0

I want to store a document hash on an Ethereum network. I have two options. 1st one is to send the transaction directly through a node js application with input field as the document hash ie,

        const txObject = {
        nonce: web3.utils.toHex(count),
        to: toAccount,
        gasLimit: web3.utils.toHex(estimatedGas),
        gasPrice: web3.utils.toHex(web3.utils.toWei('9', 'gwei')),
        data: web3.utils.toHex(message)
    }`

2nd way is to send it by smart contract:

function notarizeHash(uint256 id, bytes32 documentHash) public onlyOwner noHashExistsYet(id) {
        hashesById[id] = documentHash;

I want to find how much is the gas difference. How can I find the gas required of function notarizeHash without actually deploying it in the main net?

Mr.SsS
  • 415
  • 4
  • 14
  • You have the answer to this question, inside the answer that I gave you to your previous question: await transaction.estimateGas(...), with transaction initialized as contract.methods.notarizeHash(...). Have you bothered to read that answer at all??? – goodvibration Jun 11 '20 at 06:38
  • Hey @goodvibration yes I read the answer.. But doesn't it require to first deploy the contract to the ethereum main net? – Mr.SsS Jun 11 '20 at 07:00
  • You can: 1. Deploy to a public testnet (e.g., ropsten). 2. Deploy to a private network (e.g., using Ganache). – goodvibration Jun 11 '20 at 07:53
  • When we deploy it to test net does it give accurate gas estimation? – Mr.SsS Jun 11 '20 at 08:08
  • To a public testnet - yes. To a private network, if you're using Ganache, then there's some deviation (and it also depends on the Ganache version used). – goodvibration Jun 11 '20 at 08:13

0 Answers0