This page uses machine translation from English, which may contain errors or unclear language. For the most accurate information, please see the original English version. Some content may be in the original English due to frequent updates. Help us improve this page's translation by joining our effort on 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 ethers and @kaiachain/ethers-ext modules to add kaia features on ethers.js.
Set up the provider with the specified kairos testnet URL. A provider in ethers is a read-only abstraction to access the blockchain data.
Also, you can change the provider URL from kairos to quicknode
Set the Abi generated from solidity code
Define contract address to interact with
Create a contract instance with ethers.Contract, fill in params contractAddr, abi, provider. You can read and write the contract through this instance
Get the value of number from contract by using method counter.number()