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.
Prerequisites⚓︎
If you have not done so already, start with Setting Up a Development Environment.
Full Code⚓︎
Making SDK Calls⚓︎
The class is the main entry point to the Symbol SDK when working with the NEM blockchain. It provides most of the methods you will need, 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 NEM blockchain happens through a node, which exposes a REST interface for querying network state and submitting transactions.
This example connects to a testnet node and retrieves the current blockchain height from the /chain/height 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: testnet
Network launch date: 2015-03-29 00:06:25+00:00
Using node http://libertalia.nemtest.net:7890
Fetching chain height from /chain/height
Blockchain height: 625,079 blocks
Conclusion⚓︎
If you got the output shown above, you're all set! You have access to the Symbol SDK and successfully reached a NEM node.
That's all you need to start your NEM adventure.
Why not try creating an account next?