{"_id":"@eliseev_s/ton-lite-client","name":"@eliseev_s/ton-lite-client","dist-tags":{"latest":"3.0.0"},"versions":{"3.0.0":{"name":"@eliseev_s/ton-lite-client","version":"3.0.0","main":"dist/index.js","author":{"name":"Whales Corp.","email":"developers@whalescorp.com"},"license":"MIT","scripts":{"build":"rm -fr dist && tsc --declaration","release":"npm run build && npm publish --access public"},"devDependencies":{"@ton/core":"^0.56.3","@ton/crypto":"3.2.0","@types/node":"^17.0.45","@types/pegjs":"^0.10.6","buffer":"^6.0.3","jest":"^27.5.1","pegjs":"^0.10.0","ts-node":"^10.9.2","typescript":"^4.9.5"},"dependencies":{"adnl":"^1.0.3","dataloader":"^2.2.2","lru_map":"^0.4.1","teslabot":"^1.5.0","ton-tl":"^1.0.1","tweetnacl":"^1.0.3"},"peerDependencies":{"@ton/core":"^0.57.0"},"packageManager":"yarn@3.4.1","_id":"@eliseev_s/ton-lite-client@3.0.0","gitHead":"8e7089c35aaac7b7b75833c3b68a777d1d023c84","types":"./dist/index.d.ts","description":"ton-lite-client is a JS library that allows you to get information from TON Blockchain through it's native ADNL protocol.","_nodeVersion":"22.9.0","_npmVersion":"10.8.3","dist":{"integrity":"sha512-nPBLx3U5jgA+4Us752vfCuH8ze5wcr/d5rL/1jVy4epvTW5D1hPqqUWbJ1OaIrNE20pYFfDw5xSg3Fghy0LVNg==","shasum":"c198f7ec7084c29110ba1d9df0cbb125e14f4ff7","tarball":"https://registry.npmjs.org/@eliseev_s/ton-lite-client/-/ton-lite-client-3.0.0.tgz","fileCount":29,"unpackedSize":158095,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCRyTh4fzL0QocCkrBr56bE0lDTGwz2NN4Xylu6BROLZgIgcpY3e09L0G2tPi8K65+HmJzuKalxs8JBCQUAamv8n4s="}]},"_npmUser":{"name":"eliseev_s","email":"elis.alech900@gmail.com"},"directories":{},"maintainers":[{"name":"eliseev_s","email":"elis.alech900@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ton-lite-client_3.0.0_1727809294477_0.30013369192786254"},"_hasShrinkwrap":false}},"time":{"created":"2024-10-01T19:01:34.335Z","3.0.0":"2024-10-01T19:01:34.703Z","modified":"2024-10-01T19:01:35.018Z"},"maintainers":[{"name":"eliseev_s","email":"elis.alech900@gmail.com"}],"description":"ton-lite-client is a JS library that allows you to get information from TON Blockchain through it's native ADNL protocol.","author":{"name":"Whales Corp.","email":"developers@whalescorp.com"},"license":"MIT","readme":"## ton-lite-client\n\nton-lite-client is a JS library that allows you to get information from TON Blockchain through it's native ADNL protocol.\n\nTo get servers list, use official urls:\n- Mainnet: https://ton.org/global.config.json\n- Testnet: https://ton.org/testnet-global.config.json\n\nExample of getting account state:\n```typescript\nimport { LiteClient, LiteRoundRobinEngine, LiteSingleEngine, LiteEngine } from \"ton-lite-client\";\nimport { Address } from \"@ton/core\";\n\nfunction intToIP(int: number) {\n    var part1 = int & 255;\n    var part2 = ((int >> 8) & 255);\n    var part3 = ((int >> 16) & 255);\n    var part4 = ((int >> 24) & 255);\n\n    return part4 + \".\" + part3 + \".\" + part2 + \".\" + part1;\n}\n\nlet server = {\n    \"ip\": 1097649206,\n    \"port\": 29296,\n    \"id\": {\n        \"@type\": \"pub.ed25519\",\n        \"key\": \"p2tSiaeSqX978BxE5zLxuTQM06WVDErf5/15QToxMYA=\"\n    }\n}\n\nasync function main() {\n    const engines: LiteEngine[] = [];\n    engines.push(new LiteSingleEngine({\n        host: `tcp://${intToIP(server.ip)}:${server.port}`,\n        publicKey: Buffer.from(server.id.key, 'base64'),\n    }));\n    const engine: LiteEngine = new LiteRoundRobinEngine(engines);\n    const client = new LiteClient({ engine });\n    console.log('get master info')\n    const master = await client.getMasterchainInfo()\n    console.log('master', master)\n\n    const address = Address.parse('kQC2sf_Hy34aMM7n9f9_V-ThHDehjH71LWBETy_JrTirPIHa');\n    const accountState = await client.getAccountState(address, master.last)\n    console.log('Account state:', accountState)\n}\n\nmain()\n```\n\nBy default, LiteClient uses cache for 4 things: blocks, blockHeaders, shards, account states at given block. All caches are LRU maps with capacity of 1000 elements. If your use case needs different caching strategy - you can bring your own map.\n\n\nFor example, you can cap every map at 100 000 elements:\n```typescript\nconst client = new LiteClient({\n    engine,\n    cacheMap: 100000,\n});\n```\n\nOr you can cache only account states (not recommended, just example):\n```typescript\nconst client = new LiteClient({\n    engine, cacheMap: (kind) => {\n        if (kind === 'accounts') {\n            return new Map()\n        }\n\n        return {\n            get(key) { },\n            set(key, value) { },\n            delete(key: any) { },\n            clear() { },\n        }\n    }\n});\n```\n\n","readmeFilename":"README.md"}