Skip to main content

Running a Liteserver

To install and manage your own liteserver, use the mytonctrl open source tool developed by TON Foundation.

Hardware requirements

  • at least 8 cores CPU
  • at least 8 GB RAM
  • at least 512 GB NVMe SSD
  • 1 Gbit/s network connectivity
  • public IP address (fixed IP address)

Installation

mytonctrl installation

  1. Download the installation script.
wget https://raw.githubusercontent.com/ton-blockchain/mytonctrl/master/scripts/install.sh
  1. Run the installation script with the next flags:
  • -m full - Full node installation.
  • -d - mytonctrl will download a dump of the latest blockchain state. This will reduce liteserver synchronization time by several times.
  • -c <path> - If you want to use not public liteservers for synchronization.
sudo bash install.sh -m full -d
  1. After installation run mytonctrl CLI and check its status:
$ mytonctrl

MyTonCtrl> status

Wait until Local validator out of sync become less than 20 seconds.

Liteserver config

  1. Create config file
MyTonCtrl> installer
MyTonInstaller> clcf

Local config file created: /usr/bin/ton/local.config.json
  1. Copy the config file located on the specified path. You will need this file to connect to your liteserver.

Interaction with Liteserver

  1. Install libraries.
pip install pytonlib
  1. Initialize client and request masterchain info to make sure liteserver is running.
import asyncio
from pytonlib import TonlibClient
from pathlib import Path
import json


async def get_client() -> TonlibClient:
with open('config.json', 'r') as f:
config = json.loads(f.read())

keystore_dir = '/tmp/ton_keystore'
Path(keystore_dir).mkdir(parents=True, exist_ok=True)

client = TonlibClient(ls_index=0, config=config, keystore=keystore_dir, tonlib_timeout=10)
await client.init()

return client


async def test_client():
client = await get_client()

print(await client.get_masterchain_info())

await client.close()


if __name__ == '__main__':
asyncio.run(test_client())
  1. Now you can interact with your own liteserver.

See Also