0

API spec for Contract:

new Contract(addressOrName: string, contractInterface: ethers.ethers.ContractInterface, signerOrProvider?: ethers.ethers.providers.Provider | ethers.ethers.Signer | undefined):

  1. With respect to the second parameter(contractInterface), can I literally just click the Copy ABI to Clipboard button for a contract on Etherscan and provide that to Contract?

https://goerli.etherscan.io/address/0x7dc68b7d0915ba5816e617528d6a0576f4143916#code

And would the JSON format of the ABI work as well? (https://api-goerli.etherscan.io/api?module=contract&action=getabi&address=0x0441ff033652bcEB75a011887F17B5dfC84Ddc6f)

  1. With respect to the third parameter, in what scenarios would you input the signer vs provider since Contract can accept both?

1 Answer 1

0

With respect to the second parameter(contractInterface), can I literally just click the Copy ABI to Clipboard button for a contract on Etherscan and provide that to Contract?

Yes, at least for 0x7dc68b7d0915ba5816e617528d6a0576f4143916 it is fine. There are certain cases in which the contract ABI is different from the actual smart contract, for example upgradable smart contract. JSON works too, but you need to convert the JSON object into a String first.

With respect to the third parameter, in what scenarios would you input the signer vs provider since Contract can accept both?

In general, if you need to send transactions, a provider object is not enough. You need a signer to sign the transaction and the signer class should include a provider.

If you just need to use this contract as, for example, a median to subscribe event or to send a call, using the provider is sufficient.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.