LiteServers
Libs Integration
Tonpy (Python)
Pytoniq (Python)
Tonutils (Go)
Tonpy has LiteClient only in dev version (tonpy-dev) at the moment
Python
1from tonpy import *
2
3test = LiteClient(host="...", port=...,
4 pubkey_hex="...", timeout=5)
5
6test.get_masterchain_info_ext().last
Python
1import requests
2from pytoniq import LiteBalancer
3
4config = requests.get('LINK_FROM_BOT').json()
5provider = LiteBalancer.from_config(config=config, trust_level=2)
6
7await provider.start_up()
8result = await client.run_get_method(address='EQBvW8Z5huBkMJYdnfAEM5JqTNkuWX3diqYENkWsIL0XggGG', method='seqno', stack=[])
Go
1package main
2
3import (
4 "context"
5 "fmt"
6 "log"
7
8 "github.com/xssnick/tonutils-go/address"
9 "github.com/xssnick/tonutils-go/liteclient"
10 "github.com/xssnick/tonutils-go/ton"
11)
12
13func main() {
14 client := liteclient.NewConnectionPool()
15
16 // connect to mainnet lite server
17 err := client.AddConnection(context.Background(), "IP_FROM_BOT:PORT_FROM_BOT", "BASE64_KEY_FROM_BOT")
18 if err != nil {
19 log.Fatalln("connection err: ", err.Error())
20 return
21 }
22
23 // initialize ton api lite connection wrapper
24 api := ton.NewAPIClient(client)
25
26 // we need fresh block info to run get methods
27 b, err := api.CurrentMasterchainInfo(context.Background())
28 if err != nil {
29 log.Fatalln("get block err:", err.Error())
30 return
31 }
32
33 /*
34 We will run such method of contract
35 cell mult(int a, int b) method_id {
36 return begin_cell().store_uint(a * b, 64).end_cell();
37 }
38 */
39
40 res, err := api.WaitForBlock(b.SeqNo).RunGetMethod(context.Background(), b,
41 address.MustParseAddr("kQBL2_3lMiyywU17g-or8N7v9hDmPCpttzBPE2isF2GTziky"), "mult", 7, 7)
42 if err != nil {
43 log.Fatalln("run get method err:", err.Error())
44 return
45 }
46
47 val, err := res.MustCell(0).BeginParse().LoadUInt(64)
48 if err != nil {
49 println("ERR", err.Error())
50 return
51 }
52
53 fmt.Printf("parsed result: %d\n", val)
54}