Transfer

The transfer method creates and optionally broadcasts MNEE token transfers. It handles all the complexity of creating valid MNEE transactions, including UTXO selection, fee calculation, and cosigner authorization.

Usage

Basic Transfer

const recipients = [{ address: 'recipient-address', amount: 2.55 }];
const wif = 'sender-wif-key';

const response = await mnee.transfer(recipients, wif);
console.log('Ticket ID:', response.ticketId);

Multiple Recipients

const recipients = [
  { address: 'recipient-1-address', amount: 2.55 },
  { address: 'recipient-2-address', amount: 5 },
  { address: 'recipient-3-address', amount: 0.75 },
];
const wif = 'sender-wif-key';

const response = await mnee.transfer(recipients, wif);
console.log('Ticket ID:', response.ticketId);

// Check status of the transfer
const status = await mnee.getTxStatus(response.ticketId);
console.log('Status:', status);

Create Without Broadcasting

Transfer with Webhook Callback

Parameters

  • request: Array of SendMNEE objects, each containing:

    • address: Recipient Bitcoin address

    • amount: Amount to send in MNEE (not atomic units)

  • wif: Wallet Import Format private key of the sender

  • transferOptions (optional): Object containing:

    • broadcast: Whether to broadcast the transaction (default: true)

    • callbackUrl: Webhook URL for status updates (only when broadcast is true)

Response

Returns a TransferResponse object:

Common Use Cases

Simple Payment

Batch Payments

Two-Step Transfer with Validation

Transfer with Balance Check

Micro-Payment Channel

Error Handling

The transfer method can throw several specific errors:

Important Notes

  • Amounts are specified in MNEE, not atomic units (1 MNEE = 100,000 atomic units)

  • The method automatically:

    • Selects appropriate UTXOs

    • Calculates fees based on transaction size

    • Adds change output if needed

    • Obtains cosigner authorization

  • Minimum transfer amount is determined by dust limit (check via config())

  • All recipients must have valid Bitcoin addresses

  • The sender must have sufficient balance to cover amounts + fees

  • When broadcast is true, the transaction is processed asynchronously and you receive a ticketId to track status

See Also

Last updated