Skip to content

TorumNetwork/Binance-Smart-Chain-Node-Setup-with-TypeScript

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 

Repository files navigation

πŸ›  Binance Smart Chain Node Setup with TypeScript Based on guide by QuickNode Original: How to Run a Binance Smart Chain Node Edited by me β€” for programmatic interaction and connection using TypeScript

βœ… Install dependencies bash Copy Edit yarn init --yes # or npm init --yes tsc --init --resolveJsonModule true

yarn add web3 dotenv axios

or

npm install web3 dotenv axios πŸ“‚ Project structure text Copy Edit bsc-node-connect/ β”œβ”€β”€ app.ts β”œβ”€β”€ .env β”œβ”€β”€ tsconfig.json └── README.md πŸ” .env example env Copy Edit BSC_NODE_URL=https://bsc-dataseed.binance.org/ # or your QuickNode/Ankr/etc endpoint ▢️ app.ts example ts Copy Edit import Web3 from "web3"; import dotenv from "dotenv";

dotenv.config();

const BSC_NODE_URL = process.env.BSC_NODE_URL || ""; const web3 = new Web3(BSC_NODE_URL);

(async () => { try { const latestBlock = await web3.eth.getBlock("latest"); console.log("Latest block:", latestBlock.number);

const gasPrice = await web3.eth.getGasPrice();
console.log("Current gas price:", web3.utils.fromWei(gasPrice, "gwei"), "Gwei");

// Add more logic here to interact with BSC smart contracts or nodes

} catch (error) { console.error("Error connecting to BSC node:", error); } })(); ▢️ Start project bash Copy Edit npx ts-node app.ts

About

Binance Smart Chain Node Setup with TypeScript

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published