All transfer operations use the following structure:
interface TransferOperation { from: string // Sender's account name to: string // Recipient's account name amount: string // Amount with 3 decimal places and asset symbol memo: string // Transfer memo (can be encrypted)}
Move funds to your savings account for added security. Savings withdrawals have a 3-day waiting period.
import { Transaction, PrivateKey } from 'hive-tx'async function transferToSavings() { const tx = new Transaction() await tx.addOperation('transfer_to_savings', { from: 'myaccount', to: 'myaccount', // Can transfer to own or another account amount: '100.000 HIVE', memo: 'Moving to savings' }) const key = PrivateKey.from('your-active-key') tx.sign(key) const result = await tx.broadcast() console.log('Transfer to savings successful!', result.result.tx_id)}
Withdraw funds from savings. The funds will be available after a 3-day waiting period.
import { Transaction, PrivateKey } from 'hive-tx'async function transferFromSavings() { const tx = new Transaction() await tx.addOperation('transfer_from_savings', { from: 'myaccount', request_id: 1, // Unique ID for this withdrawal request to: 'myaccount', // Destination account amount: '50.000 HIVE', memo: 'Withdrawing from savings' }) const key = PrivateKey.from('your-active-key') tx.sign(key) const result = await tx.broadcast() console.log('Withdrawal initiated!', result.result.tx_id) console.log('Funds will be available in 3 days')}
interface TransferFromSavingsOperation { from: string // Account withdrawing from savings request_id: number // Unique request ID (must be unique per account) to: string // Destination account amount: string // Amount with asset symbol memo: string // Transfer memo}