Skip to main content
Operations are the atomic actions that modify the Hive blockchain state. Every transaction contains one or more operations that execute sequentially when the transaction is included in a block.

What Are Operations?

In Hive, operations represent specific actions like voting, transferring funds, publishing content, or updating account settings. Each operation has:
  • A unique name (e.g., vote, transfer, comment)
  • A structured body containing the operation’s parameters
  • Specific authority requirements (which key type is needed)

Operation Structure

All operations follow the same tuple format:
type Operation = [operationName, operationBody]
For example, a vote operation:
const voteOp: Operation = [
  'vote',
  {
    voter: 'alice',
    author: 'bob',
    permlink: 'awesome-post',
    weight: 10000  // 100% upvote
  }
]
The tuple format [name, body] is Hive’s protocol-level structure. hive-tx preserves this for compatibility while adding TypeScript type safety.

Type-Safe Operations

hive-tx provides full TypeScript types for all operations. When you call addOperation(), you get autocomplete and type checking:
await tx.addOperation('transfer', {
  from: 'alice',
  to: 'bob',
  amount: '5.000 HIVE',
  memo: 'Thanks!'  // TypeScript knows this field exists
})

// TypeScript error: Property 'amount' is missing
await tx.addOperation('transfer', {
  from: 'alice',
  to: 'bob',
  memo: 'Oops, forgot amount!'
})

Type Inference

The addOperation method uses conditional types to ensure the body matches the operation name:
src/Transaction.ts:59
async addOperation<O extends OperationName>(
  operationName: O,
  operationBody: OperationBody<O>
): Promise<void>
This means TypeScript enforces that a vote operation must have VoteOperation structure, a transfer must have TransferOperation, etc.

Common Operations

Voting

Upvote or downvote content:
src/types.ts:45
await tx.addOperation('vote', {
  voter: 'alice',         // Your username
  author: 'bob',          // Post/comment author
  permlink: 'post-slug',  // Post/comment identifier
  weight: 10000           // -10000 to 10000 (100% downvote to 100% upvote)
})
Authority Required: Posting key
Vote weight ranges from -10000 to 10000:
  • 10000 = 100% upvote
  • 5000 = 50% upvote
  • 0 = Remove vote
  • -10000 = 100% downvote (flag)

Transfer

Send HIVE or HBD between accounts:
src/types.ts:62
await tx.addOperation('transfer', {
  from: 'alice',
  to: 'bob',
  amount: '10.000 HIVE',  // Must include 3 decimal places and symbol
  memo: 'Payment for services'
})
Authority Required: Active key
Amounts must be formatted as strings with exactly 3 decimal places and the asset symbol (HIVE, HBD, or VESTS). Example: '1.000 HIVE'

Comment (Post/Reply)

Publish posts or replies:
src/types.ts:52
// Create a new post
await tx.addOperation('comment', {
  parent_author: '',              // Empty for top-level posts
  parent_permlink: 'hive',        // Category/tag for posts
  author: 'alice',
  permlink: 'my-post-slug',
  title: 'My First Post',
  body: 'This is the post content in markdown.',
  json_metadata: JSON.stringify({
    tags: ['hive', 'introduction'],
    app: 'my-app/1.0.0'
  })
})

// Create a reply
await tx.addOperation('comment', {
  parent_author: 'bob',           // Author of post you're replying to
  parent_permlink: 'post-slug',   // Permlink of parent post
  author: 'alice',
  permlink: 're-post-slug-20260304',  // Must be unique
  title: '',                      // Empty for replies
  body: 'Great post!',
  json_metadata: '{}'
})
Authority Required: Posting key

Custom JSON

Execute custom operations for apps and games:
src/types.ts:153
await tx.addOperation('custom_json', {
  required_auths: [],              // Active key authorities (use for financial ops)
  required_posting_auths: ['alice'], // Posting key authorities
  id: 'follow',                    // Operation identifier
  json: JSON.stringify([
    'follow',
    {
      follower: 'alice',
      following: 'bob',
      what: ['blog']  // Follow bob's blog
    }
  ])
})
Authority Required: Posting key (if using required_posting_auths) or Active key (if using required_auths)
Custom JSON operations are perfect for building social features, games, and app-specific logic without modifying the blockchain protocol.

All Available Operations

The complete operation types are defined in types.ts:
  • vote - Upvote or downvote content
  • comment - Create posts or replies
  • delete_comment - Delete a post/comment
  • custom_json - Custom app operations
  • transfer - Send HIVE/HBD
  • transfer_to_vesting - Power up HIVE to HP
  • withdraw_vesting - Start power down
  • transfer_to_savings - Move to savings
  • transfer_from_savings - Withdraw from savings (3-day delay)
  • claim_reward_balance - Claim pending rewards
  • limit_order_create - Place buy/sell order
  • limit_order_create2 - Advanced order with exchange rate
  • limit_order_cancel - Cancel existing order
  • convert - Convert HBD to HIVE (3.5 day delay)
  • collateralized_convert - Instant conversion with collateral
  • account_create - Create new account (paid)
  • account_create_with_delegation - Create with delegated HP
  • create_claimed_account - Create from claimed ticket
  • claim_account - Claim subsidized account creation
  • account_update - Update account authorities
  • account_update2 - Enhanced account update
  • account_witness_vote - Vote for a witness
  • account_witness_proxy - Set witness vote proxy
  • update_proposal_votes - Vote on DHF proposals
  • witness_update - Update witness settings
  • witness_set_properties - Set witness properties
  • delegate_vesting_shares - Delegate HP to another account
  • comment_options - Set post payout options and beneficiaries
  • set_withdraw_vesting_route - Route power down to another account
  • escrow_transfer - Three-party escrow transaction
  • recurrent_transfer - Set up recurring payments

Operation Type Reference

View the full type definitions in the source:
src/types.ts:409
export type Operation =
  | ['vote', VoteOperation]
  | ['comment', CommentOperation]
  | ['transfer', TransferOperation]
  | ['transfer_to_vesting', TransferToVestingOperation]
  | ['withdraw_vesting', WithdrawVestingOperation]
  // ... 40+ operation types
Each operation body type is defined with all required and optional fields:
src/types.ts:45
export interface VoteOperation {
  voter: string
  author: string
  permlink: string
  weight: number
}

Full Type Definitions

View all operation types in the source code

Using Assets

Many operations require Asset values. You can use:

String Format

Simplest approach - use properly formatted strings:
amount: '10.000 HIVE'   // Must have 3 decimals and symbol
amount: '5.123 HBD'
amount: '1000.000000 VESTS'  // VESTS use 6 decimals

Asset Class

For calculations and conversions:
import { Asset } from 'hive-tx'

const amount = new Asset(10, 'HIVE')
await tx.addOperation('transfer', {
  from: 'alice',
  to: 'bob',
  amount: amount,  // Automatically serialized
  memo: ''
})

Authority Requirements

Each operation requires specific key types:
Operation TypeRequired Authority
vote, comment, custom_json (posting)Posting key
transfer, account_updateActive key
account_create, witness_updateActive key
owner authority changesOwner key
Using the wrong key type will cause the transaction to fail validation. For example, you cannot transfer funds with a posting key.

Multiple Operations in One Transaction

You can batch multiple operations together:
const tx = new Transaction()

// Post content
await tx.addOperation('comment', { /* ... */ })

// Set beneficiaries
await tx.addOperation('comment_options', { /* ... */ })

// Vote on your own post
await tx.addOperation('vote', {
  voter: 'alice',
  author: 'alice',
  permlink: 'my-post',
  weight: 10000
})

// All execute together when broadcast
const key = PrivateKey.fromLogin('alice', 'password', 'posting')
tx.sign(key)
await tx.broadcast()
Batching operations saves bandwidth and ensures they execute atomically - either all succeed or all fail.

Next Steps

Transactions

Learn the full transaction lifecycle

Keys & Signatures

Understand authority and signing

Type Definitions

Browse all operation types

Build a Voting App

Practical operation examples

Build docs developers (and LLMs) love