简体   繁体   English

获取智能合约,web3 python

[英]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?正确,我理解地址就足够了,因为在它的帮助下,我可以参考合同日期字段,并通过解码 abi?

It is also not clear why in web3, when referring to a contract, it is obligatory to use both the address and abi?也不清楚为什么在 web3 中,当引用合约时,必须同时使用地址和 abi?

token_contract = w3.eth.contract(address=address, abi=abi)

why not:为什么不:

token_contract = w3.eth.contract(address=address)

Abi tells how to interact with/use your contract. Abi 告诉如何与你的合约交互/使用你的合约。 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. Abi 就像智能合约的用户手册。

The ABI encodes information about smart contracts' functions and events. ABI 对有关智能合约功能和事件的信息进行编码。 It acts as an interface between EVM-level bytecode and high-level smart contract program code.它充当 EVM 级字节码和高级智能合约程序代码之间的接口。 To interact with a smart contract deployed on the Ethereum blockchain, external programs require an ABI and the address of the smart contract.为了与部署在以太坊区块链上的智能合约进行交互,外部程序需要 ABI 和智能合约的地址。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM