Skip to main content

Overview

The hive-tx library provides TypeScript type definitions for all Hive blockchain operations. These types ensure type safety when constructing transactions and operations.

Operation Type

The Operation type is a union of all available operation types, structured as tuples of [operationName, operationBody].
type Operation =
  | ['vote', VoteOperation]
  | ['comment', CommentOperation]
  | ['transfer', TransferOperation]
  // ... and 40+ more operation types

Helper Types

OperationName
string
Extract the operation name from the Operation union type.
type OperationName = Operation[0]
// 'vote' | 'comment' | 'transfer' | ...
OperationBody
generic
Extract the operation body type for a specific operation name.
type OperationBody<O extends OperationName> = Extract<Operation, [O, any]>[1]

// Example usage:
type TransferBody = OperationBody<'transfer'> // TransferOperation

Content Operations

VoteOperation

Upvote or downvote content on the blockchain.
voter
string
required
The account name casting the vote
author
string
required
The author of the content being voted on
The permlink of the content being voted on
weight
number
required
Vote weight from -10000 to 10000 (100% to -100%)

CommentOperation

Create a post or comment on the blockchain.
parent_author
string
required
Author of the parent post (empty string for top-level posts)
Permlink of the parent post (category for top-level posts)
author
string
required
Author of the comment or post
Unique permlink for the post or comment
title
string
required
Title of the post (empty for comments)
body
string
required
Content body in Markdown format
json_metadata
string
required
JSON string containing metadata (tags, app info, etc.)

DeleteCommentOperation

author
string
required
Author of the comment to delete
Permlink of the comment to delete

CommentOptionsOperation

author
string
required
Author of the comment
Permlink of the comment
max_accepted_payout
Asset | string
required
Maximum payout accepted (e.g., “1000.000 HBD”)
percent_hbd
number
required
Percentage of payout in HBD (0-10000)
allow_votes
boolean
required
Whether to allow votes on this content
allow_curation_rewards
boolean
required
Whether to allow curation rewards
extensions
Array<Array<Beneficiary>>
required
Array of beneficiaries for reward sharing

Transfer Operations

TransferOperation

Transfer HIVE or HBD between accounts.
from
string
required
Sender account name
to
string
required
Recipient account name
amount
Asset | string
required
Amount to transfer (e.g., “10.000 HIVE” or “5.000 HBD”)
memo
string
required
Transfer memo (can be encrypted or plain text)

RecurrentTransferOperation

from
string
required
Sender account name
to
string
required
Recipient account name
amount
Asset | string
required
Amount to transfer per execution
memo
string
required
Transfer memo
recurrence
number
required
Hours between executions
executions
number
required
Number of executions (2-730)
extensions
Array<{ type: number; value: { pair_id: number } }>
required
Extensions for pairing transfers

TransferToVestingOperation

from
string
required
Account sending HIVE
to
string
required
Account receiving VESTS (can be same as from)
amount
Asset | string
required
Amount of HIVE to power up

WithdrawVestingOperation

account
string
required
Account powering down
vesting_shares
Asset | string
required
Amount of VESTS to power down

DelegateVestingSharesOperation

delegator
string
required
Account delegating VESTS
delegatee
string
required
Account receiving delegation
vesting_shares
Asset | string
required
Amount of VESTS to delegate (0 to remove)

TransferToSavingsOperation

from
string
required
Account sending to savings
to
string
required
Account receiving in savings
amount
Asset | string
required
Amount to transfer to savings
memo
string
required
Transfer memo

TransferFromSavingsOperation

from
string
required
Account withdrawing from savings
request_id
number
required
Unique request ID
to
string
required
Destination account
amount
Asset | string
required
Amount to withdraw
memo
string
required
Withdrawal memo

CancelTransferFromSavingsOperation

from
string
required
Account canceling withdrawal
request_id
number
required
Request ID to cancel

Account Operations

AccountCreateOperation

fee
Asset | string
required
Account creation fee
creator
string
required
Account creating the new account
new_account_name
string
required
Name of the new account
owner
Authority
required
Owner authority
active
Authority
required
Active authority
posting
Authority
required
Posting authority
memo_key
string | PublicKey
required
Memo public key
json_metadata
string
required
Account metadata

AccountCreateWithDelegationOperation

Extends AccountCreateOperation with delegation.
delegation
Asset | string
required
Amount of VESTS to delegate
extensions
[]
required
Extensions array

ClaimAccountOperation

creator
string
required
Account claiming the account creation token
fee
Asset | string
required
Fee (can be 0 HIVE if using RC)
extensions
[]
required
Extensions array

CreateClaimedAccountOperation

creator
string
required
Account using the claimed token
new_account_name
string
required
Name of the new account
owner
Authority
required
Owner authority
active
Authority
required
Active authority
posting
Authority
required
Posting authority
memo_key
string | PublicKey
required
Memo public key
json_metadata
string
required
Account metadata
extensions
[]
required
Extensions array

AccountUpdateOperation

account
string
required
Account to update
owner
Authority
New owner authority (optional)
active
Authority
New active authority (optional)
posting
Authority
New posting authority (optional)
memo_key
string | PublicKey
required
New memo key
json_metadata
string
required
Updated metadata

AccountUpdate2Operation

account
string
required
Account to update
owner
Authority
New owner authority (optional)
active
Authority
New active authority (optional)
posting
Authority
New posting authority (optional)
memo_key
string | PublicKey
New memo key (optional)
json_metadata
string
required
Updated metadata
posting_json_metadata
string
required
Updated posting metadata
extensions
[]
required
Extensions array

Witness Operations

AccountWitnessVoteOperation

account
string
required
Account voting for witness
witness
string
required
Witness account name
approve
boolean
required
true to vote, false to unvote

AccountWitnessProxyOperation

account
string
required
Account setting proxy
proxy
string
required
Proxy account (empty to clear)

WitnessUpdateOperation

owner
string
required
Witness account name
url
string
required
Witness announcement URL
block_signing_key
string | PublicKey
required
Block signing public key
props
ChainProperties
required
Proposed chain properties
fee
Asset | string
required
Operation fee

WitnessSetPropertiesOperation

owner
string
required
Witness account name
props
Array<[string, string]>
required
Array of property key-value pairs
extensions
[]
required
Extensions array

Conversion Operations

ConvertOperation

owner
string
required
Account initiating conversion
requestid
number
required
Unique request ID
amount
Asset | string
required
Amount to convert (HBD to HIVE)

CollateralizedConvertOperation

owner
string
required
Account initiating conversion
requestid
number
required
Unique request ID
amount
Asset | string
required
Amount to convert (HIVE to HBD)

Market Operations

LimitOrderCreateOperation

owner
string
required
Account creating the order
orderid
number
required
Unique order ID for this account
amount_to_sell
Asset | string
required
Amount being sold
min_to_receive
Asset | string
required
Minimum amount to receive
fill_or_kill
boolean
required
Fill completely or cancel
expiration
string | Date
required
Order expiration time

LimitOrderCreate2Operation

owner
string
required
Account creating the order
orderid
number
required
Unique order ID
amount_to_sell
Asset | string
required
Amount being sold
fill_or_kill
boolean
required
Fill completely or cancel
exchange_rate
Price
required
Exchange rate as Price object
expiration
string | Date
required
Order expiration time

LimitOrderCancelOperation

owner
string
required
Account canceling the order
orderid
number
required
Order ID to cancel

FeedPublishOperation

publisher
string
required
Witness publishing the price feed
exchange_rate
Price
required
HBD/HIVE exchange rate

Reward Operations

ClaimRewardBalanceOperation

account
string
required
Account claiming rewards
reward_hive
Asset | string
required
Amount of HIVE to claim
reward_hbd
Asset | string
required
Amount of HBD to claim
reward_vests
Asset | string
required
Amount of VESTS to claim

SetWithdrawVestingRouteOperation

from_account
string
required
Account setting the route
to_account
string
required
Destination account
percent
number
required
Percentage to route (0-10000)
auto_vest
boolean
required
Auto power up the received amount

Proposal Operations

CreateProposalOperation

creator
string
required
Proposal creator
receiver
string
required
Funding receiver
start_date
string | Date
required
Funding start date
end_date
string | Date
required
Funding end date
daily_pay
Asset | string
required
Daily payment amount
subject
string
required
Proposal subject
Proposal permlink
extensions
[]
required
Extensions array

UpdateProposalOperation

proposal_id
number
required
Proposal ID to update
creator
string
required
Proposal creator
daily_pay
Asset | string
required
Updated daily payment
subject
string
required
Updated subject
Updated permlink
extensions
Array<Array<{ end_date: string | Date }>>
required
Extensions with optional end_date

UpdateProposalVotesOperation

voter
string
required
Account voting on proposals
proposal_ids
number[]
required
Array of proposal IDs
approve
boolean
required
true to approve, false to remove vote
extensions
[]
required
Extensions array

RemoveProposalOperation

proposal_owner
string
required
Proposal owner
proposal_ids
number[]
required
Array of proposal IDs to remove
extensions
[]
required
Extensions array

Custom Operations

CustomOperation

required_auths
string[]
required
Accounts whose active authority is required
id
number
required
Custom operation ID
data
Uint8Array | string
required
Operation data

CustomJsonOperation

required_auths
string[]
required
Accounts whose active authority is required
required_posting_auths
string[]
required
Accounts whose posting authority is required
id
string
required
Custom JSON identifier
json
string
required
JSON string payload

Account Recovery Operations

RecoverAccountOperation

account_to_recover
string
required
Account being recovered
new_owner_authority
Authority
required
New owner authority
recent_owner_authority
Authority
required
Recent owner authority for verification
extensions
[]
required
Extensions array

RequestAccountRecoveryOperation

recovery_account
string
required
Recovery account
account_to_recover
string
required
Account to recover
new_owner_authority
Authority
required
New owner authority
extensions
[]
required
Extensions array

ChangeRecoveryAccountOperation

account_to_recover
string
required
Account changing recovery account
new_recovery_account
string
required
New recovery account
extensions
[]
required
Extensions array

ResetAccountOperation

reset_account
string
required
Account performing the reset
account_to_reset
string
required
Account being reset
new_owner_authority
Authority
required
New owner authority

SetResetAccountOperation

account
string
required
Account setting reset account
current_reset_account
string
required
Current reset account
reset_account
string
required
New reset account

DeclineVotingRightsOperation

account
string
required
Account declining voting rights
decline
boolean
required
true to decline, false to re-enable

Escrow Operations

EscrowTransferOperation

from
string
required
Sender account
to
string
required
Recipient account
hbd_amount
Asset | string
required
HBD amount in escrow
hive_amount
Asset | string
required
HIVE amount in escrow
escrow_id
number
required
Unique escrow ID
agent
string
required
Escrow agent account
fee
Asset | string
required
Agent fee
json_meta
string
required
JSON metadata
ratification_deadline
string | Date
required
Deadline for ratification
escrow_expiration
string | Date
required
Escrow expiration time

EscrowDisputeOperation

from
string
required
Sender account
to
string
required
Recipient account
agent
string
required
Escrow agent
who
string
required
Account raising dispute
escrow_id
number
required
Escrow ID

EscrowReleaseOperation

from
string
required
Sender account
to
string
required
Recipient account
agent
string
required
Escrow agent
who
string
required
Account releasing funds
receiver
string
required
Account receiving funds
escrow_id
number
required
Escrow ID
hbd_amount
Asset | string
required
HBD amount to release
hive_amount
Asset | string
required
HIVE amount to release

EscrowApproveOperation

from
string
required
Sender account
to
string
required
Recipient account
agent
string
required
Escrow agent
who
string
required
Account approving
escrow_id
number
required
Escrow ID
approve
boolean
required
true to approve, false to reject

Type Safety Examples

Type-Safe Operation Construction

import { Operation, VoteOperation, TransferOperation } from 'hive-tx'

// TypeScript ensures correct operation structure
const voteOp: Operation = ['vote', {
  voter: 'alice',
  author: 'bob',
  permlink: 'test-post',
  weight: 10000
}]

const transferOp: Operation = ['transfer', {
  from: 'alice',
  to: 'bob',
  amount: '10.000 HIVE',
  memo: 'Payment for services'
}]

Using OperationBody Helper

import { OperationBody } from 'hive-tx'

// Extract specific operation body type
type VoteBody = OperationBody<'vote'>

function createVote(params: VoteBody) {
  return ['vote', params] as const
}

const vote = createVote({
  voter: 'alice',
  author: 'bob',
  permlink: 'post',
  weight: 10000
})

Type-Safe Transaction Building

import { Transaction } from 'hive-tx'
import type { Operation } from 'hive-tx'

const operations: Operation[] = [
  ['vote', { voter: 'alice', author: 'bob', permlink: 'post', weight: 10000 }],
  ['transfer', { from: 'alice', to: 'bob', amount: '1.000 HIVE', memo: '' }]
]

const tx = new Transaction()
tx.create(operations)

Build docs developers (and LLMs) love