Smart Contract Deploy
TxTypeSmartContractDeploy deploys a smart contract to the given address. The following changes will be made by this transaction type.
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 kaia Baobab testnet URL. A provider in web3 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 with the private key using web3.eth.accounts.privateKeyToAccount
Create a fee payer's wallet with the private key using web3.eth.accounts.privateKeyToAccount
Define a transaction object
Set type: TxType.FeeDelegatedSmartContractDeploy
for transaction to deploy a new contract with a fee payer
Set data: "0x60806040...
is the bytecode of the compile solidity source code
Set others required parameters such as senderAddr, humanReadable, codeFormat
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