generated from theodorusclarence/ts-nextjs-tailwind-starter
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
changed get token balance to use alchemy
- Loading branch information
1 parent
606ba5c
commit 8341593
Showing
5 changed files
with
48 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
'use client'; | ||
import { Alchemy, Network } from 'alchemy-sdk'; | ||
|
||
const useGetTokenBalance = async (ownerAddress: string) => { | ||
try { | ||
const config = { | ||
apiKey: process.env.NEXT_PUBLIC_ALCHEMY_API_KEY, | ||
network: Network.ETH_SEPOLIA, | ||
}; | ||
const alchemy = new Alchemy(config); | ||
|
||
const tokenContractAddresses = ['0x94a9D9AC8a22534E3FaCa9F4e7F2E2cf85d5E4C8']; | ||
console.log('ownerAddress', ownerAddress, "tokenContractAddresses", tokenContractAddresses); | ||
|
||
|
||
const data = await alchemy.core.getTokenBalances( | ||
ownerAddress, | ||
tokenContractAddresses | ||
); | ||
|
||
console.log('Token balance for Address'); | ||
console.log(data); | ||
|
||
return data; | ||
} catch (error) { | ||
console.log('error', error); | ||
} | ||
}; | ||
|
||
export default useGetTokenBalance; |