⌘K

Icon SunFilledIcon MoonStars
Preparing a Script

Icon LinkPreparing a Script Transaction

Akin to Contracts, we can configure the call parameters and transaction parameters for Scripts, as well as retrieve the entire transaction request or transaction ID prior to submission.

const script = new Script(binHexlified, abiContents, wallet);
const { minGasPrice } = provider.getGasConfig();
 
const tx = script.functions.main(argument);
 
// Set the call parameters
tx.callParams({ gasLimit: 100 });
 
// Set the transaction parameters
tx.txParams({ gasPrice: minGasPrice, gasLimit: 10_000 });
 
// Get the entire transaction request prior to
const txRequest = await tx.getTransactionRequest();
 
// Get the transaction ID
const txId = await tx.getTransactionId();
 
// Retrieve the value of the call and the actual gas used
const { value, gasUsed } = await tx.call();