Authority
Represents permission authority on the Hive blockchain. Each account has three authority types: owner, active, and posting.
Minimum combined weight required to authorize an action. Typically set to 1 for single-signature accounts.
Array of account authorizations. Each entry is a tuple of [accountName, weight]. Allows other accounts to authorize actions.
key_auths
Array<[string | PublicKey, number]>
Array of key authorizations. Each entry is a tuple of [publicKey, weight]. These keys can sign transactions for this authority.
Authority Structure Example
import { Authority } from 'hive-tx'
import { PublicKey } from 'hive-tx/helpers'
// Single-key authority (most common)
const singleKeyAuth: Authority = {
weight_threshold: 1,
account_auths: [],
key_auths: [[
'STM5jZtxvFXL...', // public key
1 // weight
]]
}
// Multi-signature authority (2-of-3)
const multiSigAuth: Authority = {
weight_threshold: 2,
account_auths: [],
key_auths: [
['STM5jZtxvFXL...', 1],
['STM6kYxuGHM...', 1],
['STM7mNopQRS...', 1]
]
}
// Account authority (allows another account to authorize)
const accountAuth: Authority = {
weight_threshold: 1,
account_auths: [
['recovery_account', 1]
],
key_auths: [
['STM5jZtxvFXL...', 1]
]
}
Multi-Signature Examples
// 2-of-2 multi-sig (both keys required)
const twoOfTwo: Authority = {
weight_threshold: 2,
account_auths: [],
key_auths: [
['STM5key1...', 1],
['STM6key2...', 1]
]
}
// 2-of-3 multi-sig (any 2 keys required)
const twoOfThree: Authority = {
weight_threshold: 2,
account_auths: [],
key_auths: [
['STM5key1...', 1],
['STM6key2...', 1],
['STM7key3...', 1]
]
}
// Weighted multi-sig (key1 OR key2+key3)
const weighted: Authority = {
weight_threshold: 3,
account_auths: [],
key_auths: [
['STM5masterKey...', 3], // Master key has full weight
['STM6backupKey1...', 2], // Backup keys need to combine
['STM7backupKey2...', 1]
]
}
Using in Account Creation
import { Transaction } from 'hive-tx'
import { PrivateKey, PublicKey } from 'hive-tx/helpers'
// Generate keys for new account
const ownerKey = PrivateKey.from('5J...')
const activeKey = PrivateKey.from('5K...')
const postingKey = PrivateKey.from('5L...')
const memoKey = PublicKey.from('STM5...')
const tx = new Transaction()
await tx.create([
['account_create', {
fee: '3.000 HIVE',
creator: 'alice',
new_account_name: 'newuser',
owner: {
weight_threshold: 1,
account_auths: [],
key_auths: [[ownerKey.createPublic().toString(), 1]]
},
active: {
weight_threshold: 1,
account_auths: [],
key_auths: [[activeKey.createPublic().toString(), 1]]
},
posting: {
weight_threshold: 1,
account_auths: [],
key_auths: [[postingKey.createPublic().toString(), 1]]
},
memo_key: memoKey.toString(),
json_metadata: '{}'
}]
])
Beneficiary
Defines a reward beneficiary for post payouts.
Beneficiary account name that will receive a portion of post rewards
Percentage of rewards in basis points (0-10000, where 10000 = 100%)
Beneficiary Examples
import { Beneficiary } from 'hive-tx'
import { Transaction } from 'hive-tx'
// Single beneficiary (10% to charity)
const beneficiaries: Beneficiary[] = [
{ account: 'charity', weight: 1000 } // 10%
]
// Multiple beneficiaries
const multipleBeneficiaries: Beneficiary[] = [
{ account: 'curator', weight: 2500 }, // 25%
{ account: 'developer', weight: 1500 }, // 15%
{ account: 'charity', weight: 1000 } // 10%
// Author keeps remaining 50%
]
// Use in comment_options operation
const tx = new Transaction()
await tx.create([
['comment', {
parent_author: '',
parent_permlink: 'blog',
author: 'alice',
permlink: 'my-post',
title: 'My Post',
body: 'Post content...',
json_metadata: '{}'
}],
['comment_options', {
author: 'alice',
permlink: 'my-post',
max_accepted_payout: '10000.000 HBD',
percent_hbd: 10000,
allow_votes: true,
allow_curation_rewards: true,
extensions: [beneficiaries]
}]
])
Beneficiary Rules
- Total beneficiary weight cannot exceed 8000 (80%)
- Author must receive at least 20% of rewards
- Beneficiaries must be sorted alphabetically by account name
- Maximum of 8 beneficiaries per post
Price
Represents an exchange rate between two assets.
Base asset in the exchange rate (e.g., “1.000 HBD”)
Quote asset in the exchange rate (e.g., “3.000 HIVE”)
Price Examples
import { Price } from 'hive-tx'
import { Asset } from 'hive-tx/helpers'
// HBD price in terms of HIVE
// Interpretation: 1 HBD = 3 HIVE
const hbdPrice: Price = {
base: '1.000 HBD',
quote: '3.000 HIVE'
}
// Using Asset objects
const price: Price = {
base: Asset.from('1.000 HBD'),
quote: Asset.from('2.500 HIVE')
}
Using in Feed Publish
import { Transaction } from 'hive-tx'
import { PrivateKey } from 'hive-tx/helpers'
// Witness publishing price feed
const tx = new Transaction()
await tx.create([
['feed_publish', {
publisher: 'witness.account',
exchange_rate: {
base: '1.000 HBD',
quote: '3.250 HIVE'
}
}]
])
const activeKey = PrivateKey.from('5J...')
await tx.broadcast(activeKey)
Using in Limit Orders
import { Transaction } from 'hive-tx'
const tx = new Transaction()
// Create limit order using exchange_rate
await tx.create([
['limit_order_create2', {
owner: 'trader',
orderid: 12345,
amount_to_sell: '100.000 HIVE',
fill_or_kill: false,
exchange_rate: {
base: '1.000 HBD',
quote: '3.000 HIVE'
},
expiration: new Date(Date.now() + 86400000) // 24 hours
}]
])
ChainProperties
Defines blockchain consensus parameters proposed by witnesses.
Fee required to create a new account (e.g., “3.000 HIVE”)
Maximum block size in bytes
Annual interest rate for HBD in savings (in basis points, e.g., 1000 = 10%)
ChainProperties Example
import { ChainProperties } from 'hive-tx'
import { Transaction } from 'hive-tx'
import { PrivateKey, PublicKey } from 'hive-tx/helpers'
const proposedProps: ChainProperties = {
account_creation_fee: '3.000 HIVE',
maximum_block_size: 65536, // 64 KB
hbd_interest_rate: 1000 // 10% APR
}
// Witness proposes these properties
const tx = new Transaction()
await tx.create([
['witness_update', {
owner: 'witness.account',
url: 'https://witness.example.com',
block_signing_key: PublicKey.from('STM5...'),
props: proposedProps,
fee: '0.000 HIVE'
}]
])
const activeKey = PrivateKey.from('5J...')
await tx.broadcast(activeKey)
WitnessProps
Extended witness properties for witness_set_properties operation.
Proposed account creation fee
Account subsidy decay rate
Proposed maximum block size
new_signing_key
string | PublicKey | null
New block signing key (null to disable witness)
HBD exchange rate price feed
Proposed HBD interest rate
WitnessProps Example
import { Transaction } from 'hive-tx'
import { PrivateKey, PublicKey } from 'hive-tx/helpers'
const signingKey = PublicKey.from('STM5...')
const tx = new Transaction()
await tx.create([
['witness_set_properties', {
owner: 'witness.account',
props: [
['key', signingKey.toString()],
['account_creation_fee', '3.000 HIVE'],
['maximum_block_size', '65536'],
['hbd_interest_rate', '1000'],
['url', 'https://witness.example.com']
],
extensions: []
}]
])
const activeKey = PrivateKey.from('5J...')
await tx.broadcast(activeKey)
AssetSymbol
Valid asset symbols on the Hive blockchain.
type AssetSymbol = 'HIVE' | 'HBD' | 'VESTS' | 'STEEM' | 'SBD' | 'TESTS' | 'TBD'
Asset Symbol Usage
HIVE: Main blockchain token
HBD: Hive-Backed Dollar (stablecoin)
VESTS: Vesting shares (powered-up HIVE)
STEEM, SBD: Legacy symbols (pre-fork compatibility)
TESTS, TBD: Testnet tokens
Complete Authority Management Example
import { Transaction } from 'hive-tx'
import { PrivateKey, PublicKey } from 'hive-tx/helpers'
import type { Authority } from 'hive-tx'
// Update account to use multi-sig posting authority
async function setupMultiSigPosting() {
const ownerKey = PrivateKey.from('5J...') // Current owner key
// Create 2-of-3 posting authority
const newPostingAuth: Authority = {
weight_threshold: 2,
account_auths: [],
key_auths: [
['STM5primaryKey...', 1],
['STM6backupKey1...', 1],
['STM7backupKey2...', 1]
]
}
const tx = new Transaction()
await tx.create([
['account_update2', {
account: 'myaccount',
posting: newPostingAuth,
json_metadata: '',
posting_json_metadata: '',
extensions: []
}]
])
// Sign with owner key (required for authority changes)
const result = await tx.broadcast(ownerKey)
console.log('Multi-sig posting authority activated!')
console.log('Transaction ID:', result.tx_id)
}