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 web3 and @kaiachain/web3js-ext packages to add kaia features on web3
Set up the provider with the specified kairos testnet URL. A provider in web3js is a read-only abstraction to access the blockchain data.
Also, you can change the provider URL from kairos to quicknode
Define contract Abi and addreess, you can get it from compiled solidity code
Create a contract instance using Web3.eth.Contract
with defined contractAbi and address. You can read and write the contract through this instance
Call function number of created contract and print the result