Smart Contract Deploy
TxTypeSmartContractDeploy deploys a smart contract to the given address. The following changes will be made by this transaction type.
Import the ethers and @kaiachain/ethers-ext modules to add kaia features on ethers.js.
Define sender's and fee payer's addresses and private keys
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 wallets for the sender and fee payer using their private keys
Define the transaction object for a fee-delegated smart contract deployment
Specify the transaction type as FeeDelegatedSmartContractDeploy
Specify the contract bytecode, you can retreive it from block explorer
Populate the transaction with additional details (e.g., gas limit)
Sign the transaction with the sender's private key
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.
The wait function returns the tx receipt if the tx was sent to the blockchain successfully.