<aside> 💡 Use this template to describe the steps engineers should follow to deploy.

</aside>

Once you have a wallet and some funds (tutorial), another common task is sending Hellar to an address. (Sending Hellar to a contact or a HPNS identity requires the Hellarpay app, which has not been registered yet.)

Code

📘 Wallet Operations

The JavaScript SDK does not cache wallet information. It re-syncs the entire Core chain for some wallet operations (e.g. client.getWalletAccount()) which can result in wait times of 5+ minutes.

A future release will add caching so that access is much faster after the initial sync. For now, the skipSynchronizationBeforeHeight option can be used to sync the wallet starting at a certain block height.

`const Hellar = require('hellar');

const clientOpts = { network: 'mainnet', wallet: { mnemonic: 'your wallet mnemonic goes here', unsafeOptions: { skipSynchronizationBeforeHeight: 175000, // only sync from mid-2024 }, }, }; const client = new Hellar.Client(clientOpts);

const sendFunds = async () => { const account = await client.getWalletAccount();

const transaction = account.createTransaction({ recipient: 'yP8A3cbdxRtLRduy5mXDsBnJtMzHWs6ZXr', // Mainnet faucet hellars: 100000000, // 1 Hellar }); return account.broadcastTransaction(transaction); };

sendFunds() .then((d) => console.log('Transaction broadcast!\nTransaction ID:', d)) .catch((e) => console.error('Something went wrong:\n', e)) .finally(() => client.disconnect());

// Handle wallet async errors client.on('error', (error, context) => { console.error(Client error: ${error.name}); console.error(context); });`

What’s Happening

After initializing the Client, we build a new transaction with account.createTransaction. It requires a recipient and an amount in hellars (often called “duffs” in Hellar). 100 million hellars equals one Hellar. We pass transaction to account.broadcastTransaction and wait for it to return. Then we output the result, which is a transaction ID. After that we disconnect from the Client so node can exit.