Instructions inside the envelope? Clauses! 📬 VeChain bundles multiples for efficiency.
You weren't expecting to code manually each clause, right? Fortunatelly we have a Clause builder.
Encode clauses:
import { Clause, ABIFunction } from '@vechain/sdk-core';
const clauses = [
Clause.callFunction('0x8384738c...',
new ABIFunction({ name: 'increment', type: 'function' })),
];import { Clause, ABIFunction } from '@vechain/sdk-core';
const clauses = [
Clause.callFunction('0x8384738c...',
new ABIFunction({ name: 'increment', type: 'function' })),
];import { Clause, ABIFunction } from '@vechain/sdk-core';
const clauses = [
Clause.callFunction('0x8384738c...',
new ABIFunction({ name: 'increment', type: 'function' })),
];The other part you know, you estimate gas and get the transaction body:
const gasResult = await thor.transactions.estimateGas(clauses);
const txBody = await thor.transactions.buildTransactionBody(clauses, gasResult.totalGas);
const gasResult = await thor.transactions.estimateGas(clauses);
const txBody = await thor.transactions.buildTransactionBody(clauses, gasResult.totalGas);
const gasResult = await thor.transactions.estimateGas(clauses);
const txBody = await thor.transactions.buildTransactionBody(clauses, gasResult.totalGas);
Multi-power activated!
In the example we've used ABIFunction, which requires to know the properties of the contract function we wish to use. The alternative is to load the ABI:
import Abi from './abi.json' assert { type: 'json' };
const vtho = thor.contracts.load(
'0x8384738c...',
Abi
)
const clauses = [
vtho.clause.increment().clause,
]import Abi from './abi.json' assert { type: 'json' };
const vtho = thor.contracts.load(
'0x8384738c...',
Abi
)
const clauses = [
vtho.clause.increment().clause,
]import Abi from './abi.json' assert { type: 'json' };
const vtho = thor.contracts.load(
'0x8384738c...',
Abi
)
const clauses = [
vtho.clause.increment().clause,
]Signing seals it!