Skip to main content
The IWaxBaseInterface provides methods for offline blockchain operations including transaction creation, asset handling, key management, and cryptographic operations.

Properties

ASSETS

Readonly record of asset definitions for HIVE, HBD, and VESTS.
readonly ASSETS: Readonly<Record<EAssetName, NaiAsset>>;

formatter

Access to the WAX formatter for custom formatting operations.
readonly formatter: IWaxExtendableFormatter;

waxify

Shorthand access to the waxify template literal formatter.
readonly waxify: IWaxExtendableFormatter['waxify'];

chainId

The chain ID configured for this instance.
readonly chainId: THexString;

addressPrefix

The public key address prefix for this chain (e.g., “STM” for mainnet).
get addressPrefix(): string;

config

Protocol configuration for the current chain.
get config(): IChainConfig;

Transaction methods

createTransactionWithTaPoS

Constructs a new transaction object with TaPoS (Transaction as Proof of Stake) data.
createTransactionWithTaPoS(
  taposBlockId: TBlockHash,
  expirationTime?: TTimestamp
): ITransaction;
taposBlockId
TBlockHash
required
Reference block ID (can be head block ID) for TaPoS. This is a 20-byte string or hex string.
expirationTime
TTimestamp
Expiration time for the transaction. Can be:
  • Date object
  • Unix timestamp in milliseconds (number)
  • ISO 8601 date string
  • Relative time: "+10s", "+30m", "+1h"
Maximum expiration time on mainnet is 1 hour. Defaults to "+1m".
ITransaction
ITransaction
Transaction interface ready to receive operations

Usage example

const tx = wax.createTransactionWithTaPoS(
  "0000000000000000000000000000000000000000",
  "+30m"
);

tx.pushOperation({
  vote: {
    voter: "alice",
    author: "bob",
    permlink: "example-post",
    weight: 10000
  }
});

createTransactionFromProto

Constructs a transaction from a protobuf transaction object.
createTransactionFromProto(protoTransaction: transaction): ITransaction;

createTransactionFromJson

Converts a Hive API-form transaction (HF26 format) to a transaction object.
createTransactionFromJson(
  transactionData: string | object | ApiTransaction
): ITransaction;

createTransactionFromLegacyJson

Converts a legacy Hive API-form transaction to a transaction object.
createTransactionFromLegacyJson(
  transactionData: string | object | LegacyApiTransaction
): ITransaction;

convertTransactionToBinaryForm

Converts a transaction to HF26 binary form.
convertTransactionToBinaryForm(
  transaction: ApiTransaction,
  stripToUnsignedTransaction?: boolean
): THexString;

convertTransactionFromBinaryForm

Converts a transaction from HF26 binary form to Hive API-form JSON.
convertTransactionFromBinaryForm(transaction: THexString): ApiTransaction;

Asset methods

hiveCoins

Retrieves HIVE in NAI form with given amount (using decimal precision).
hiveCoins(amount: number): NaiAsset;
amount
number
required
Amount of HIVE as a decimal number. Accepts JS Double-precision floating-point format (IEEE 754), which does not support numbers greater than 2^53 - 1.

Usage example

const hive = wax.hiveCoins(100.5);
// Returns: { amount: "100500", precision: 3, nai: "@@000000021" }

hiveSatoshis

Retrieves HIVE in NAI form with given amount (using integer satoshis).
hiveSatoshis(amount: TNaiAssetConvertible): NaiAsset;
amount
TNaiAssetConvertible
required
Amount of HIVE in satoshis (integer). Can be number, string, or BigInt.

Usage example

const hive = wax.hiveSatoshis(100500);
// Returns: { amount: "100500", precision: 3, nai: "@@000000021" }

const largeAmount = wax.hiveSatoshis("10000000000000000");

hbdCoins

Retrieves HBD in NAI form with given amount (using decimal precision).
hbdCoins(amount: number): NaiAsset;

hbdSatoshis

Retrieves HBD in NAI form with given amount (using integer satoshis).
hbdSatoshis(amount: TNaiAssetConvertible): NaiAsset;

vestsCoins

Retrieves VESTS in NAI form with given amount (using decimal precision).
vestsCoins(amount: number): NaiAsset;

vestsSatoshis

Retrieves VESTS in NAI form with given amount (using integer satoshis).
vestsSatoshis(amount: TNaiAssetConvertible): NaiAsset;

getAsset

Retrieves asset amount and symbol from NAI data.
getAsset(nai: NaiAsset): IHiveAssetData;

Usage example

const nai = wax.hiveCoins(100);
const asset = wax.getAsset(nai);
// Returns: { amount: "100.000", symbol: "HIVE" }

Asset conversion methods

vestsToHp

Converts VESTS to Hive Power (HP).
vestsToHp(
  vests: TNaiAssetSource,
  totalVestingFundHive: TNaiAssetSource,
  totalVestingShares: TNaiAssetSource
): NaiAsset;

hpToVests

Converts Hive Power to VESTS.
hpToVests(
  hive: TNaiAssetSource,
  totalVestingFundHive: TNaiAssetSource,
  totalVestingShares: TNaiAssetSource
): NaiAsset;

hbdToHive

Converts HBD to HIVE using price feed.
hbdToHive(
  hbd: TNaiAssetSource,
  base: TNaiAssetSource,
  quote: TNaiAssetSource
): NaiAsset;

hiveToHbd

Converts HIVE to HBD using price feed.
hiveToHbd(
  amount: TNaiAssetSource,
  base: TNaiAssetSource,
  quote: TNaiAssetSource
): NaiAsset;

Calculation methods

calculateCurrentManabarValue

Calculates current manabar value for a Hive account.
calculateCurrentManabarValue(
  now: number,
  maxMana: TNaiAssetConvertible,
  currentMana: TNaiAssetConvertible,
  lastUpdateTime: number
): IManabarData;
IManabarData
IManabarData

calculateManabarFullRegenerationTime

Calculates full regeneration time for a manabar.
calculateManabarFullRegenerationTime(
  now: number,
  maxMana: TNaiAssetConvertible,
  currentMana: TNaiAssetConvertible,
  lastUpdateTime: number
): number;
number
number
Full regeneration timestamp in seconds

calculateAccountHp

Calculates account Hive Power.
calculateAccountHp(
  vests: TNaiAssetSource,
  totalVestingFundHive: TNaiAssetSource,
  totalVestingShares: TNaiAssetSource
): NaiAsset;

calculateWitnessVotesHp

Calculates witness votes in Hive Power.
calculateWitnessVotesHp(
  votes: TNaiAssetSource,
  totalVestingFundHive: TNaiAssetSource,
  totalVestingShares: TNaiAssetSource
): NaiAsset;

calculateHpApr

Calculates current HP APR.
calculateHpApr(
  headBlockNum: number,
  vestingRewardPercent: number,
  virtualSupply: TNaiAssetSource,
  totalVestingFundHive: TNaiAssetSource
): number;
number
number
HP APR percent with 2 decimals

estimateHbdInterest

Estimates HBD interest value.
estimateHbdInterest(
  accountHdbSeconds: TNaiAssetConvertible,
  hbdBalance: TNaiAssetSource,
  lastCompoundingDate: TTimestamp,
  now: TTimestamp,
  interestRate: number
): NaiAsset;

estimateHiveCollateral

Estimates HIVE collateral for HBD.
estimateHiveCollateral(
  currentMedianHistoryBase: TNaiAssetSource,
  currentMedianHistoryQuote: TNaiAssetSource,
  currentMinHistoryBase: TNaiAssetSource,
  currentMinHistoryQuote: TNaiAssetSource,
  hbdAmountToGet: TNaiAssetSource
): NaiAsset;

Cryptographic methods

suggestBrainKey

Generates a secure brain key with corresponding private and public keys.
suggestBrainKey(): IBrainKeyData;
IBrainKeyData
IBrainKeyData

getPrivateKeyFromPassword

Derives a private key for a given role from a master password.
getPrivateKeyFromPassword(
  account: string,
  role: string,
  password: string
): IPrivateKeyData;
account
string
required
Account name
role
string
required
Key role: “active”, “owner”, “posting”, or “memo”
password
string
required
Master password

calculatePublicKey

Calculates the public key from a private key.
calculatePublicKey(wifPrivateKey: string): TPublicKey;

convertRawPrivateKeyToWif

Converts a raw private key (32 bytes hex) to WIF format.
convertRawPrivateKeyToWif(rawPrivateKey: THexString): string;

convertRawPublicKeyToWif

Converts a raw public key (33 or 65 bytes hex) to WIF format.
convertRawPublicKeyToWif(rawPublicKey: THexString): string;

getPublicKeyFromSignature

Retrieves the public key used to create a signature.
getPublicKeyFromSignature(
  sigDigest: THexString,
  signature: THexString
): THexString;

Validation methods

isValidAccountName

Checks if an account name is valid.
isValidAccountName(name: string): boolean;
Account names must:
  • Comply with RFC 1035 grammar
  • Use only lowercase letters
  • Be between 3 and 16 characters (inclusive)

operationGetImpactedAccounts

Retrieves account names impacted by an operation.
operationGetImpactedAccounts(
  operation: operation | ApiOperation
): Set<TAccountName>;

operationBinaryViewMetadata

Retrieves binary view metadata for an operation.
operationBinaryViewMetadata(
  operation: operation | ApiOperation,
  isHf26Serialization?: boolean
): IBinaryViewOutputData;

Utility methods

extendConfig

Extends the current instance with custom options, creating a copy.
extendConfig(config: IWaxBaseExtendibleOptions): IWaxBaseInterface;

getVersion

Retrieves the bundled package version string.
getVersion(): string;

delete

Deletes the created WAX proto_protocol instance.
delete(): void;

TypeScript types

type TNaiAssetConvertible = number | string | bigint;
type TNaiAssetSource = TNaiAssetConvertible | NaiAsset;
type TTimestamp = Date | number | string;
type THexString = string;
type TPublicKey = string;
type TBlockHash = string;
type TTransactionId = string;

interface NaiAsset {
  amount: string;
  precision: number;
  nai: string;
}

interface IHiveAssetData {
  amount: string;
  symbol: string;
}

See also

Build docs developers (and LLMs) love