-
Notifications
You must be signed in to change notification settings - Fork 9
Creating a transfer transaction
weegee edited this page Nov 20, 2023
·
2 revisions
To create a transfer transaction currently, you don't need a Crossover or call data, so its the easier and the most basic transaction.
We just need one output note which contains the value we are transferring and the address we want to transfer the amount to
NOTE: Make sure you convert the lux value to dusk before sending with the output note
export function transfer(wasm, seed, sender, receiver, amount) {
// convert the amount from lux to dusk, this is important
amount = luxToDusk(wasm, amount);
const output = {
receiver: receiver,
// if you want to hide the value of the transaction
note_type: "Obfuscated",
// ref id of the transaction
ref_id: 1,
value: amount,
};
// random bytes
const rng_seed = new Uint8Array(32);
crypto.getRandomValues(rng_seed);
execute(
wasm,
seed,
rng_seed,
sender,
output,
// no crossover needed
undefined,
// no fees needed
undefined,
// no call data needed
undefined,
// gas limit
500000000,
// gas price
1
);
}