Delegate
  • Overview
  • Delegating a wallet
  • Comparison with Others
  • FAQ
  • Audits
  • Integrate In Your Project
    • Smart Contract Examples
    • Token Ownership Claiming
  • Upgrade to V2
    • V2 is a Separate Contract
    • V1 → V2 migration
    • Batching
    • Subdelegations
  • Advanced Use Cases
    • Shadow Delegation
  • Delegate Market
    • Overview
    • FAQ
  • Gaming
    • Delegate for Gaming
  • Technical Documentation
    • Delegate Registry
      • Contract Addresses
      • IDelegateRegistry.sol
    • Javascript SDK
      • Installation / Importing
      • Setup
      • Check Delegations
        • checkDelegateForAll
        • checkDelegateForContract
        • checkDelegateForERC721
        • checkDelegateForERC1155
        • checkDelegateForERC20
      • Fetch Delegations
      • Delegate/Revoke
        • delegateAll
        • delegateContract
        • delegateERC721
        • delegateERC1155
        • delegateERC20
    • REST API
      • v2
      • v1
  • Resources
    • Media Kit
    • Github
    • Twitter
    • Live Stats
  • V1 Registry (Legacy)
    • Technical Documentation
Powered by GitBook
On this page
  1. Integrate In Your Project

Token Ownership Claiming

Explains the recommended user experience for how a user should claim something based on ownership.

PreviousSmart Contract ExamplesNextV2 is a Separate Contract

Last updated 2 months ago

In this example, let's assume a user wants to claim a Ticket to an event based on ownership of a NFT. Your goal is to:

  • List out all NFTs that have been delegated to a particular wallet

  • Process that NFT Token ID as claimed by:

    • Checking ownership of that NFT

    • If the wallet does not own the NFT, check to make sure the NFT has been delegated to that user

  • Give the wallet the Ticket

User experience steps

  1. The first step is to get all the incoming delegations from the wallet that wants to claim the ticket. You can do this the following ways:

    Contract/Javascript SDK:

    REST API: where to is the wallet address in question

  2. Filter out these delegations to only include the NFT Contract you are looking to claim tickets for.

    // A rough example
    const filteredDelegations = incomingDelegations.filter(delegation => {
        return delegation.type === "ALL" ||
        delegation.type === "CONTRACT" && delegation.contract === NFT_CONTRACT ||
        delegation.type === "ERC721"  && delegation.contract === NFT_CONTRACT
    })

  3. Get all the NFT's of each unique from address in the above list.

    const delegatedWallets = [...new Set(filteredDelegations.map(delegation => delegation.from))];

  4. For each delegatedWallet, list all of their NFT's that are from the contract you are claiming for. Then the user can decide which Token ID to claim the ticket for. There are many external API's to accomplish this. Alchemy offers a simple solution here called .

  5. Once the user has selected a token they want to claim a ticket for, the user will most likely send this selection to a backend request. We need to double check that the user has actually delegated this token to the wallet or that the wallet owns this NFT token.

    • Make sure the token id has not been claimed before.

    • Does the wallet submitting the request own this NFT? You can do this by checking the ownerOf(tokenId) on the contract level.

    • If not, double check that the wallet who delegated this token owns the NFT

    • If so, double check that this specific token id has been delegated to the requestor. Contract/Javascript SDK: Use the checkDelegateForERC721 in the SDK or contract REST API: Use the endpoint

  6. Process the ticket! You'll want to mark this specific token id as claimed so no one else can claim this token.

getIncomingDelegations(address)
getNFTsForOwner
Delegations by wallet
v2/check/erc721