Error: sending a transaction requires a signer while calling aggregate function of Multicall Contract Ethereum

Viewed 10981
2 Answers

You must provide a signer to perform the solidity method.

You can get a signer from your web3 provider.

You can bind a signer to the Contract like so

import Contract from './artifacts/contracts/Contract.sol/Contract.json'
const contractDeployedAddress = "0xblah";

const provider = new ethers.providers.Web3Provider(window.ethereum)
const signer = provider.getSigner();
const contract = new ethers.Contract(contractDeployedAddress, Contract.abi, signer)

await contract.someMethodThatRequiresSigning();

I have similar situation which is using @web3-react with reference to the uniswap-interface code.

@web3-react base on the ethers.js, and we must execute the State Changing Methods with signer. I post a sample that I solved.

const { library, account } = useActiveWeb3React();

const contract = getContract(
      CONTRACT_ADDRESS,
      abi,
      library
    );
const signer = contract.connect(library.getSigner());
signer.someStateChangingMethods();

This may help you. https://docs.ethers.io/v5/getting-started/#getting-started--writing

Related