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:
Initialize the Thor client:
Networks:
Mainnet:
https://mainnet.vechain.orgTestnet:
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 balanceenergy– Shows the VTHO balancehasCode– 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:
Here is a snippet that shows how you can make a request to the blockchain and receive data directly from the VTHO contract:
Reading B3TR token balances
B3TR is the incentive token of VeBetterDAO, deployed on the VeChainThor blockchain.
Contract Address:
0x5ef79995FE8a89e0812330E4378eB2660ceDe699Token Standard: ERC-20 compatible
You can read B3TR balances using the VeChain SDK's `balanceOf()` method:
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.
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
Join our Telegram