Skip to content

Commit

Permalink
light client
Browse files Browse the repository at this point in the history
  • Loading branch information
fadeev committed Nov 5, 2024
1 parent 1795a6c commit b257688
Show file tree
Hide file tree
Showing 3 changed files with 343 additions and 4 deletions.
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,17 @@
},
"dependencies": {
"@inquirer/prompts": "^5.5.0",
"@ton/core": "^0.59.0",
"@ton/crypto": "^3.3.0",
"@uniswap/v2-core": "^1.0.1",
"@uniswap/v2-periphery": "^1.1.0-beta.0",
"@zetachain/protocol-contracts": "10.0.0-rc11",
"ansis": "^3.3.2",
"concurrently": "^8.2.2",
"dockerode": "^4.0.2",
"ethers": "^6.13.2",
"hardhat": "^2.22.8",
"ton-lite-client": "^3.0.0",
"wait-on": "^7.2.0"
}
}
37 changes: 37 additions & 0 deletions packages/localnet/src/tonLightClient.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import {
LiteClient,
LiteRoundRobinEngine,
LiteSingleEngine,
LiteEngine,
} from "ton-lite-client";
import { Address } from "@ton/core";

let server = {
id: {
"@type": "pub.ed25519",
key: "p2tSiaeSqX978BxE5zLxuTQM06WVDErf5/15QToxMYA=",
},
};

async function main() {
const engines: LiteEngine[] = [];
engines.push(
new LiteSingleEngine({
host: `http://0.0.0.0:8111`,
publicKey: Buffer.from(server.id.key, "base64"),
})
);
const engine: LiteEngine = new LiteRoundRobinEngine(engines);
const client = new LiteClient({ engine });
console.log("get master info");
const master = await client.getMasterchainInfo();
console.log("master", master);

const address = Address.parse(
"kQC2sf_Hy34aMM7n9f9_V-ThHDehjH71LWBETy_JrTirPIHa"
);
const accountState = await client.getAccountState(address, master.last);
console.log("Account state:", accountState);
}

main();
Loading

0 comments on commit b257688

Please sign in to comment.