0

I have created a simple contract to increment a number and a .js script to call the contract. I run the .js script then I submit the incrementNumber function with remix IDE. I'm using the pending parameter on my Web3 script to see if the value is updated when the transaction that I submitted is still pending. But I just found out that the value get updated only if the transaction is confirmed on the block.

Then I try to use a really low gas price to submit the incrementNumber again to makes the transaction keep on pending state as long as it could. And as I guessed that the number value isn't changed.

So my question is, does pending parameter on contract call really does something ? Or we can only see if the value changed only when the transaction is confirmed ?

https://web3js.readthedocs.io/en/v1.5.2/web3-eth-contract.html#methods-mymethod-call

By the way I'm using Ropsten network to test the contract and the script

const abi = [
  {
    inputs: [],
    name: "getNumber",
    outputs: [
      {
        internalType: "uint256",
        name: "",
        type: "uint256",
      },
    ],
    stateMutability: "view",
    type: "function",
  },
  {
    inputs: [],
    name: "incrementNumber",
    outputs: [],
    stateMutability: "nonpayable",
    type: "function",
  },
];

const batman = async () => {
  const contract = new web3.eth.Contract(
    abi,
    "0xf29B98b41AF25c82668833A3B87fAC339D672042"
  );
  const aa = await contract.methods
    .getNumber()
    .call({ from: "0x4aA5a7C02696c25F3aF86950B132C6a173f79d6F" }, "pending");

  console.log("aa", aa);
  batman().then().catch();
};

batman().then().catch();
2
  • ethereum.stackexchange.com/questions/3400/… I think ropsten mine ur transaction too fast so u can’t notice it. Try to send a tx with a very low fee then it will probably get stuck in pending and u can check the result
    – Majd TL
    Oct 12 '21 at 11:39
  • and try to connect to the same node
    – Majd TL
    Oct 12 '21 at 11:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.