Developer Fundamentals

3. Humans vs. Machines

Identify account types and retrieve balances for the VET/VTHO dual-token system.

Prerequisites

The Identity Check (Accounts)

Who lives on the blockchain? There are two types of accounts:

  1. Externally Owned Accounts (EOA): People with private keys in wallets.

  2. Smart Contracts: Program code deployed to an address.

"Think of it like an ID card..." You can tell them apart by checking the hasCode flag! If it's true, it's a smart contract.

VeChain uses a Dual-token system to keep costs predictable.

  • VET (Balance): The value-transfer token.

  • VTHO (Energy): The gas token used to pay for transactions.

In JavaScript, this means...

we need to handle some big numbers! Balances are stored as hex-encoded BigInts with 18 decimal places.

const account = await thor.accounts.getAccount('0x...');
// Convert VET to a human-readable number
const vetBalance = BigInt(account.balance) / 10n**18n;
const account = await thor.accounts.getAccount('0x...');
// Convert VET to a human-readable number
const vetBalance = BigInt(account.balance) / 10n**18n;
const account = await thor.accounts.getAccount('0x...');
// Convert VET to a human-readable number
const vetBalance = BigInt(account.balance) / 10n**18n;

Nice! You divided by 10 to the power of 18 to move that decimal point to the right place.