Developer Fundamentals
-- III. Read Accounts
Learn how to identify different types of accounts, read VET and VTHO balances, and retrieve contract bytecode using the VeChain SDK.
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 distinguish 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.
Key Attributes of an Account
hasCode – Indicates a smart contract at the address.
balance – Represents the VET balance.
energy – Denotes the VTHO balance.
The balance is stored as a hex-encoded BigInt, which can be converted into a human-readable format using BigInt(balance).
It's important to note that numbers are stored with all their decimals, and for better readability, 18 decimal places should be considered.
Here's an example snippet for accessing account details for the VTHO contract:
Test It Yourself
The snippet below shows how you can make a request to the blockchain and receive data directly from the VTHO contract:
The same information is available using the JSON-API:
Join our Telegram