Purchase NFTs from Sellers

When a user has listed an NFT for sale at a specific price, a buyer can purchase the token through the following two APIs:

  1. initiateBuyNFT: This API fetches the token listing information, including the token details and the listed price, to initiate the buy transaction. The buyer can complete the transaction through the front-end using Phantom or Backpack wallet.
  2. updateTransactionHash: After the successful purchase, the buyer needs to confirm the transaction by calling the updateTransactionHash API. This finalizes the sale and records the transaction hash.

Sample mutations

mutation initiateBuyNFT($nftTokenId: UUID1!, $buyerAddress: String!, $orgId: UUID1!, $country: String, $postalCode: String, $currencyId: UUID1, $cryptoTax: CryptoTax, $taxAddress: TaxAddressInput) {
  initiateBuyNFT(
    nftTokenId: $nftTokenId
    buyerAddress: $buyerAddress
    orgId: $orgId
    country: $country
    postalCode: $postalCode
    currencyId: $currencyId
    cryptoTax: $cryptoTax
    taxAddress: $taxAddress
  ) {
    proofOfApproval
    Network {
      id
      name
      chainID
      wethAddress
      __typename
    }
    order {
      id
      nftTokenId
      tokenId
      tokenContract
      quantity
      nftOwnerAddress
      fixedPrice
      price {
        unit
        value
        type
        __typename
      }
      nftToken {
        id
        name
        deployed
        tokenMetadata {
          name
          description
          image
          __typename
        }
        nftContractID
        __typename
      }
      __typename
    }
    bubblegumParams {
      buyer
      seller
      buyerTokenAccount
      sellerTokenAccount
      systemProgram
      tokenProgram
      bubblegumProgram
      compressionProgram
      treeAuthority
      leafOwner
      leafDelegate
      newLeafDelegate
      logWrapper
      merkleTree
      buyDiscriminator
      marketplaceAddress
      mintAccount
      buyerVinTokenAccount
      sellerVinTokenAccount
      commissionVinTokenAccount
      platformVinTokenAccount
      initializeAccount
      metadataId
      listing
      bubblegumArg {
        amount
        dataHash
        creatorHash
        nonce
        index
        root
        proof
        __typename
      }
      offer
      offerEscrow
      acceptOfferDiscriminator
      delegateAuthority
      __typename
    }
    isNonEVM
    __typename
  }
}
mutation updateTransactionHash($nftTokenId: UUID1!, $orgId: UUID1!, $transactionHash: String!, $buyerAddress: String!, $orderId: UUID1) {
  updateTransactionHash(
    nftTokenId: $nftTokenId
    orgId: $orgId
    transactionHash: $transactionHash
    buyerAddress: $buyerAddress
    orderId: $orderId
  ) {
    success
    order {
      id
      nftTokenId
      fixedPrice
      price {
        value
        unit
        type
        __typename
      }
      __typename
    }
    newNFTID
    __typename
  }
}

Sample variable

{
  "orgId": "0db10bbf-85fe-4c87-911b-d18f8568fc07",
  "nftTokenId": "021272bc-e41b-412f-8631-f63304a6d3a6",
  "buyerAddress": "AhE1ubLPzT6vY1rWFoPko5DSC3rpQUhLMjdEiWV1mJGh",
  "currencyId": "ef390e4c-3194-44ad-b4d7-14be88ed4ee7"
}
{
  "orgId": "0db10bbf-85fe-4c87-911b-d18f8568fc07",
  "transactionHash": "uh59p5YRE5Krq6uQTUJ4A4FaAymDmGgWt2pLz3EctgiSpZyYBSNhLhuAUyDAuZ58dxWtgWDZS4sE5iDu4NRgP37",
  "nftTokenId": "021272bc-e41b-412f-8631-f63304a6d3a6",
  "buyerAddress": "AhE1ubLPzT6vY1rWFoPko5DSC3rpQUhLMjdEiWV1mJGh",
  "orderId": "bab1a303-9c9d-49cf-a464-4bdd6c1fe618"
}

Sample response

{
  "data": {
    "initiateBuyNFT": {
      "proofOfApproval": "9JJFzSxGDGaWNBuL5szb26YNTSLuPZNmUFnnpTfnuZeY",
      "Network": {
        "id": "51987430-77d2-4633-99c3-100cdd9952c7",
        "name": "Solana Devnet",
        "chainID": 901,
        "wethAddress": "",
        "__typename": "Network"
      },
      "order": {
        "id": "bab1a303-9c9d-49cf-a464-4bdd6c1fe618",
        "nftTokenId": "021272bc-e41b-412f-8631-f63304a6d3a6",
        "tokenId": "7dDe5D6N16tkuM53RKEuKJ7gZDiB7NC6oyQKP2AQJDSc",
        "tokenContract": "FytWTAobotGfihugTU8TEQzEgjfrttUVNWcRHv1GG2G3",
        "quantity": 1,
        "nftOwnerAddress": "7GckBHDKCMEdFdnxJV3qY12YCEVop6MKtgjVAnd7vHGD",
        "fixedPrice": 1,
        "price": [],
        "nftToken": {
          "id": "021272bc-e41b-412f-8631-f63304a6d3a6",
          "name": "GrapeCraft #7",
          "deployed": true,
          "tokenMetadata": {
            "name": "GrapeCraft #7",
            "description": "A rare vintage-inspired collectible from the GrapeCraft series.",
            "image": "https://storage.googleapis.com/mojito-dev-public/nft/solana/GrapeCraft/7.jpeg",
            "__typename": "ERC721Metadata"
          },
          "nftContractID": "24c7e3c6-89dd-4b3c-82d4-dcf2a8257c69",
          "__typename": "NFTToken"
        },
        "__typename": "Order"
      },
      "bubblegumParams": {
        "buyer": "AhE1ubLPzT6vY1rWFoPko5DSC3rpQUhLMjdEiWV1mJGh",
        "seller": "7GckBHDKCMEdFdnxJV3qY12YCEVop6MKtgjVAnd7vHGD",
        "buyerTokenAccount": "HpmxiYp7pNS9bH9Bq5VpJDEw4P3hDu3WMg1VbwtHPnkB",
        "sellerTokenAccount": "D5RsufniFeb1zEygWM1SZ4kg2oxnFS8A67dvhjtWvToD",
        "systemProgram": "11111111111111111111111111111111",
        "tokenProgram": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
        "bubblegumProgram": "BGUMAp9Gq7iTEuizy4pqaxsTyUCBK68MDfK752saRPUY",
        "compressionProgram": "cmtDvXumGCrqC1Age74AVPhSRVXJMd8PJS91L8KbNCK",
        "treeAuthority": "DnuWkN8zJAk2H5PwaYkEPRyQkVZb3LN7BtoLzXykRQf5",
        "leafOwner": "7GckBHDKCMEdFdnxJV3qY12YCEVop6MKtgjVAnd7vHGD",
        "leafDelegate": "9VmqpuzWwfEh4qBmV1bhKBMnMJZp6HgR26GsZFiLX3uc",
        "newLeafDelegate": "AhE1ubLPzT6vY1rWFoPko5DSC3rpQUhLMjdEiWV1mJGh",
        "logWrapper": "noopb9bkMVfRPU8AsbpTUg8AQkHtKwMYZiFUjNRtMmV",
        "merkleTree": "4iCY74wJcHPfskyoJaYh788Y8nPKY78DagE7Z2X1er2y",
        "buyDiscriminator": [
          96,
          0,
          28,
          190,
          49,
          107,
          83,
          222
        ],
        "marketplaceAddress": "4aRpxWDMLu9ZfYYFYPng2PnyUancWcZipkFhVHRxLREY",
        "mintAccount": "FytWTAobotGfihugTU8TEQzEgjfrttUVNWcRHv1GG2G3",
        "buyerVinTokenAccount": "EaXKtgnKwXvxfeiMR1eCq21EWUzc9NLkY9t8oCUNGxpV",
        "sellerVinTokenAccount": "7wrTJoBe5SVtpohw6cHr3YV9hLYWtTZAhETtv2oRtHXf",
        "commissionVinTokenAccount": "H5cQLHmLcvexAtUT2Lb6dnPc5dKgtZye31tkUmeUp54J",
        "platformVinTokenAccount": "E63JtPtbmRCjNx8mA73xHJZ6gX5CeEuFDsJGykyNSYqb",
        "initializeAccount": "6wFGPaANJuXeWHSEjGhtMhKQftQaTTvhxZxBrUhgn9pF",
        "metadataId": "Zv2vv8roKtLuqQTFT14NpbhhjWVmu3qhqgiwaG8RrpF",
        "listing": "9JJFzSxGDGaWNBuL5szb26YNTSLuPZNmUFnnpTfnuZeY",
        "bubblegumArg": {
          "amount": 1000000000,
          "dataHash": "923Pyist1hp5sAQLwTHrJnsDs4eHf2cR3UhuhyagYzUh",
          "creatorHash": "E85ZyyjjrrsKAgeGeqBE2RSkfzs94FTdfEtefJpnJHrp",
          "nonce": 6,
          "index": 6,
          "root": "9mmsqqMU6UCMqh5eXggwSWxtfL8qEMc5bjwuizcgsN8E",
          "proof": [
            "EVpnpyr76cRj9hsbanRPPHe3Xy68Gs6X2Z2BwAtwWFTn",
            "BWJVP3XGfLCUHxWsYV3fJB5VpxgTbDikWX1w5WuFHXqz",
            "DUPLo4PDHx9zDwMAkzr5go9PRvAN8kA9B9HejTK62HSm",
            "8WkbxHTtzURPaXrj2U57TKmcQLzYk9ubre7co3vkPeBT",
            "GSz87YKd3YoZWcEKhnjSsYJwv8o5aWGdBdGGYUphRfTh",
            "zLUDhASAn7WA1Aqc724azRpZjKCjMQNATApe74JMg8C",
            "ABnEXHmveD6iuMwfw2po7t6TPjn5kYMVwYJMi3fa9K91",
            "JDh7eiWiUWtiWn623iybHqjQ6AQ6c2Czz8m6ZxwSCkta",
            "BFvmeiEuzAYcMR8YxcuCMGYPDpjcmP5hsNbcswgQ8pMc",
            "EvxphsdRErrDMs9nhFfF4nzq8i1C2KSogA7uB96TPpPR",
            "HpMJWAzQv9HFgHBqY1o8V1B27sCYPFHJdGivDA658jEL",
            "HjnrJn5vBUUzpCxzjjM9ZnCPuXei2cXKJjX468B9yWD7",
            "4YCF1CSyTXm1Yi9W9JeYevawupkomdgy2dLxEBHL9euq",
            "E3oMtCuPEauftdZLX8EZ8YX7BbFzpBCVRYEiLxwPJLY2",
            "7DiCkBhs5HQLPEsKY6EjfNd3oBswnfRk9UAZcHqczL7m",
            "FhsNgK6GGU1cRPFbmPhrEZ95Zj8vorjK6GmhFuwmZsUm",
            "3e2oBSLfSDVdUdS7jRGFKa8nreJUA9sFPEELrHaQyd4J",
            "GCXyEHiFMtRFTNFT5LNHwxiXZfooBpUMGSkjyz7pfcS5",
            "752CmMF5k7acEFEmJA7oE3aobbWj7CAZVm3KpDR6HiRV",
            "D9GGr1ycBmgRbHJyJzmxMk5aoKZmjdezB4NpxopAcgpP"
          ],
          "__typename": "bubblegumArg"
        },
        "offer": "",
        "offerEscrow": "",
        "acceptOfferDiscriminator": [],
        "delegateAuthority": null,
        "__typename": "bubblegumInfo"
      },
      "isNonEVM": true,
      "__typename": "NFTSaleDetails"
    }
  }
}
{
  "data": {
    "updateTransactionHash": {
      "success": true,
      "order": {
        "id": "bab1a303-9c9d-49cf-a464-4bdd6c1fe618",
        "nftTokenId": "021272bc-e41b-412f-8631-f63304a6d3a6",
        "fixedPrice": 1,
        "price": [
          {
            "value": 0.037,
            "unit": "USD",
            "type": "FIAT",
            "__typename": "NFTPrice"
          },
          {
            "value": 1,
            "unit": "VIN",
            "type": "CRYPTO",
            "__typename": "NFTPrice"
          }
        ],
        "__typename": "Order"
      },
      "newNFTID": "021272bc-e41b-412f-8631-f63304a6d3a6",
      "__typename": "TransactionResponse"
    }
  }
}

Field

The table below provides an explanation of each variable in the respective column.

initiateBuyNFT:

NameTypeDescription
orgIdUUID1The organization ID.
nftTokenIdUUID1The NFT token ID.
buyerAddressStringThe buyer's wallet address.
currencyIdUUID1The payment currency ID is fetched from the supported currency API

updateTransactionHash:

NameTypeDescription
orgIdUUID1The organization ID.
nftTokenIdUUID1The NFT token ID.
transactionHashStringThe successful transaction hash.
buyerAddressStringThe user buyer's address.
orderIdUUID1The listing order ID.