本页面使用机器翻译自英语,可能包含错误或不清楚的语言。如需最准确的信息,请参阅英文原文。由于更新频繁,部分内容可能与英文原文有出入。请加入我们在 Crowdin 上的努力,帮助我们改进本页面的翻译。 (Crowdin translation page, Contributing guide)
Read
You can call functions in Smart Contract via "Call" RPC API. What you can call here is limited to view functions that is not changing any states in the Contract.
Import the @kaiachain/ethers-ext modules to add kaia features on web3.
Initializes a public client for read-only interactions with the Kaia blockchain.
Set the Abi generated from solidity code
Define contract address to interact with
The readContract
method is called on the public client to query the number function (a view function that doesn’t modify state) from the contract at the specified address.