@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
Name | Type |
---|---|
version? | number |
instructions? | Instruction [] |
Returns
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
Name | Type |
---|---|
privKey | PrivKey |
to? | number |
Returns
Uint8Array
Defined in
packages/core/dist/tx.d.ts:44
isSignedBy
▸ isSignedBy(addr
, index
): boolean
Parameters
Name | Type |
---|---|
addr | Address |
index | number |
Returns
boolean
Defined in
packages/core/dist/tx.d.ts:45
push
▸ push(instruction
): Tx
Pushes an Instruction onto the transaction.
Parameters
Name | Type |
---|---|
instruction | Instruction |
Returns
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
Name | Type |
---|---|
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
Name | Type |
---|---|
bytes | Uint8Array |
Returns
Defined in
packages/core/dist/tx.d.ts:27
fromHex
▸ fromHex(str
): Tx
Returns a Transaction from the given hex-encoded string.
Parameters
Name | Type |
---|---|
str | string |
Returns
Defined in
packages/core/dist/tx.d.ts:31