Skip to content

Builder

@aeternity/aepp-sdk/es/tx/builder

JavaScript-based Transaction builder

Example

import Transaction from '@aeternity/aepp-sdk/es/tx/builder'

exports.calculateFee(fee, txType, options) ⇒ String | Number

Calculate fee

Kind: Exported function
rtype: (fee, txType, gas = 0) => String

Param Type Description
fee String | Number fee
txType String Transaction type
options Options Options object
options.gas String | Number Gas amount
options.params Object Tx params

Example

calculateFee(null, 'spendTx', { gas, params })

exports.validateParams(params, schema, excludeKeys) ⇒ Object

Validate transaction params

Kind: Exported function
Returns: Object - Object with validation errors

Param Type Description
params Object Object with tx params
schema Array Transaction schema
excludeKeys Array Array of keys to exclude for validation

exports.buildRawTx(params, schema, [options]) ⇒ Array

Build binary transaction

Kind: Exported function
Returns: Array - Array with binary fields of transaction
Throws:

  • Error Validation error
Param Type Default Description
params Object Object with tx params
schema Array Transaction schema
[options] Object {} options
[options.excludeKeys] Object excludeKeys Array of keys to exclude for validation and build

exports.unpackRawTx(binary, schema) ⇒ Object

Unpack binary transaction

Kind: Exported function
Returns: Object - Object with transaction field's

Param Type Description
binary Array Array with binary transaction field's
schema Array Transaction schema

exports.buildTx(params, type, [options]) ⇒ Object

Build transaction hash

Kind: Exported function
Returns: Object - { tx, rlpEncoded, binary } Object with tx -> Base64Check transaction hash with 'tx_' prefix, rlp encoded transaction and binary transaction
Throws:

  • Error Validation error
Param Type Default Description
params Object Object with tx params
type String Transaction type
[options] Object {} options
[options.excludeKeys] Object excludeKeys Array of keys to exclude for validation and build
[options.prefix] String Prefix of transaction

exports.unpackTx(encodedTx, fromRlpBinary, prefix) ⇒ Object

Unpack transaction hash

Kind: Exported function
Returns: Object - { tx, rlpEncoded, binary } Object with tx -> Object with transaction param's, rlp encoded transaction and binary transaction

Param Type Description
encodedTx String | Buffer String or RLP encoded transaction array (if fromRlpBinary flag is true)
fromRlpBinary Boolean Unpack from RLP encoded transaction (default: false)
prefix String Prefix of data

exports.buildTxHash(rawTx) ⇒ String

Build a transaction hash

Kind: Exported function
Returns: String - Transaction hash

Param Type Description
rawTx String | Buffer base64 or rlp encoded transaction