ERC721 Standard
You can utilize these features of the SDK if your contract implements the ERC721 standard.
View NFT Balance
Get a wallet's NFT balance (number of NFTs in this contract owned by the wallet).
- React
- Javascript
- Python
- Go
- Unity
const { data: ownerBalance, isLoading, error } = useNFTBalance(contract, "{{wallet_address}}");
// for ERC1155 contracts, you can also pass a tokenId
const tokenId = 0;
const { data: ownerBalance, isLoading, error } = useNFTBalance(contract, "{{wallet_address}}", tokenId);
This snippet is for v3 of the SDK. Learn how to upgrade.
View in React SDK Documentationconst walletAddress = "{{wallet_address}}";
const balance = await contract.erc721.balanceOf(walletAddress);
console.log(balance);
This snippet is for v3 of the SDK. Learn how to upgrade.
View in Javascript SDK DocumentationThis feature is missing a code snippet or might not be supported yet.
Check the Python SDK documentation for more information.
Reach out on Discord for further assistance!
View Python SDK DocumentationThis feature is missing a code snippet or might not be supported yet.
Check the Go SDK documentation for more information.
Reach out on Discord for further assistance!
View Go SDK Documentationvar walletAddress = "{{wallet_address}}";
var balance = await contract.ERC721.BalanceOf(walletAddress);
Debug.Log(balance);
Get NFT Metadata
Read the URI this NFT points to and fetch that data automatically.
If the metadata is stored on IPFS, this function uses our IPFS gateway (or the one you specify) to read the data.
- React
- Javascript
- Python
- Go
- Unity
const tokenId = 0; // the tokenId to look up
const { data: nft, isLoading, error } = useNFT(contract, tokenId);
This snippet is for v3 of the SDK. Learn how to upgrade.
View in React SDK Documentationconst tokenId = 0;
const nft = await contract.erc721.get(tokenId);
This snippet is for v3 of the SDK. Learn how to upgrade.
View in Javascript SDK DocumentationThis feature is missing a code snippet or might not be supported yet.
Check the Python SDK documentation for more information.
Reach out on Discord for further assistance!
View Python SDK DocumentationThis feature is missing a code snippet or might not be supported yet.
Check the Go SDK documentation for more information.
Reach out on Discord for further assistance!
View Go SDK Documentationvar tokenId = "0";
var nft = await contract.ERC721.Get(tokenId);
Transfer NFT
Transfer an NFT from the connected wallet to another wallet.
- React
- Javascript
- Python
- Go
- Unity
const Component = () => {
const { contract } = useContract("{{contract_address}}");
const {
mutate: transferNFT,
isLoading,
error,
} = useTransferNFT(contract);
if (error) {
console.error("failed to transfer NFT", error);
}
return (
<button
disabled={isLoading}
onClick={() => transferNFT({
to: "{{wallet_address}}",
tokenId: 2
})}
>
Transfer
</button>
);
};
This snippet is for v3 of the SDK. Learn how to upgrade.
View in React SDK Documentationconst walletAddress = "{{wallet_address}}";
const tokenId = 0;
await contract.erc721.transfer(walletAddress, tokenId);
This snippet is for v3 of the SDK. Learn how to upgrade.
View in Javascript SDK DocumentationThis feature is missing a code snippet or might not be supported yet.
Check the Python SDK documentation for more information.
Reach out on Discord for further assistance!
View Python SDK DocumentationThis feature is missing a code snippet or might not be supported yet.
Check the Go SDK documentation for more information.
Reach out on Discord for further assistance!
View Go SDK Documentationvar walletAddress = "{{wallet_address}}";
var tokenId = "0";
await contract.ERC721.Transfer(walletAddress, tokenId);