Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Readme

The ThorClient is responsible for communicating with the Vechain network, it is passed a HTTP Client that will handle the requests.

1
2
3
4
5
6
7
8
9
10
11
import { HttpClient, ThorClient } from "npm:@vechain/sdk-network";
const thorClient = new ThorClient(new HttpClient("https://mainnet.vechain.org"));
const bestBlock = await thorClient.blocks.getBestBlockCompressed();
console.log("Best Block:", bestBlock.number);
const finalBlock = await thorClient.blocks.getFinalBlockCompressed();
console.log("Final Block:", finalBlock.number);
const genesisBlock = await thorClient.blocks.getBlockCompressed(0);
console.log("Genesis Block Id:", genesisBlock.id);
ifavo-vechain_sdk_blocks_best_script.web.val.run
April 2, 2024