Requesting a Collectible

ORB allows developers to request certain collectibles from their players. This can occur for a few reasons:

  • The player wants to enter a specific area in the game. In order to do so, they have to give their collectible, which acts as their access, to the developer or a designated wallet address

  • The player wants to create a new item/collectible in game, but in order to do so they need to hand over certain collectibles first, as first materials or resources for the new item which will be made

  • The player wants to exchange a collectible for another one - perhaps a higher rarity/level collectible for the one they already have

There are a lot of applications in games in which the game/developer needs to request certain tokens from the player. Here is how that is possible using the ORB3 API.

Use the following Mutation to request a collectible to a specified wallet address.

SendToken
mutation RequestToken($input: requestTokenInput!) {
  SendToken(input: $input) {
    status,
    transactionHash
  }
}
Input Variables
"input": {
    "collectionId": "KT1G76H9srgnpXBVYEjbiTgXpbMN7cZ3vVMp",
    "from": "tz1Sd5ceMABaiPU4qQvvrVJQYbE6X2gJBmf8",
    "transactions": [
      {
        "quantity": "1",
        "to": "tz1i7SnAcekYtyPv1RZ9YBbnd8ScNcREVaDK",
        "tokenId": "3"
      },
      {
        "quantity": "9",
        "to": "tz1aWZmdKqKvGP331yWJjqgCZakGci3VAGmj",
        "tokenId": "0"
      }
    ]
  }

When requesting a collectible from a wallet, make note of a few useful tips:

  • It is advisable that you check beforehand to make sure that the person does have the collectible you want in their wallet. In case they do not, the transaction request will reach the wallet, but it will fail. You can do this by using the GetOwnedTokens Query

  • You can request multiple collectibles with each call. For each distinct tokenId, you can choose the number of editions you will request as well as the wallet to which the editions of this collectible will be send to. The only restrain is that all the Collectibles you will be requesting need to have been created in the same collection, meaning same collectionId.

Here are a few things to keep in mind when wanting to send editions of a collectible to a wallet address:

  • collectionId: The collectionId that the collectible was created in.

  • transactions: A list of all the collectibles you wish to send. Think of it as a list, which will hold all the transfers you wish to make. For each one of these transactions, you will need to define the following information.

    • quantity: The number of editions you are looking to send over.

    • to: The wallet address you are looking to send the collectibles to.

    • tokenId: The tokenIds of the collectibles you are looking to send.

The RequestToken Mutation allows you to request multiple collectibles from a wallet address, all in one transaction, thus lowering the number of transactions overall. The only thing to keep in mind is that all the collectibles need to be part of the same collection.

Furthermore, apart from sending multiple collectibles (different tokenIds), you can choose to send each one of these to a different wallet address if need be.

In the example of the code above, we have chosen to send 2 different collectibles, both part of the collection with Id KT1G76H9srgnpXBVYEjbiTgXpbMN7cZ3vVMp. For the collectible with tokenId 3 we will send 1 edition to the user with wallet address tz1i7SnAcekYtyPv1RZ9YBbnd8ScNcREVaDK, and for the collectible with tokenId 0 we will send 9 editions to the user with wallet address tz1aWZmdKqKvGP331yWJjqgCZakGci3VAGmj.

Sample Response
{
  "data": {
    "RequestToken": {
      "status": "applied",
      "transactionHash": "ooHdoNxmsXAYPSAT8Nf2xruL45uJvGYjcKtvhmMdepFR56rRafV"
    }
  }
}

Once the transaction has been signed from the specified wallet, the editions of the collectibles will leave the wallet and be sent to the defined addresses. The hash of the transaction will be provided as a response, in order to be able to monitor the successful completion of the transfer.

Last updated