Pay for an asset with Crypto
You can easily allow your users to pay for assets in your game by paying with SOL. The minting price and details of the asset to be minted are fully customizable. The purchase flow is seamlessly generated and similar to checkout Gameshifts credit card checkout flows.
Initiating an Asset Mint with SOL
To initiate the minting of an asset paid for with SOL
, make a POST request to https://api.gameshift.dev/nx/payments/unique-assets
with the following parameters:
curl --request POST \
--url https://api.gameshift.dev/nx/payments/unique-assets \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--header 'x-api-key: <your api key>' \
--data '{
"details": {
"name": "Magic Sword",
"description": "A powerful sword imbued with magic",
"imageUrl": "https://example.com/magic-sword.png",
"collectionId": "your_collection_id",
"attributes": [
{
"traitType": "Damage",
"value": "50"
},
{
"traitType": "Element",
"value": "Fire"
}
]
},
"price": {
"currencyId": "SOL",
"naturalAmount": "0.05"
},
"destinationUserReferenceId": "player-1"
}'
The request body must include the following fields:
details
: An object specifying the properties of the asset to be minted, including:name
: The name of the assetdescription
: A description of the assetimageUrl
: A URL pointing to the image for this assetcollectionId
: The ID of the collection this asset should belong toattributes
: An array of trait_type/value pairs for the asset's attributes
price
: An object defining the mint price of the asset, including:currencyId
: This must be"SOL"
to mint with SOLnaturalAmount
: The amount ofSOL
required to mint, as a string (e.g. "1.5")
destinationUserReferenceId
: The reference ID of the user who will receive the newly minted asset
The response will include a "checkout URL" that you must navigate the user to in order to pay the minting price and receive the asset:
{
"checkoutUrl": "https://app.gameshift.dev/checkout?payment=7hud72js...",
"id": "7hud72js..."
}
Once the user completes the checkout flow, the asset will be minted and transferred to the destinationUserReferenceId
specified. The asset will then be queryable via the existing Asset and User APIs.
Retrieving Details of a Mint with SOL Payment
To get information about a Mint with SOL payment, you can make a GET request to the Payment endpoint for the returned payment ID:
curl --request GET \
--url https://api.gameshift.dev/payments/<payment-id-from-response> \
--header 'accept: application/json' \
--header 'x-api-key: <your api key>'
This will return details about the payment, including the current status (paymentStatus
) which will be one of:
Pending
: Waiting for the user to complete the checkout flowConfirmed
: The user completed checkout and minting is in progressFailed
: There was an issue processing the payment
The response will also include information about the associated asset in the asset
field once minting has started.
Updated 3 months ago