>

>

1. The Ingredients: Clauses and VTHO

Clauses and Gas ⛽

The Ingredients: Clauses and VTHO

Hey there! Ready to write your first piece of history on the blockchain? Let's go! 🌟

On VeChain, every change starts with a transaction. Think of a transaction like an envelope containing one or more letters—we call these letters clauses.

A single transaction can carry multiple clauses! This means you can send VET to three different friends in one go. Efficient, right?

First, we encode our intent. If we want to interact with a contract, we use the clauseBuilder to create our instruction.

const clauses = [
  clauseBuilder.functionInteraction(
    '0xYourContractAddress',
    'increment()'
  ),
];
const clauses = [
  clauseBuilder.functionInteraction(
    '0xYourContractAddress',
    'increment()'
  ),
];
const clauses = [
  clauseBuilder.functionInteraction(
    '0xYourContractAddress',
    'increment()'
  ),
];

Nice! But wait—every action needs fuel. On VeChainThor, that fuel is VTHO (gas).

Before we hit send, we must ask the network: 'How much VTHO will this cost?' We use thor.gas.estimateGas to find out.

const gasResult = await thor.gas.estimateGas(clauses);
console.log('VTHO needed:', gasResult.totalGas);
const gasResult = await thor.gas.estimateGas(clauses);
console.log('VTHO needed:', gasResult.totalGas);
const gasResult = await thor.gas.estimateGas(clauses);
console.log('VTHO needed:', gasResult.totalGas);

You’re getting it! Now we have our instructions and our fuel. Let's get ready to build!