Icon HelpCircleForumIcon Link

⌘K

Icon HelpCircleForumIcon Link
Nightly /
Transaction Policies

Icon LinkTransaction Policies

Transaction policies are rules that can govern how a transaction is processed, introduced by the transaction parameters that you pass to a transaction request. The available policies are as follows:

Icon LinkTip

Optional amount on the base asset to incentivise block producer to include transaction, ensuring faster processing for those willing to pay more. The value set here will be added to the transaction maxFee.

Icon LinkWitness Limit

The maximum byte length allowed for the transaction witnesses array.

Icon LinkMaturity

The number of blocks that must pass before the transaction can be included in a block.

Icon LinkMax Fee

The maximum amount you're willing to pay for the transaction using the base asset.

Icon LinkSetting Transaction Policies

The following snippet shows which transaction parameters correspond to which policies:

// #import { ScriptTransactionRequest };
 
const transactionRequest = new ScriptTransactionRequest({
  tip: bn(10), // Sets the tip policy
  witnessLimit: bn(1), // Sets the witness limit policy
  maturity: 1, // Sets the maturity policy
  maxFee: bn(1), // Sets the max fee policy
});

Icon LinkRetrieving Transaction Policies from a Transaction

Policies used for a transaction can be retrieved from a transaction using a TransactionResponse. The below snippet will show how to retrieve the policies from a transaction:

// #import { ScriptTransactionRequest, TransactionResponse, Policy };
 
// Instantiate the transaction request with transaction parameters that would
// set the respective policies.
const transactionRequest = new ScriptTransactionRequest({
  script: SumScript.bytecode,
  gasLimit: bn(2000),
  maturity: 2,
  tip: bn(3),
  witnessLimit: 900,
  maxFee: bn(60_000),
});
 
// Set the script main function arguments
transactionRequest.setData(SumScript.abi, scriptMainFunctionArguments);
 
// Fund the transaction
transactionRequest.addResources(resources);
 
// Submit the transaction and retrieve the transaction response
const tx: TransactionResponse = await wallet.sendTransaction(transactionRequest);
const response = await tx.waitForResult();
// is undefined if the transaction had no policies applied.
const policies: Policy[] | undefined = response.transaction.policies;