write-txtype
Import the ethers and @kaiachain/ethers-ext modules to add kaia features on ethers.js.
Define sender address and private key
Set up the provider with the specified kaia Baobab testnet URL. A provider in ethers is a read-only abstraction to access the blockchain data.
Also, you can change the provider URL from baobab to allthatnode
create a wallet from sender private key and web3 provider
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 number value before updated by using method counter.number()
Create a transaction data to update the number value
Create a transaction object with data from previous step with type SmartContractExecution
Send the tx to the blockchain. Function sendTransaction
internally signs with the private key of the account and then transmits it to the blockchain network.
The wait function returns the tx receipt if it is completed in the blockchain.
Get the updated value number by using method counter.number()