You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import { Connection, PublicKey, clusterApiUrl } from "@solana/web3.js";
const connection = new Connection(clusterApiUrl("devnet"));
const address = new PublicKey('CenYq6bDRB7p73EjsPEpiYN7uveyPUTdXkDkgUduboaN');
const balance = await connection.getBalance(address);
console.log(`The balance of the account at ${address} is ${balance} lamports`);
console.log(`✅ Finished!`)
It will result:
yarco@heaven scripts$ HTTPS_PROXY=http://127.0.0.1:7890 npx esrun key_001.ts
bigint: Failed to load bindings, pure JS will be used (try npm run rebuild?)
(node:55856) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
/Users/yarco/Documents/Workspace/Blockchain/solana/scripts/node_modules/.pnpm/@[email protected]/node_modules/@solana/web3.js/src/connection.ts:3245
throw new Error(
^
Error: failed to get balance of account CenYq6bDRB7p73EjsPEpiYN7uveyPUTdXkDkgUduboaN: TypeError: fetch failed
at e (/Users/yarco/Documents/Workspace/Blockchain/solana/scripts/node_modules/.pnpm/@[email protected]/node_modules/@solana/web3.js/src/connection.ts:3245:15)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at Connection.getBalance (/Users/yarco/Documents/Workspace/Blockchain/solana/scripts/node_modules/.pnpm/@[email protected]/node_modules/@solana/web3.js/src/connection.ts:3242:12)
at async file:///Users/yarco/Documents/Workspace/Blockchain/solana/scripts/[eval1]:13:15
Node.js v21.7.1
I'm pretty sure it is not networking problem, because the axios answer axios to another question in stackoverflow.com does work.
Check my running result:
So, maybe something wrong in web3.js? bigint: Failed to load bindings, pure JS will be used (try npm run rebuild?) ?
(I've also tried downgrade the node to v18, still the same error)
Problem
Hello, guys, I'm trying following the tutorial https://www.soldev.app/course/intro-to-reading-data.
But such code doesn't work
It will result:
There's also such question in solana.stackexchange.com , but got no answer.
I'm pretty sure it is not networking problem, because the axios answer axios to another question in stackoverflow.com does work.
Check my running result:
So, maybe something wrong in web3.js?
bigint: Failed to load bindings, pure JS will be used (try npm run rebuild?)
?(I've also tried downgrade the node to v18, still the same error)
Proposed Solution
For now only the axios version: https://stackoverflow.com/a/77715282/1960612
does work to me.
Mac m1 pro
Node: v21.7.1 (also tried v18)
pnpm: 8.15.5
@solana-developers/helpers 2.1.0
@solana/web3.js 1.91.1
axios 1.6.8
bigint-buffer 1.1.5
dotenv 16.4.5
esrun 3.2.26
typescript 5.4.2
The text was updated successfully, but these errors were encountered: