vue-dapp
vue-dapp copied to clipboard
vue-dapp internal provider signer does not read updated state of contract properly
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
Hi @olifur can you provide a replicable example code where we can investigate your case ?
@olifur Hmm... are you sure that your metamask wallet connected to the localhost network?
Close this issue as vue-dapp has introduced a new version with breaking changes. If there is an issue, please open a new one.