Transferring a token out of a Hub wallet
In this guide, we'll use Hub API to transfer a Hub-minted token out of a Hub wallet. We'll add corresponding UI to our starter mint repos. The feature is available now via Hub API.
Prerequisites
- A token minted out of a drop within Holaplex Hub or via Hub API
- Access to the Holaplex Hub GraphQL API (an access token can be generated on Hub's "Credentials" page)
- Hub API Playground: https://api.holaplex.com. You could also use a GraphQL client such as Apollo Client or a tool like GraphQL Playground
For all API requests to Hub, you'll need to include an authentication header of the form
{
"Authorization": "<access-token>"
}
The first step is creating a customer associated to a project in Hub. To do this, you need to send a createCustomer
mutation with the required input parameters.
Mutation
mutation TransferAsset($input: TransferAssetInput!) {
transferAsset(input: $input) {
mint {
id
address
}
}
}
Variables
{
"input": {
"id": "<mint-id>",
"recipient": "<destination-wallet-address>"
}
}
Response
{
"data": {
"transferAsset": {
"mint": {
"id": "<mint-id>",
"address": "<token-address>"
}
}
}
}
Note that the API only supports transfering an NFT out of a Hub wallet. If a transfer is requested from an external wallet (even if the token was minted by Hub), Hub will return an error.