Reputation: 15
Say I have an ethereum contract that uses erc721 protocol. When I create a new contract object using web3.
const contract = new web3.eth.contract(contractABI, contractAddress);
Is it possible to include only the abi of the parent erc721 contract, aslong as I only use functions that are within the erc721 scope? Or does web3 require the full abi?
I want to know if I can call upon multiple erc721 tokens sharing one abi.
Upvotes: 0
Views: 691
Reputation: 43561
Yes, you can use a common ABI for multiple contracts. The limitation is that you'll be able to use only the methods and properties defined in the ABI.
And the other way around: If you call a method that is defined in the ABI but not in the actual contract, the contract will try to run the fallback function.
web3
needs the ABI to be able to tell how to encode the function arguments and return values. So if you call foo(1, 2)
should it encode as foo(uint8 1, uint64 2)
or foo(bool true, uint256 2)
?
But it's really "just" a helper to generate the correct functions in the contract.methods.*
list and their encoding map. So if you don't need some of them, you can skip this by not defining them in the ABI.
Upvotes: 0