Skip to main content

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

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.