Created
February 4, 2023 17:19
-
-
Save dbuarque/7f9a1c364ff903565a3288e26986065f to your computer and use it in GitHub Desktop.
How to send crypto using klever blockchain
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Account, TransactionType } from "@klever/sdk"; | |
// Define the transaction payload object | |
const payload = { | |
amount // The amount of KLV to be transferred | |
receiver, // The address of the receiver | |
kda: 'KLV', // The symbol for the KLEVER token or your token id | |
}; | |
// The private key of the sender's account | |
const privateKey = "yourPrivateKey"; | |
// Create an instance of the Account class with the private key | |
const account = new Account(privateKey); | |
// Wait until the account instance is ready to use | |
await account.ready; | |
// Use the `quickSend` method to perform a transfer transaction | |
const broadcastRes = await account.quickSend([ | |
{ | |
payload, // The transaction payload | |
type: TransactionType.Transfer, // The type of transaction is a transfer | |
}, | |
]); | |
// The `quickSend` method is a convenient way to perform a buildTransaction + signTransaction + broadcastTransactions all in one call | |
// Log the result of the broadcast transaction | |
console.log(broadcastRes); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment