Skip to main content
Version: V1

Read NFT Ownership

tip

Install the GraphQL packages before starting this section.

In this section, we'll help you write a simple query to read the ownership information of an NFT.

  1. Initialize the GraphQL client:
/src/queries/GetNFTOwnership.tsx
const client = new GraphQLClient(CYBERCONNECT_ENDPOINT);
  1. Write a query to get the NFT's tokenId, its owner, and the owner's twitter handle:
/src/queries/GetNFTOwnership.tsx
export const GET_NFT_OWNERSHIP = gql`
query($contract: String!, $tokenId: String) {
nftOwners(contract: $contract, tokenId: $tokenId) {
tokenId
owner
twitter {
handle
}
}
}
`;

Make sure to check out the full list of fields available in the CyberConnect API.

Sandbox

You can write your own query in the Playground or experiment with our code in the sandbox below!

Designed by