Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,30 @@ import { Network } from 'alchemy-sdk';
async function main() {
// Default config to use for all networks.
const defaultConfig = {
apiKey: 'demo', // TODO: Replace with your API key.
network: Network.MATIC_MAINNET
apiKey: 'demo', // TODO: Replace with your Mainnet Alchemy API key.
network: Network.ETH_MAINNET
};
// Include optional setting overrides for specific networks.
const overrides = {
// TODO: Replace with your API keys.
[Network.MATIC_MAINNET]: { apiKey: 'matic-api-key', maxRetries: 10 },
[Network.ARB_MAINNET]: { apiKey: 'arb-api-key' }
[Network.MATIC_MAINNET]: { apiKey: 'demo', maxRetries: 10 }, // Replace with your Matic Alchemy API key.
[Network.ARB_MAINNET]: { apiKey: 'demo' } // Replace with your Arbitrum Alchemy API key.
};
const alchemy = new AlchemyMultichainClient(defaultConfig, overrides);

// get NFTs in multiple networks
// owner for which you want to get the NFTs
const owner = '0xd8da6bf26964af9d7eed9e03e53415d37aa96045';

// get NFTs for owner in mainnet and matic networks with a page size of 5
const mainnetNfts = await alchemy
.forNetwork(Network.ETH_MAINNET)
.nft.getNftsForOwner(owner, { pageSize: 5 });
const maticNfts = await alchemy
.forNetwork(Network.MATIC_MAINNET)
.nft.getNftsForOwner(owner, { pageSize: 5 });

// log the NFTs
console.log('mainnetNfts', mainnetNfts);
console.log('maticNfts', maticNfts);
}
Expand Down