vue-dapp icon indicating copy to clipboard operation
vue-dapp copied to clipboard

vue-dapp internal provider signer does not read updated state of contract properly

Open olifur opened this issue 2 years ago • 1 comments

Hi everyone!

I got the following problem:

If I use the provider coming with vue-dapp, requesting changed state from the blockchain is not working at all.

changing the state of a contract variable on the blockchain using an external node script:

await (await nftContract.connect(signer).startMinting()).wait();
console.log("is minting started  " + await nftContract.hasMintingStarted());

always outputs true.

When I connect the metamask provider to my dapp using vue-dapp in the browser and use its signer I get:

...
const { address, balance, provider, signer, isActivated } = useEthers()
...
this.nftContract = new ethers.Contract(this.nftContractAddress, nftContractAbi, signer.value);
console.log("is minting started  " + await this.nftContract.hasMintingStarted());

it returns false.

But, when I create a new provider in the same Dapp:


      const abi = JSON.parse('[{"inputs":[{"..."}]')

      const provider = new ethers.providers.JsonRpcProvider("http://localhost:8545")
      const signer = provider.getSigner(0);
      const nftContractAddress = "0x...";

      const nftContract = new ethers.Contract(nftContractAddress, abi, signer)

      console.log("is minting started  " + await nftContract.hasMintingStarted());
    }

it returns true!

So somehow the signer connecting through metamask is not working properly.

Please note that I am using a forked hardhat localhost archive node .

Best, Oliver

olifur avatar Aug 01 '22 10:08 olifur

Hi @olifur can you provide a replicable example code where we can investigate your case ?

re2005 avatar Aug 14 '22 18:08 re2005

@olifur Hmm... are you sure that your metamask wallet connected to the localhost network?

johnson86tw avatar Oct 26 '22 14:10 johnson86tw

Close this issue as vue-dapp has introduced a new version with breaking changes. If there is an issue, please open a new one.

johnson86tw avatar Jan 28 '24 09:01 johnson86tw