Skip to content

@aldea/sdk / Exports / TxBuilder

Class: TxBuilder ​

Transaction Builder

A simple API for building transactions.

Table of contents ​

Constructors ​

Properties ​

Accessors ​

Methods ​

Constructors ​

constructor ​

• new TxBuilder(aldea, opts?): TxBuilder

Parameters ​

NameType
aldeaAldea
optsTxBuilderOpts

Returns ​

TxBuilder

Defined in ​

packages/sdk/src/tx-builder.ts:91

Properties ​

_tx ​

• Private _tx: Tx

Defined in ​

packages/sdk/src/tx-builder.ts:89


afterHooks ​

• Private afterHooks: TxBuildHook[]

Defined in ​

packages/sdk/src/tx-builder.ts:86


aldea ​

• Private aldea: Aldea

Defined in ​

packages/sdk/src/tx-builder.ts:83


buildHooks ​

• Private buildHooks: TxBuildHook[]

Defined in ​

packages/sdk/src/tx-builder.ts:85


buildSteps ​

• Private buildSteps: [TxBuildStep, any[]][]

Defined in ​

packages/sdk/src/tx-builder.ts:84


isBuilding ​

• Private isBuilding: boolean = false

Defined in ​

packages/sdk/src/tx-builder.ts:88


results ​

• Private results: InstructionResult[]

Defined in ​

packages/sdk/src/tx-builder.ts:87

Accessors ​

tx ​

• get tx(): Tx

Returns the transaction being built. Can only be accessed during building.

Returns ​

Tx

Defined in ​

packages/sdk/src/tx-builder.ts:166

Methods ​

applyHooks ​

▸ applyHooks(hooks, instruction, idx): Promise<Instruction>

Parameters ​

NameType
hooksTxBuildHook[]
instructionInstruction | Promise<Instruction>
idxnumber

Returns ​

Promise<Instruction>

Defined in ​

packages/sdk/src/tx-builder.ts:284


build ​

▸ build(): Promise<Tx>

Builds the transaction. Executes the build steps and returns the Tx.

Returns ​

Promise<Tx>

Defined in ​

packages/sdk/src/tx-builder.ts:118


call ​

▸ call(ref, methodName, args?): InstructionRef

Pushes a CALL instruction onto the Transaction. Accepts an InstructionRef (which must refer to a JigResult), a method name and a list of args.

Parameters ​

NameTypeDefault value
refInstructionRefundefined
methodNamestringundefined
argsany[][]

Returns ​

InstructionRef

Defined in ​

packages/sdk/src/tx-builder.ts:207


deploy ​

▸ deploy(code): InstructionRef

Pushes a DEPLOY instruction onto the Transaction.

Parameters ​

NameType
codeMap<string, string>

Returns ​

InstructionRef

Defined in ​

packages/sdk/src/tx-builder.ts:239

▸ deploy(entry, code): InstructionRef

Parameters ​

NameType
entrystring | string[]
codeMap<string, string>

Returns ​

InstructionRef

Defined in ​

packages/sdk/src/tx-builder.ts:240


exec ​

▸ exec(ref, functionName, args?): InstructionRef

Pushes an EXEC instruction onto the Transaction. Accepts an InstructionRef (which must refer to a PkgResult), a function name and a list of args.

Parameters ​

NameTypeDefault value
refInstructionRefundefined
functionNamestringundefined
argsany[][]

Returns ​

InstructionRef

Defined in ​

packages/sdk/src/tx-builder.ts:215


fund ​

▸ fund(ref): InstructionRef

Pushes a FUND instruction onto the Transaction. Accepts an InstructionRef (which must refer to a JigResult).

Parameters ​

NameType
refInstructionRef

Returns ​

InstructionRef

Defined in ​

packages/sdk/src/tx-builder.ts:223


getResult ​

▸ getResult(ref, type): InstructionResult

Gets an InstructionResult from the stack of results.

Parameters ​

NameType
refInstructionRef
typeResultType

Returns ​

InstructionResult

Defined in ​

packages/sdk/src/tx-builder.ts:151


import ​

▸ import(pkgId): InstructionRef

Pushes an IMPORT instruction onto the Transaction.

Parameters ​

NameType
pkgIdstring | Uint8Array

Returns ​

InstructionRef

Defined in ​

packages/sdk/src/tx-builder.ts:174


load ​

▸ load(outputId): InstructionRef

Pushes a LOAD instruction onto the Transaction.

Parameters ​

NameType
outputIdstring | Uint8Array

Returns ​

InstructionRef

Defined in ​

packages/sdk/src/tx-builder.ts:182


loadByOrigin ​

▸ loadByOrigin(origin): InstructionRef

Pushes a LOADBYORIGIN instruction onto the Transaction.

Parameters ​

NameType
originstring | Pointer

Returns ​

InstructionRef

Defined in ​

packages/sdk/src/tx-builder.ts:190


lock ​

▸ lock(ref, address): InstructionRef

Pushes a LOCK instruction onto the Transaction. Accepts an InstructionRef (which must refer to a JigResult), and an address instance of string.

Parameters ​

NameType
refInstructionRef
addressstring | Address

Returns ​

InstructionRef

Defined in ​

packages/sdk/src/tx-builder.ts:231


new ​

▸ new(ref, className, args?): InstructionRef

Pushes a NEW instruction onto the Transaction. Accepts an InstructionRef (which must refer to a PkgResult), a class name and a list of args.

Parameters ​

NameTypeDefault value
refInstructionRefundefined
classNamestringundefined
argsany[][]

Returns ​

InstructionRef

Defined in ​

packages/sdk/src/tx-builder.ts:199


push ​

▸ push(instruction, ...args): InstructionRef

Pushes a build step onto the stack of steps. The build step must return an instruction.

Parameters ​

NameType
instructionInstruction | TxBuildStep
...argsany[]

Returns ​

InstructionRef

Defined in ​

packages/sdk/src/tx-builder.ts:276


refuteBuilding ​

▸ refuteBuilding(name?): void

Parameters ​

NameType
name?string

Returns ​

void

Defined in ​

packages/sdk/src/tx-builder.ts:392


refuteMutation ​

▸ refuteMutation(txid): void

Parameters ​

NameType
txidstring

Returns ​

void

Defined in ​

packages/sdk/src/tx-builder.ts:400


resultFromInstruction ​

▸ resultFromInstruction(instruction): Promise<InstructionResult>

Parameters ​

NameType
instructionInstruction

Returns ​

Promise<InstructionResult>

Defined in ​

packages/sdk/src/tx-builder.ts:299


resultFromReturnType ​

▸ resultFromReturnType(abi, rtype): Promise<InstructionResult>

Parameters ​

NameType
abiAbi
rtypenull | TypeNode

Returns ​

Promise<InstructionResult>

Defined in ​

packages/sdk/src/tx-builder.ts:357


sign ​

▸ sign(privKey): InstructionRef

Pushes a SIGN instruction onto the Transaction. The given PrivKey is used to create the signature used in the instruction.

Parameters ​

NameType
privKeyPrivKey | HDPrivKey

Returns ​

InstructionRef

Defined in ​

packages/sdk/src/tx-builder.ts:260


signTo ​

▸ signTo(privKey): InstructionRef

Pushes a SIGNTO instruction onto the Transaction. The given PrivKey is used to create the signature used in the instruction.

Parameters ​

NameType
privKeyPrivKey | HDPrivKey

Returns ​

InstructionRef

Defined in ​

packages/sdk/src/tx-builder.ts:268