Sending Transactions
Transactions are a formal action on a blockchain. They are always initiated in Kaikas with a call to the klay_sendTransaction
method. They can involve a simple sending of KLAY, may result in sending tokens, creating a new smart contract, or changing state on the blockchain in any number of ways. They are always initiated by a signature from an external account, or a simple key pair.
In Kaikas, there are several ways to make transactions. First one is to use klaytn.sendAsync
method to directly invoke klay_sendTransaction
. This method wraps RPC API and sends it to browser's Caver instance.
Another way (more recommanded) is to use Caver. Pass window.klaytn
, or just klaytn
, when creating Caver instance. After that, you can use that instance when interacting with Klaytn network. Below is an example of sending 1 KLAY. Install Caver via npm install caver-js
. You can choose whatever version of Caver you want to use.
Even without installing caver-js, you can use injected caver. If user has Kaikas installed, caver will be available as a global variable. This caver's version is 1.4.0.
From the user's perspective, the following pop-up will be shown. If the user confirms, Kaikas will sign the transaction and send it to Klaytn blockchain network.
Last updated