Skip to main content
This page demonstrates common account management operations on the Hive blockchain.

Claim Rewards

Claim your pending author, curation, and vesting rewards.
import { Transaction, PrivateKey } from 'hive-tx'

async function claimRewards() {
  const tx = new Transaction()
  
  await tx.addOperation('claim_reward_balance', {
    account: 'your-username',
    reward_hive: '0.123 HIVE',      // Amount of HIVE to claim
    reward_hbd: '0.456 HBD',        // Amount of HBD to claim
    reward_vests: '123.456789 VESTS'  // Amount of VESTS to claim (6 decimals)
  })
  
  const key = PrivateKey.from('your-posting-key')
  tx.sign(key)
  
  const result = await tx.broadcast()
  console.log('Rewards claimed!', result.result.tx_id)
}

ClaimRewardBalanceOperation Type

interface ClaimRewardBalanceOperation {
  account: string           // Your account name
  reward_hive: string       // HIVE amount with 3 decimals
  reward_hbd: string        // HBD amount with 3 decimals
  reward_vests: string      // VESTS amount with 6 decimals
}

Get Pending Rewards Before Claiming

You should fetch your pending rewards before claiming them.
import { callRPC } from 'hive-tx'

async function getPendingRewards(account: string) {
  const accounts = await callRPC('condenser_api.get_accounts', [[account]])
  
  if (accounts && accounts.length > 0) {
    const acc = accounts[0]
    return {
      reward_hive: acc.reward_hive_balance,
      reward_hbd: acc.reward_hbd_balance,
      reward_vests: acc.reward_vesting_balance
    }
  }
  
  throw new Error('Account not found')
}

// Usage:
const rewards = await getPendingRewards('your-username')
console.log('Pending rewards:', rewards)
// Output: { reward_hive: '0.123 HIVE', reward_hbd: '0.456 HBD', reward_vests: '123.456789 VESTS' }

Claim All Available Rewards

import { Transaction, PrivateKey, callRPC } from 'hive-tx'

async function claimAllRewards(account: string) {
  // Get pending rewards
  const accounts = await callRPC('condenser_api.get_accounts', [[account]])
  const acc = accounts[0]
  
  const tx = new Transaction()
  
  await tx.addOperation('claim_reward_balance', {
    account,
    reward_hive: acc.reward_hive_balance,
    reward_hbd: acc.reward_hbd_balance,
    reward_vests: acc.reward_vesting_balance
  })
  
  const key = PrivateKey.from('your-posting-key')
  tx.sign(key)
  
  const result = await tx.broadcast()
  console.log('All rewards claimed!', result.result.tx_id)
}

Delegate VESTS (Hive Power)

Delegate your Hive Power (in VESTS) to another account.
import { Transaction, PrivateKey } from 'hive-tx'

async function delegateVests() {
  const tx = new Transaction()
  
  await tx.addOperation('delegate_vesting_shares', {
    delegator: 'your-username',         // Your account
    delegatee: 'recipient-username',    // Account receiving delegation
    vesting_shares: '1000000.000000 VESTS'  // Amount to delegate (6 decimals)
  })
  
  const key = PrivateKey.from('your-active-key')
  tx.sign(key)
  
  const result = await tx.broadcast()
  console.log('Delegation successful!', result.result.tx_id)
}

DelegateVestingSharesOperation Type

interface DelegateVestingSharesOperation {
  delegator: string           // Delegating account
  delegatee: string           // Receiving account
  vesting_shares: string      // VESTS amount with 6 decimals
}

Remove Delegation

To remove a delegation, delegate 0.000000 VESTS to the same account.
import { Transaction, PrivateKey } from 'hive-tx'

async function removeDelegation() {
  const tx = new Transaction()
  
  await tx.addOperation('delegate_vesting_shares', {
    delegator: 'your-username',
    delegatee: 'recipient-username',
    vesting_shares: '0.000000 VESTS'  // 0 VESTS removes delegation
  })
  
  const key = PrivateKey.from('your-active-key')
  tx.sign(key)
  
  const result = await tx.broadcast()
  console.log('Delegation removed!', result.result.tx_id)
  console.log('Delegated HP will return in 5 days')
}
When you remove a delegation, the Hive Power returns to you after a 5-day cooldown period.

Power Up (Convert HIVE to Hive Power)

Convert liquid HIVE to Hive Power (VESTS) for yourself or another account.
import { Transaction, PrivateKey } from 'hive-tx'

async function powerUp() {
  const tx = new Transaction()
  
  await tx.addOperation('transfer_to_vesting', {
    from: 'your-username',      // Account sending HIVE
    to: 'your-username',        // Account receiving Hive Power (can be different)
    amount: '100.000 HIVE'      // Amount to power up
  })
  
  const key = PrivateKey.from('your-active-key')
  tx.sign(key)
  
  const result = await tx.broadcast()
  console.log('Power up successful!', result.result.tx_id)
}

TransferToVestingOperation Type

interface TransferToVestingOperation {
  from: string        // Account sending HIVE
  to: string          // Account receiving Hive Power
  amount: string      // HIVE amount with 3 decimals
}

Power Up to Another Account

You can power up HIVE directly to another account.
import { Transaction, PrivateKey } from 'hive-tx'

async function powerUpToOther() {
  const tx = new Transaction()
  
  await tx.addOperation('transfer_to_vesting', {
    from: 'your-username',
    to: 'other-username',      // Different account receives the HP
    amount: '50.000 HIVE'
  })
  
  const key = PrivateKey.from('your-active-key')
  tx.sign(key)
  
  const result = await tx.broadcast()
  console.log('Powered up to other account!', result.result.tx_id)
}

Power Down (Start Withdrawing Hive Power)

Initiate a power down to convert Hive Power back to liquid HIVE over 13 weeks.
import { Transaction, PrivateKey } from 'hive-tx'

async function startPowerDown() {
  const tx = new Transaction()
  
  await tx.addOperation('withdraw_vesting', {
    account: 'your-username',
    vesting_shares: '13000.000000 VESTS'  // Amount to power down (6 decimals)
  })
  
  const key = PrivateKey.from('your-active-key')
  tx.sign(key)
  
  const result = await tx.broadcast()
  console.log('Power down initiated!', result.result.tx_id)
  console.log('You will receive 1/13 of the amount each week for 13 weeks')
}

WithdrawVestingOperation Type

interface WithdrawVestingOperation {
  account: string           // Your account name
  vesting_shares: string    // VESTS amount with 6 decimals
}

Stop Power Down

To stop an ongoing power down, withdraw 0.000000 VESTS.
import { Transaction, PrivateKey } from 'hive-tx'

async function stopPowerDown() {
  const tx = new Transaction()
  
  await tx.addOperation('withdraw_vesting', {
    account: 'your-username',
    vesting_shares: '0.000000 VESTS'  // 0 VESTS stops power down
  })
  
  const key = PrivateKey.from('your-active-key')
  tx.sign(key)
  
  const result = await tx.broadcast()
  console.log('Power down stopped!', result.result.tx_id)
}

Vote for Witness

Vote for a witness (block producer) on the Hive blockchain.
import { Transaction, PrivateKey } from 'hive-tx'

async function voteForWitness() {
  const tx = new Transaction()
  
  await tx.addOperation('account_witness_vote', {
    account: 'your-username',
    witness: 'witness-username',
    approve: true  // true to vote, false to unvote
  })
  
  const key = PrivateKey.from('your-active-key')
  tx.sign(key)
  
  const result = await tx.broadcast()
  console.log('Witness vote successful!', result.result.tx_id)
}

AccountWitnessVoteOperation Type

interface AccountWitnessVoteOperation {
  account: string     // Your account name
  witness: string     // Witness account name
  approve: boolean    // true = vote, false = unvote
}

Unvote a Witness

Remove your vote from a witness.
import { Transaction, PrivateKey } from 'hive-tx'

async function unvoteWitness() {
  const tx = new Transaction()
  
  await tx.addOperation('account_witness_vote', {
    account: 'your-username',
    witness: 'witness-username',
    approve: false  // false to unvote
  })
  
  const key = PrivateKey.from('your-active-key')
  tx.sign(key)
  
  const result = await tx.broadcast()
  console.log('Witness unvoted!', result.result.tx_id)
}

Vote for Multiple Witnesses

import { Transaction, PrivateKey } from 'hive-tx'

async function voteForMultipleWitnesses() {
  const tx = new Transaction()
  
  const witnesses = ['witness1', 'witness2', 'witness3', 'witness4']
  
  for (const witness of witnesses) {
    await tx.addOperation('account_witness_vote', {
      account: 'your-username',
      witness: witness,
      approve: true
    })
  }
  
  const key = PrivateKey.from('your-active-key')
  tx.sign(key)
  
  const result = await tx.broadcast()
  console.log(`Voted for ${witnesses.length} witnesses!`, result.result.tx_id)
}
You can vote for up to 30 witnesses. Use your votes to support witnesses who contribute to the network.

Set Withdraw Vesting Route

Route a percentage of your weekly power down payments to another account.
import { Transaction, PrivateKey } from 'hive-tx'

async function setWithdrawRoute() {
  const tx = new Transaction()
  
  await tx.addOperation('set_withdraw_vesting_route', {
    from_account: 'your-username',
    to_account: 'other-username',
    percent: 5000,        // 5000 = 50% (in basis points)
    auto_vest: false      // false = liquid HIVE, true = power up to recipient
  })
  
  const key = PrivateKey.from('your-active-key')
  tx.sign(key)
  
  const result = await tx.broadcast()
  console.log('Withdraw route set!', result.result.tx_id)
}

SetWithdrawVestingRouteOperation Type

interface SetWithdrawVestingRouteOperation {
  from_account: string    // Your account name
  to_account: string      // Destination account
  percent: number         // Percentage in basis points (5000 = 50%)
  auto_vest: boolean      // true = power up, false = liquid
}

Remove Withdraw Route

To remove a withdraw route, set percent to 0.
import { Transaction, PrivateKey } from 'hive-tx'

async function removeWithdrawRoute() {
  const tx = new Transaction()
  
  await tx.addOperation('set_withdraw_vesting_route', {
    from_account: 'your-username',
    to_account: 'other-username',
    percent: 0,           // 0 removes the route
    auto_vest: false
  })
  
  const key = PrivateKey.from('your-active-key')
  tx.sign(key)
  
  const result = await tx.broadcast()
  console.log('Withdraw route removed!', result.result.tx_id)
}

Important Notes

  • Claim rewards: Use posting key
  • Delegate, power up/down, witness votes, withdraw routes: Use active key
  • Power down occurs over 13 weeks (1/13 per week)
  • Removing delegation has a 5-day return period
  • VESTS amounts use 6 decimal places
  • HIVE/HBD amounts use 3 decimal places
  • Withdraw route percentages are in basis points (100 = 1%, 10000 = 100%)
Convert Hive Power to VESTS before delegating using the dynamic global properties API to get the current HIVE to VESTS ratio.

Build docs developers (and LLMs) love