Skip to content

Commit

Permalink
feat: add script to query gno balance
Browse files Browse the repository at this point in the history
Signed-off-by: Norman Meier <[email protected]>
  • Loading branch information
n0izn0iz committed Sep 26, 2023
1 parent b53a1dd commit 5da851e
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions packages/scripts/gnoBalance.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { GnoJSONRPCProvider } from "@gnolang/gno-js-client";
import { program } from "commander";

import { NetworkKind, parseUserId } from "../networks";

const main = async () => {
program.argument("user-id", "user id");
program.parse();
const [userId] = program.args as [string, string];

const [network, userAddress] = parseUserId(userId);
if (network?.kind !== NetworkKind.Gno) {
console.error("network not supported");
return;
}
const provider = new GnoJSONRPCProvider(network.endpoint);
try {
const rawRes = await provider.getBalance(userAddress);
console.log(rawRes);
} catch (e) {
console.error(JSON.stringify(e));
}
};

main();

0 comments on commit 5da851e

Please sign in to comment.