Init

There are several ways to init LiteClient:

  1. From constructor

Provide to constructor Liteserver's ip (in string ipv4 format), port and base64-encoded public key, trust level and init_block if trust_level is zero. Also you can provide tl_schemas_path if you don't want to use ones from library files.

host = '65.21.141.231'
port = 17728

pub_key_b64 = 'BYSVpL7aPk0kU5CtlsIae/8mf2B/NrBi7DKmepcjX6Q='


async def main():

    init_block = BlockIdExt.from_dict({
      "root_hash": "61192b72664cbcb06f8da9f0282c8bdf0e2871e18fb457e0c7cca6d502822bfe",
      "seqno": 27747086,
      "file_hash": "378db1ccf9c98c3944de1c4f5ce6fea4dcd7a26811b695f9019ccc3e7200e35b",
      "workchain": -1,
      "shard": -9223372036854775808
    })

    client = LiteClient(
        host,
        port,
        pub_key_b64,
        trust_level=0,
        init_key_block=init_block
    )
    await client.connect()
  1. From config

Provide to LiteClient's from_config method config as dictionary, liteserver index you want to use and trust level (by default its 2).

Use one of from_mainnet_config and from_testnet_config methods. Specify liteserver index you want to use and trust level (by default its 0).

async def main():

    client = LiteClient.from_mainnet_config(7)

    await client.connect()

After initialization you need to call connect asynchronous method to initialize connection and sync blocks.

Last updated