'Getting a smart contract, web3 python
How can I access smart contract calls with only the address of the contract? Correctly, I understand that the address will be enough, because with the help of it I can refer to the contract date field, and by decoding the abi?
It is also not clear why in web3, when referring to a contract, it is obligatory to use both the address and abi?
token_contract = w3.eth.contract(address=address, abi=abi)
why not:
token_contract = w3.eth.contract(address=address)
Solution 1:[1]
Abi tells how to interact with/use your contract. Address alone is not enough, it just points to contract on blockchain which is stored in binary form(opcodes). Abi is like an user manual of smart contract.
Solution 2:[2]
The ABI encodes information about smart contracts' functions and events. It acts as an interface between EVM-level bytecode and high-level smart contract program code. To interact with a smart contract deployed on the Ethereum blockchain, external programs require an ABI and the address of the smart contract.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | kj-crypto |
Solution 2 | Yilmaz |