How to deploy a TON Node in the cloud?
TON (The Open Network) is a decentralized ecosystem with the TON Blockchain as its core component. It is designed for scalable cross-chain interoperability and was initially developed by Telegram but is currently developed by the TON Foundation. TON Blockchain is the core protocol, connecting TON’s underlying infrastructure to form a complete ecosystem.
Key features of TON
- TON is made to be highly scalable. It can process millions of transactions per second because a sharding method divides the network into smaller, linked blockchains known as "shards." The network's capacity is significantly increased because each shard can handle transactions independently.
- TON is intended to work with other DApps and blockchains. Interacting with other blockchain networks is simple, enabling the smooth exchange of data and assets. This functionality is essential for building a decentralized, networked web where many blockchain networks may collaborate.
- The architecture of TON is designed to be fast. Instead of using the Proof of Work (PoW) technique employed by Bitcoin, TON uses a POS(Proof of stake) technique, which is faster, quicker, and more energy efficient. As a result, the TON network is perfect for daily usage in terms of payments, microtransactions, and many financial operations because, from TON, transactions are completed almost very quickly and faster in very little time.
- TON is not governed by a single person, group, or organization. Instead, it is managed by the community of creators and consumers. Because of its decentralization, TON is more resilient to possible intrusions and guarantees that the network will always be available to all users.
Use Cases of TON
- Financial transactions can be completed quickly and securely with TON. Its high throughput makes it perfect for online purchases and peer-to-peer transactions, guaranteeing speedy payment and transfer processing. Additionally, businesses can incorporate cryptocurrency into their payment systems by using TON.
- TON's scalability and security can benefit DeFi applications, including lending services and decentralized exchanges. It is appropriate for sophisticated financial services because it can manage numerous transactions.
- TON's architecture supports the development of decentralized platforms for content distribution. These platforms can guarantee the speedy and secure delivery of material by providing features like file sharing and video streaming.
- The gaming industry can use TON's quick transactions and innovative contract features to develop decentralized games and in-game economies, creating new opportunities for players and producers.
- Telegram's connection with TON enables the creation of decentralized chat and social media apps. Using a variety of integrated mini-apps and associated services, users can benefit from increased security.
Prerequisites
- Instance Type: Choose an instance type with a good CPU, memory, and storage balance. A TON Node requires a minimum of 8 vCPUs and 32GB of RAM. You can start with a more minor instance for a simple RPC node.
- Operating System: Use a Linux-based OS like Ubuntu 22.04.
- Storage: At least 200GB of SSD storage is recommended, preferably more, depending on your use case.
Step-by-step process to deploy a TON node in the cloud
For the purpose of this tutorial, we will use a CPU-powered Virtual Machine offered by NodeShift; however, you can replicate the same steps with any other cloud provider of your choice. NodeShift provides the most affordable Virtual Machines at a scale that meets GDPR, SOC2, and ISO27001 requirements.
Step 1: Sign Up and Set Up a NodeShift Cloud Account
- Visit the NodeShift Platform and create an account.
- Once you've signed up, log into your account.
- Follow the account setup process and provide the necessary details and information.
Step 2: Create a Compute Node (CPU Virtual Machine)
NodeShift Compute Nodes offers flexible and scalable on-demand resources like NodeShift Virtual Machines (VMs), which are easily deployed and come with general-purpose, CPU-powered, or storage-optimized nodes.
- Navigate to the menu on the left side.
- Select the "Compute Nodes" option.
- Click the "Create Compute Nodes" button in the Dashboard to make your first deployment.
Step 3: Select a Region and Choose VM Configuration
- In the "Compute Nodes" tab, select a geographical region where you want to launch the Virtual Machine (e.g., the United States).
- In the "Choose VM Configuration" section, select the number of cores, amount of memory, boot disk type, and size that best suits your needs.
- You will need at least 200 GB of storage for the node to run smoothly. If you use NodeShift and need more resources, you can always resize to add more CPUs and RAM.
Step 4: Choose an Image
Next, you will need to choose an image for your Virtual Machine. We will deploy the VM on Ubuntu, but you can choose according to your preference. Other options like CentOS and Debian are also available to deploy your TON Node.
Step 5: Choose the Billing Cycle & Authentication Method
- Select the billing cycle that best suits your needs. Two options are available: Hourly, ideal for short-term usage and pay-as-you-go flexibility, or Monthly, perfect for long-term projects with a consistent usage rate and potentially lower overall cost.
- Select the authentication method. There are two options: Password and SSH Key. SSH keys are a more secure option. To create them, refer to our official documentation.
Step 6: Additional Details & Complete Deployment
- The ‘Finalize Details' section allows users to configure the final aspects of the Virtual Machine.
- After finalizing the details, click the 'Create' button, and your Virtual Machine will be deployed.
Step 7: Virtual Machine Successfully Deployed
You will get visual confirmation that your node is up and running.
Step 8: Connect via SSH
- Open your terminal
- Run the SSH command:
For example, if your username is root
, the command would be:
ssh root@84.32.34.39
- If SSH keys are set up, the terminal will authenticate using them automatically.
- If prompted for a password, enter the password associated with the username on the VM.
- You should now be connected to your VM!
Step 9: Install Required Software and Essential tools
After SSH into your VM, run the following commands to update the package manager and install the required dependencies:
sudo apt update
After executing the update command, execute the following command to install essential tools:
sudo apt install git curl wget
The command sudo apt install git curl wget
is used to install three essential tools on a Debian-based Linux distribution, such as Ubuntu. Here’s what each component means:
Breakdown of the Command
sudo
: sudo is an abbreviation of "super user do" and is a Linux command that allows programs to be executed as a super user (aka root user) or another user. It's basically the Linux/Mac equivalent of the runas command in Windows.apt
: apt-get is a command-line tool that helps handle packages in Linux. Its main task is to retrieve the information and packages from the authenticated sources for installation, upgrade, and removal of packages along with their dependencies.install
: This command within APT specifies you want to install the listed packages.git
: Git is a set of command line utility programs that are designed to execute on a Unix style command-line environment. Modern operating systems like Linux and macOS both include built-in Unix command line terminals. This makes Linux and macOS complementary operating systems when working with Git.It is widely used in software development.curl
: Curl (short for "Client URL") is a command line tool that enables data transfer over various network protocols. It communicates with a web or application server by specifying a relevant URL and the data that need to be sent or received.wget
: Wget is non-interactive, meaning it can work in the background while the user is not logged on. This lets you start a retrieval and disconnect from the system, allowing you to finish the work. By contrast, most Web browsers require constant user presence, which can significantly hinder data transfer.
Purpose of the Command
By running this command, you install Git, Curl, and Wget, essential tools for software development and network operations. This setup is handy for developers who manage code repositories (Git), download files from the internet (Curl and Wget), and perform various web development or system administration tasks.
Step 10: Install the Python and Pip package
Run the following command to update the package:
sudo apt update
Next, Run the following command to Install Python 3 and pip:
sudo apt install python3 python3-pip
Then, Run the following command to Check if Python 3 and pip are installed correctly:
python3 --version
pip3 --version
Step 11: Download and Install MyTonCtrl
Run the following command to download the installation script:
wget https://raw.githubusercontent.com/ton-blockchain/mytonctrl/master/scripts/install.sh
Next, Execute the following command to run the installation script:
sudo bash install.sh
When you reach the installation mode selection for your TON node, you make meaningful choices about how you want your node to function. Here’s a breakdown of what each prompt means and what you should consider:
Installation Mode
- Validator: Choose this if you want to participate in the network by validating transactions and earning rewards. This requires staking Toncoin.
- Liteserver: Select this if you want to provide services to Lite Clients without needing to validate transactions.
Network Selection
- Mainnet: This is the live network where real transactions occur. Choose this if you want your node to operate in the production environment.
- Testnet: Use this for testing purposes, where you can experiment without any financial risk.
- Other: This option is for custom networks, which is less common.
Validator Usage Mode
If you've selected Validator, you can choose from various modes:
- Validator wallet: If you plan to stake Toncoin directly and validate blocks.
- Nominator pool: If you want to delegate your stake to another validator.
- Single pool: If you're setting up a standalone validator pool.
- Liquid Staking: For a more flexible staking option that allows you to retain liquidity.
- Skip: You can skip this step and configure it later.
Download Blockchain Dump
- By selecting "y" (yes) to download the blockchain dump, you can download a large file containing the blockchain's current state. This will significantly reduce synchronization time when your node starts up, as it won’t have to download the entire history from scratch.
Recommended Actions
- Choose Validator or Liteserver based on your goals.
- Select Mainnet if you're ready for live operations or Testnet for testing.
- If you've chosen Validator, choose the usage mode that best suits your needs, or skip it for now.
- Confirm downloading the blockchain dump to expedite synchronization.
Once you've made these selections, proceed with the installation process as prompted.
Note: If you want to download the blockchain dump, so you have
- 16 CPUs
- 64 GB RAM
I am running only for testing purposes so my setup has only 8 CPUs and approximately 16 GB of RAM, which is sufficient for testing and I am not running blockchain dump.
Type N in the prompt if you don't want to download the blockchain dump.
After a successful installation, you will see the following message: Mytonctrl installation completed. This means your script is running successfully, and you have downloaded everything.
Step 12: Configure the Node
- After installation, configure the node by editing the configuration files as needed.
- You can set it up as a validator or in liteserver mode based on your requirements.
Step 13: Start the Node
Run the following command to start the node:
mytonctrl
Check the status to ensure it is running correctly:
mytonctrl status
Additional Considerations
- Synchronization Time: Initial synchronization may take several hours, depending on network throughput.
- Monitoring Logs: Keep an eye on logs for troubleshooting:
tail -f /var/log/mytonctrl.log
Using TON RPC Nodes (Optional)
If you prefer not to run your node, consider using services like Chainstack, which offers managed TON RPC nodes that can be deployed quickly without requiring extensive setup.
Conclusion
In this guide, we defined the TON(The Open Network) node requirements and provided step-by-step instructions on running a TON node. From installing the Required Software, Essential tools, Python, Pip package, and Install MyTonCtrl to creating a validator startup script.
For more information about NodeShift: