Transactions
Transaction utility functions are defined in @liskhq/lisk-transactions
.
The functionalities can be accessed through package @liskhq/lisk-transactions
, @liskhq/lisk-client
or lisk-sdk
.
Signing transactions
signTransaction
Signs a transaction with a given networkIdentifier and passphrase. This returns a transaction object with a signature.
signTransaction(
// schema defined in custom asset to be signed
assetSchema: Schema,
// transaction object in JavaScript object format
transactionObject: Record<string, unknown>,
networkIdentifier: Buffer,
passphrase: string,
): Record<string, unknown>;
signMultiSignatureTransaction
Signs a transaction with a given passphrase as a multi signature account. This method can be used for signing registerMultisignatureGroup by setting the includeSenderSignature to true.
signMultiSignatureTransaction(
// schema defined in the custom asset to be signed
assetSchema: Schema,
// transaction object in JavaScript object format
transactionObject: Record<string, unknown>,
networkIdentifier: Buffer,
passphrase: string,
// keys which correspond to the sender account of the transaction
keys: {
mandatoryKeys: Buffer[],
optionalKeys: Buffer[],
},
// By setting true, signature corresponds to the sender public key will also be included in the signatures
// This should be used for registerMultisignatureGroup transaction
includeSenderSignature = false,
): Record<string, unknown>
getBytes
Validates the transaction against the asset schema and returns transaction bytes.
getBytes (
// schema defined in custom asset
assetSchema: Schema,
// transaction object in JavaScript object format
transactionObject: Record<string, unknown>,
): Buffer;
getSigningBytes
Validates the transaction against the asset schema and returns transaction bytes for signing.
getSigningBytes (
// schema defined in custom asset to be signed
assetSchema: Schema,
// transaction object in JavaScript object format
transactionObject: Record<string, unknown>,
): Buffer;
Changing between formats
Validating transactions
validateTransaction
Statically validates the transaction object input using the schema.
validateTransaction(
// schema defined in custom asset to be signed
assetSchema: Schema,
// transaction object in JavaScript object format
transactionObject: Record<string, unknown>,
): LiskValidationError | Error | undefined;
Calculating the minimum fee for a transaction
computeMinFee
Returns the minimal fee for a transaction.
computeMinFee(
// schema defined in custom asset to be signed
assetSchema: Schema,
// transaction object in JavaScript object format
transactionObject: Record<string, unknown>,
options?: {
minFeePerByte: number,
baseFees: { moduleID: number, assetID: number, baseFee: number}[],
numberOfSignatures: number,
}
): bigint