Transaction parameters allow you to configure various aspects of your blockchain transactions. Dependent on these parameters, it may introduce a transaction policy . The parameters are:
Note: Setting transaction parameters is optional. If you don't specify them, the SDK will fetch some sensible defaults from the chain.
All available parameters are shown below:
// #import { TxParams, bn };
const txParams: TxParams = {
gasLimit: bn(1), // BigNumberish or undefined
maturity: 1, // number or undefined
maxFee: bn(1), // BigNumberish or undefined
witnessLimit: bn(1), // BigNumberish or undefined
variableOutputs: 1, // number or undefined
};
To set the transaction parameters, you have access to the txParams
method on a transaction request.
// #import { ScriptTransactionRequest };
// Instantiate the transaction request using a ScriptTransactionRequest
// We can set txParams in the request constructor
const transactionRequest = new ScriptTransactionRequest({
script: scriptBytecode,
gasLimit: 100,
});
The same method is also accessible within a function invocation scope, so it can also be used when calling contract functions.
const { transactionResult } = await contract.functions
.increment_count(15)
.txParams({
variableOutputs: 1,
})
.call();
Note: When performing an action that results in a transaction (e.g. contract deployment, contract call with
.call()
, asset transfer), the SDK will automatically estimate the fee based on the gas limit and the transaction's byte size. This estimation is used when building the transaction. As a side effect, your wallet must own at least one coin of the base asset, regardless of the amount.