This repository was archived by the owner on Sep 17, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +16
-19
lines changed Expand file tree Collapse file tree 1 file changed +16
-19
lines changed Original file line number Diff line number Diff line change 1
- import { createAlchemyWeb3 } from "@alch/alchemy-web3" ;
2
-
3
- //Replace with your Alchemy API Key:
4
- const apiKey = "demo" ;
5
-
6
- // Initialize an alchemy-web3 instance:
7
- const web3 = createAlchemyWeb3 (
8
- `https://eth-mainnet.alchemyapi.io/v2/${ apiKey } ` ,
9
- ) ;
10
-
11
- // Replace with the wallet address you want to query:
1
+ // Setup: npm install alchemy-sdk
2
+ import { Alchemy , Network } from "alchemy-sdk" ;
3
+
4
+ const config = {
5
+ apiKey : "<-- ALCHEMY APP API KEY -->" ,
6
+ network : Network . ETH_MAINNET ,
7
+ } ;
8
+ const alchemy = new Alchemy ( config ) ;
9
+
10
+ //Feel free to switch this wallet address with another address
12
11
const ownerAddress = "0x00000000219ab540356cbb839cbe05303d7705fa" ;
13
- /*
14
- Replace with the token contract address you want to query:
15
- The below address Corresponds to USDT
16
- */
12
+
13
+ //The below token contract address corresponds to USDT
17
14
const tokenContractAddresses = [ "0xdAC17F958D2ee523a2206206994597C13D831ec7" ] ;
18
15
19
- /*
20
- ** Fetching the token Balance with Alchemy's getTokenBalances API
21
- */
22
- const data = await web3 . alchemy . getTokenBalances ( ownerAddress , tokenContractAddresses ) ;
16
+ const data = await alchemy . core . getTokenBalances (
17
+ ownerAddress ,
18
+ tokenContractAddresses
19
+ ) ;
23
20
console . log ( "Response Object for getTokenBalances\n" , data )
24
21
25
22
/*
You can’t perform that action at this time.
0 commit comments