Hello World⚓︎
This tutorial shows how to verify that your Symbol SDK installation is working correctly by writing a minimal program that:
- Retrieves the network name and launch date using the SDK.
- Connects to a node and prints the current blockchain height.
No accounts, keys, or transactions are required, just a basic SDK call and a REST request.
Full Code⚓︎
Making SDK Calls⚓︎
The class is the main entry point to the Symbol SDK. It provides most of the methods you will need when working with Symbol: from building and signing transactions to retrieving network-related information.
To create a facade, simply specify the name of the network you want to work with, either mainnet
or testnet
.
This example then demonstrates how to retrieve the network launch date.
The method converts
a network timestamp into a UTC datetime.
By passing 0
(the genesis timestamp) you can obtain the moment the genesis block was produced, that is,
the network's launch date.
Retrieving Information From a Node⚓︎
Interaction with the Symbol blockchain happens through API nodes, which expose a REST interface for querying network state and submitting transactions. Not all nodes provide this interface, so it is important to connect to one labeled as API Node.
This example connects to an API node and retrieves the current blockchain height from the /chain/info
GET
endpoint.
This request does not require any private keys or authorization, making it a simple and effective test to confirm that the environment is set up correctly and can reach the network.
Output⚓︎
The output shown below corresponds to a typical run of the program.
Network name: mainnet
Network launch date: 2021-03-16 00:06:25+00:00
Using node https://001-sai-dual.symboltest.net:3001
Fetching chain information from /chain/info
Blockchain height: 2,367,414 blocks
Conclusion⚓︎
If you got the output shown above, you're all set! You have access to the Symbol SDK and successfully reached a Symbol API node.
That's all you need to start your Symbol adventure.
Why not try sending a transaction next?