MCPcopy Create free account
hub / github.com/dawsbot/drain / exampleUsage

Function exampleUsage

src/__tests__/moralis-client.example.ts:11–38  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

9
10// Example: Create a client instance
11async function exampleUsage() {
12 const apiKey = process.env.MORALIS_API_KEY || 'your-api-key-here';
13 const client = new MoralisClient(apiKey);
14
15 // Example 1: Fetch tokens for an address on Ethereum
16 const ethereumTokens = await client.fetchTokens(
17 1, // Ethereum mainnet
18 '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045', // Example address
19 [], // No blacklist
20 );
21
22 console.log('Ethereum tokens:', ethereumTokens.erc20s.length);
23
24 // Example 2: Fetch tokens on Polygon with blacklist
25 const polygonTokens = await client.fetchTokens(
26 137, // Polygon mainnet
27 '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045',
28 ['0xdc8fa3fab8421ff44cc6ca7f966673ff6c0b3b58'], // Blacklist specific token
29 );
30
31 console.log('Polygon tokens (filtered):', polygonTokens.erc20s.length);
32
33 // Example 3: Check supported chains
34 const supportedChains = MoralisClient.getSupportedChainIds();
35 console.log('Supported chain IDs:', supportedChains);
36
37 return { ethereumTokens, polygonTokens };
38}
39
40// Example: Mock client for unit testing
41class MockMoralisClient extends MoralisClient {

Callers

nothing calls this directly

Calls 2

fetchTokensMethod · 0.95
getSupportedChainIdsMethod · 0.80

Tested by

no test coverage detected