Fetch and Transfer NFTs
You started creating wallets. Now it's time to build the frontend for your users to interact with them.
Visualizing the NFTs
The following API retrieves the NFTs stored in a wallet so you can display them in your frontend:
const fetch = require('node-fetch');
const url = 'https://staging.crossmint.com/api/v1-alpha1/wallets/chain:wallet/nfts?page=xx&perPage=xx';
const options = {
method: 'GET',
headers: {
accept: 'application/json',
'X-CLIENT-SECRET': '<YOUR_CLIENT_SECRET>',
'X-PROJECT-ID': '<YOUR_PROJECT_ID>'
}
};
fetch(url, options)
.then(res => res.json())
.then(json => console.log(json))
.catch(err => console.error('error:' + err));
Parameter | Type | Description |
---|---|---|
chain | string | arbitrum , arbitrumnova , base , bsc , cardano ,ethereum , optimism , polygon , solana , and zora |
walletAddress | string | Wallet address whose content you want to fetch |
page | int | Page index, starting with 1 |
perPage (optional) | int | Number of items to display per page. Default: 20 |
Transferring NFTs
This API allows you to transfer an NFT from a wallet you control to any other wallet (whether it's powered by Crossmint or not), in a gas-less and seamless experience for your users. This API scope is open in staging but gated in production. Contact us to get access.
const fetch = require('node-fetch');
const url = 'https://staging.crossmint.com/api/v1-alpha1/transfer';
const options = {
method: 'POST',
headers: {
accept: 'application/json',
'content-type': 'application/json',
'X-CLIENT-SECRET': '',
'X-PROJECT-ID': ''
},
body: JSON.stringify({
chain:'',
tokenId:'',
toAddress: '',
tokenMintAddress: '',
fromAddress: ''
})
};
fetch(url, options)
.then(res => res.json())
.then(json => console.log(json))
.catch(err => console.error('error:' + err));
Parameter | Type | Description |
---|---|---|
chain | string | Blockchain of the NFT you want to transfer: [arbitrum , arbitrumnova , base , bsc , cardano ,ethereum , optimism , polygon , solana , and zora ] |
tokenId | string | The identifier of the NFT |
toAddress | string | The wallet address where you want to send the NFT |
tokenMintAddress | string | Contract address |
fromAddress | string | The wallet address for the current owner |
Updated 24 days ago