•   12 months ago

Confirmation on transaction flow with Theta blockchain?

My understanding is that the Theta blockchain uses the Proof of Stake protocol and its VM is language compatible with the Ethereum VM (Solidity, etc.). So it is a one step transaction submission process, correct? I want to make sure that I don't have to execute a two-step transaction process like I have to with Ethereum 1.0 since it uses Proof of Work (i.e. - 1) Submit request and receive nonce, 2) wait for transaction to be mined and receive confirmation or rejection). Instead, with the Theta blockchain, it's just submit the transaction and receive confirmation or rejection, all in one step, right? If there is a good sample that shows me the proper workflow, then that would be helpful.

  • 1 comment

  • Manager   •   11 months ago

    To make sure your transaction is confirmed on chain, you'd still need to get the tx hash and confirm that it is finalized on chain.

    If you use JS libraries like web3.js for contract deployment/interaction, you won't need to manually verify if the tx is confirmed. Something like this should work:

    ```
    // Please provide the actual private key, contract abi and bytecode
    const yourDeployerWalletPrivateKey = "xxxxxxx";
    const myContractABI = [....];
    const myContractBytecodes = "0xxxxxxxx";

    const HDWalletProvider = require('@truffle/hdwallet-provider');
    const Web3 = require('web3');
    const gasPrice = '4000000000000';
    let provider = new HDWalletProvider({
    privateKeys: [yourDeployerWalletPrivateKey],
    providerOrUrl: "https://eth-rpc-api.thetatoken.org/rpc",
    });
    const web3 = new Web3(provider);

    // Contract deployment
    const deployContracts = async () {
    let deployer = provider.addresses[0];
    const contract = new web3.eth.Contract(myContractABI);
    let myContract = await contract.deploy({
    data: myContractBytecodes,
    }).send({from: deployer, gas: 10000000, gasPrice: gasPrice});
    }

    // Calling a contract method. Please replace XXXXX with the actual method you would like to call
    let myContractAddress = "0xxxxxxxxxx"
    const callContract = async () {
    const myContract = new web3.eth.Contract(myContractABI, myContractAddress);
    let result = await myContract.methods.XXXXX().call();
    console.log("result:", result)
    }
    ```

Comments are closed.