Write (Fee Delegation)
You can make a "transaction" that including payment request to feepayer when you want to execute the Smart Contract.
Import the ethers and @kaiachain/ethers-ext modules to add kaia features on ethers.js.
Define sender, fee payer address and sender 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 sender's wallet using the sender's private key and the provider
Create a fee payer's wallet using the sender's private key and the 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 value of number from contract by using method counter.number()
Create a transaction data to update the number value
Create a transaction object with data from previous step
Sign the transaction with sender's wallet
Send the transaction to blockchain using fee payer's wallet. Function sendTransactionAsFeePayer
adds a signature with FeePayer’s private key to the sender’s signature and transmits it to the blockchain network.
Get the updated value number by using method counter.number()