Skip to content

@aldea/sdk / Exports / Tx

Class: Tx

Aldea Transaction

A transaction is simply a list of instructions. When a transaction is processed, the instructions are executed in the order they appear in the transaction.

This class is primarily for working with the underlying data structure of a transaction. To build a transaction, use the TxBuilder class instaed.

Table of contents

Constructors

Properties

Accessors

Methods

Constructors

constructor

new Tx(version?, instructions?): Tx

Parameters

NameType
version?number
instructions?Instruction[]

Returns

Tx

Defined in

packages/core/dist/tx.d.ts:15

Properties

instructions

instructions: Instruction[]

Defined in

packages/core/dist/tx.d.ts:14


version

version: number

Defined in

packages/core/dist/tx.d.ts:13

Accessors

hash

get hash(): Uint8Array

Transaction hash

Returns

Uint8Array

Defined in

packages/core/dist/tx.d.ts:23


id

get id(): string

Transaction ID

Returns

string

Defined in

packages/core/dist/tx.d.ts:19

Methods

createSignature

createSignature(privKey, to?): Uint8Array

Returns a valid signature for the current tx using the given key.

Parameters

NameType
privKeyPrivKey
to?number

Returns

Uint8Array

Defined in

packages/core/dist/tx.d.ts:44


isSignedBy

isSignedBy(addr, index): boolean

Parameters

NameType
addrAddress
indexnumber

Returns

boolean

Defined in

packages/core/dist/tx.d.ts:45


push

push(instruction): Tx

Pushes an Instruction onto the transaction.

Parameters

NameType
instructionInstruction

Returns

Tx

Defined in

packages/core/dist/tx.d.ts:35


sighash

sighash(to?): Uint8Array

Returns the sighash of the current transaction. Can optionally be passed an index to return the sighash upto a given instruction.

Parameters

NameType
to?number

Returns

Uint8Array

Defined in

packages/core/dist/tx.d.ts:40


signers

signers(): PubKey[]

Returns

PubKey[]

Defined in

packages/core/dist/tx.d.ts:54


toBytes

toBytes(): Uint8Array

Returns the Transaction as bytes.

Returns

Uint8Array

Defined in

packages/core/dist/tx.d.ts:49


toHex

toHex(): string

Returns the Transaction as hex-encoded string.

Returns

string

Defined in

packages/core/dist/tx.d.ts:53


verify

verify(): boolean

Verifies any signatures in the transaction and returns a boolean.

Not that this only verifies the signatures. It does not otherwise verify the transaction is valid. That is done at execution time.

Returns

boolean

Defined in

packages/core/dist/tx.d.ts:61


fromBytes

fromBytes(bytes): Tx

Returns a Transaction from the given bytes.

Parameters

NameType
bytesUint8Array

Returns

Tx

Defined in

packages/core/dist/tx.d.ts:27


fromHex

fromHex(str): Tx

Returns a Transaction from the given hex-encoded string.

Parameters

NameType
strstring

Returns

Tx

Defined in

packages/core/dist/tx.d.ts:31