How to Read Accounts on VeChain

Learn how to read your account details on VeChainThor using VeChainSDK.

Here's what you'll be able to read from any VeChain account:

  • VET and VTHO balances – Track the native tokens

  • B3TR balances – Check VeBetter ecosystem holdings

  • Account aliases – Look up human-readable names

What Is an Account?

An account can be classified as either an externally owned account or a smart contract.

  • Externally owned accounts typically consist of private keys generated in wallets.

  • Smart contracts are deployed with specific program codes.

Examining an account's hasCode flag can show the difference between the two. If it's true, it indicates that a smart contract is deployed at that address. The bytecode for smart contracts can also be retrieved.

Setup

Install the VeChain SDK:

npm install @vechain/sdk-core 
npm install @vechain/sdk-network

Initialize the Thor client:

import { ThorClient } from '@vechain/sdk-network';

// Connect to mainnet
const thor = ThorClient.at("https://mainnet.vechain.org");

// For testnet, use:
// const thor = ThorClient.at("https://testnet.vechain.org");

Networks:

  • Mainnet: https://mainnet.vechain.org

  • Testnet: https://testnet.vechain.org

Reading VET and VTHO balances

VeChain's dual-token system uses:

  • VET - The value-transfer token

  • VTHO -The transaction/gas token

Both use 18 decimals.

When you look up an account these are the key attributes of it: 

  • balance – Shows the VET balance

  • energy – Shows the VTHO balance

  • hasCode – Indicates a smart contract at the address.

The balance is stored as a hex-encoded BigInt, which can be converted into a human-readable format using BigInt(balance)

Here's an example snippet for accessing account details for the VTHO contract:

const contract = await thor.accounts.getAccount(
  '0x0000000000000000000000000000456e65726779'
);
const bytecode = await thor.accounts.getBytecode(
  '0x0000000000000000000000000000456e65726779'
);

Here is a snippet that shows how you can make a request to the blockchain and receive data directly from the VTHO contract:

import { ThorClient } from '@vechain/sdk-network';
const thor = ThorClient.at('https://testnet.vechain.org');

const account = await thor.accounts.getAccount(
  '0x01d6b50b31c18d7f81ede43935cadf79901b0ea0'
);

console.log(account);
console.log('VET Balance', BigInt(account.balance)/1000000000000000000n );
console.log('VTHO Balance', BigInt(account.energy)/1000000000000000000n );

Reading B3TR token balances

B3TR is the incentive token of VeBetterDAO, deployed on the VeChainThor blockchain. 

  • Contract Address: 0x5ef79995FE8a89e0812330E4378eB2660ceDe699

  • Token Standard: ERC-20 compatible

You can read B3TR balances using the VeChain SDK's `balanceOf()` method:

import { ThorClient } from "@vechain/sdk-network";
import { ABIFunction }  from "@vechain/sdk-core";
const thor = ThorClient.at("https://mainnet.vechain.org"); 
const wallet = "0xC06Ad8573022e2BE416CA89DA47E8c592971679A";
const B3TR = "0x5ef79995FE8a89e0812330E4378eB2660ceDe699";
const balanceOf = new ABIFunction({
  name: "balanceOf",
  type: "function",
  inputs: [{ name: "_owner", type: "address" }],
  outputs: [{ name: "balance", type: "uint256" }],
});
const b3trBalance = await thor.contracts.executeCall(B3TR, balanceOf, [wallet]);
console.log("B3TR", BigInt(b3trBalance.result.plain) / 1000000000000000000n);

You can also use the @vechain/vebetterdao-contracts library which provides a B3TR_factory import to achieve similar results..
Note: this library is newer and may have compatibility issues on some operating systems like Windows.

Reading account aliases

Aliases on VeChain allow developers or users to associate a human-readable identifier (like alice.vet) with a standard wallet address. 

This system simplifies identification and improves UX in applications by allowing developers to reference wallet addresses by alias instead of raw hexadecimal strings.

Aliases are:

  • On-chain: Stored and resolved via smart contracts

  • Unique: Each alias can only point to one address

  • Reversible: You can query in both directions:

    • From address → alias

    • From alias → address

Look up an alias from an address

Returns the alias (e.g., "alice.vet") registered to a given address.

import { ThorClient, vnsUtils } from "@vechain/sdk-network"; 

const thor = ThorClient.at("https://mainnet.vechain.org"); 
const address = "0xA830Ea6e24E3eF432fA13b70a4d816D099A8d6F4"; const alias = await vnsUtils.lookupAddress(thor, address); console.log(alias); 
// Result: bigwillysimon.vet

Reverse lookup: Get address from alias

Returns the wallet address associated with a given alias

Alias format:

  • Usually ends with .vet (e.g., alice.vet)

  • Must be unique network-wide

  • Not all addresses have aliases