Developer Fundamentals
Connect to the Network
Connect to VeChainThor using ThorClient and set up your Mainnet or Testnet environment.
Connecting to the VeChainThor Blockchain
Interacting with VeChainThor requires only an instance of ThorClient that is configured for the relevant network. Before continuing with this course, you must understand how to establish a connection with either the Mainnet or Testnet. Once the connection is established, this instance can be utilized to interact asynchronously. Below is a snippet that demonstrates importing the library and initializing a client:
The snippet connects to the Mainnet, where all production-related activity is found.
In addition to the Mainnet, VeChain provides a Testnet for testing and development purposes. This allows developers to experiment safely without risking real assets. To connect to the Testnet, use the following endpoint:
For additional Testnet setup instructions, visit the VeChain Testnet Portal. There, you can:
Access the API documentation for interacting with the Testnet
Obtain test VET for simulating transactions
Remember to set up your VeWorld Wallet to claim Testnet tokens
Explore available blockchain data for testing smart contracts
If you have deployed a solo node of VeChain, it is normally available on http://localhost:8669
The ThorClient uses an HttpClient underneath to communicate with the VeChain nodes with a REST API.
The default HttpClient is a Fetch implementation and can be replaced with any custom implementation as long as the interfaces are met.
Confirm Connection
To test the connectivity, you'll request the first and last block from the chain and output their number & id:
Test It Yourself
The snippet below shows how you can connect to the VeChain Mainnet to test connectivity:
Join our Telegram