Transactions

The following shows how to create a simple transaction (STX transfer) using Stacks.js in different environments.

  import { openSTXTransfer } from '@stacks/connect';
  import { StacksTestnet } from '@stacks/network';
  import { AnchorMode } from '@stacks/transactions';

  openSTXTransfer({
    network: new StacksTestnet(),

    recipient: 'ST39MJ145BR6S8C315AG2BD61SJ16E208P1FDK3AK', // which address we are sending to
    amount: 10000, // tokens, denominated in micro-STX
    anchorMode: AnchorMode.Any,

    onFinish: response => console.log(response.txid),
    onCancel: () => console.log('User canceled'),
  });

Last updated on