Write (Fee Delegation)
You can make a "transaction" that including payment request to feepayer when you want to execute the Smart Contract.
Import the web3 and @kaiachain/web3js-ext packages to add kaia features on web3
Define sender, fee payer addresses and private keys
Set up the provider with the specified kairos testnet URL. A provider in web3 is a read-only abstraction to access the blockchain data.
Also, you can change the provider URL from kairos to quicknode
Create a sender and fee payer account from defined private key using web3.eth.accounts.privateKeyToAccount
Define contract Abi and contract address
Create a contract instance using Web3.eth.Contract
with defined contractAbi and address. You can read and write the contract through this instance
Get the value of number before update
Encoded the contract method data with contract.methods.increment().encodeABI()
Create a transaction to update the value number with type: FeeDelegatedSmartContractExecution
Sign the transaction with sender account using signTransaction
Sign the transaction with fee payer account using signTransactionAsFeePayer
Send the transaction to blockchain. It will return the transaction receipt
Get the updated value of number