Transfer CAPS
Prerequisites
How to transfer CAPS to an address
import {
balancesTransfer,
getKeyringFromSeed,
numberToBalance,
WaitUntil,
} from "ternoa-js";
const main = async () => {
try {
// The known accounts we want to use
const keyring = await getKeyringFromSeed("//TernoaTestAccount");
const TO_ADDRESS = "5GguNdS1T2J9BDFMqPhdPp8vtQxfhGJjiGwAaYF7TPLuiJPs";
// Amount transferred: 1 CAPS
const amount = numberToBalance(1); // 1 = 1000000000000000000 for the Ternoa blockchain
const transferData = await balancesTransfer(
TO_ADDRESS,
amount,
keyring,
WaitUntil.BlockInclusion
);
console.log(
`The amount transferred to ${TO_ADDRESS} is:`,
transferData.amountRounded,
"CAPS"
);
} catch (e) {
console.error(e);
}
};
main();Support
Last updated