Problem: Cannot send transaction to contract with metamask when using Ether.js
I can get a result when calling a public view function as shown below.
However, when calling a normal function, metamask does not pop-up the window to send the transaction. Any ideas?

let provider = new ethers.providers.Web3Provider(web3.currentProvider);
let contractAddress = "--address--";

let contract = new ethers.Contract(contractAddress, abi, provider.getSigner());
contract.getterFunction().then((f) => {
                                   alert(f); //works
contract.stateChangeFunction(0).then((f) => { //no metamask pop-up

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.