Write (Fee Delegation)
You can make a "transaction" that including payment request to feepayer when you want to execute the Smart Contract.
Import extend from web3py_ext to extend web3 to kaia web3
Import necessary utils from web3 and eth_account
Create a Web3 instance with the kaia Baobab testnet endpoint
Also, you can change the provider URL from baobab to allthatnode
Load the user and fee delegator account from each private key
Create the contract instance with its address and ABI
Set the contract address that you deployed in the deploy tutorial (Counter contract). You can see the address in your deploy tx receipt
Set the contract abi. You can get the ABI after compiled in remix or solc compiler
Call the view function of the contract and print the result
Make a tx with build_transaction that returns the tx instance along with passed fields as parameter. You should set the TxType.FEE_DELEGATED_SMART_CONTRACT_EXECUTION type to request fee delegation to fee payer
increment() automatically makes the function call data and set it to the data field
Use fill_transaction to add rest of the fields of the transaction like gas limit, Nonce, etc. You can print all the fields after this line if you want to see
Sign the transaction with the user's private key
Sign the transaction as fee payer with the fee delegator's key. You need to pass the fee payer's address as well.
Send the raw transaction and get the transaction hash
Wait for the transaction receipt
Check if contract has updated the state