Send a Transaction
Code Example: Sending 1 KTA
/**
* Load the KeetaNet Client SDK
*/
const KeetaNet = require('@keetanetwork/keetanet-client');
/**
* This is the fake seed for the demo account, replace with a valid one
*/
const DEMO_ACCOUNT_SEED = 'D3M0D3M0D3M0D3M0D3M0D3M0D3M0D3M0D3M0D3M0D3M0D3M0D3M0D3M0D3M0D3M0';
async function main() {
// Create a signer account from the demo seed (account index 0)
const signer_account = KeetaNet.lib.Account.fromSeed(DEMO_ACCOUNT_SEED, 0);
console.log('🔑 Signer account:', signer_account.publicKeyString.get());
// Connect to the Keeta test network
const client = KeetaNet.UserClient.fromNetwork('test', signer_account);
// Start building a transaction
const builder = client.initBuilder();
// Define the recipient (the faucet address for testing)
const faucet_account = KeetaNet.lib.Account.fromPublicKeyString(
'keeta_aabszsbrqppriqddrkptq5awubshpq3cgsoi4rc624xm6phdt74vo5w7wipwtmi'
);
// Add a send operation to the builder: 1 KTA to the faucet address
builder.send(faucet_account, 1n, client.baseToken);
// Compute the transaction blocks (Keeta breaks operations into blocks)
const computed = await client.computeBuilderBlocks(builder);
console.log('🧱 Computed blocks:', computed.blocks);
// Publish the transaction to the network
const transaction = await client.publishBuilder(builder);
console.log('✅ Transaction published:', transaction);
}
main().then(
() => process.exit(0),
(err) => {
console.error('❌ Error:', err);
process.exit(1);
}
);
What's Happening Here?
Last updated