Developer Wallets

Introduction

Developer wallets allow you as the game developer, to control a set of your assets and currencies—a treasury of sorts.

You as the game developer will not have to worry about gas fees whatsoever.

The rest of guide will walk you through setting up a developer wallet for your project, and demonstrate developer wallet functionality.

Setup: Developer wallet key & secret

We will assign you a wallet key, that only you can use to control your project's developer wallet. These will be required to authorize transactions involving currency and assets from your developer wallet, so make sure it is stored in a safe place (and is separate from your GameShift api key). This wallet key is separate from your GameShift key, which enables access to the rest of GameShift’s APIs. We do not store these credentials and therefore cannot recover access to your developer wallet if you lose them.

Using our dashboard, navigate to your game's sidebar, access the developer wallet page, and generate a wallet key. Once you have your key, the rest of the actions in this guide will be ready for use.

In this user guide:

  • x-api-key will refer to the GameShift key
  • x-wallet-key will refer to the Developer Wallet key

Fetch Developer Wallet Address

Fetch your developer wallet address:

curl -X 'GET' \
  'https://api.gameshift.dev/nx/developer-wallet/wallet-address' \
  -H 'accept: application/json' \
  -H 'x-api-key: <api_key>'

Response:

{"address":"AHknJK4biVzW42zDQaWMhsYDYBtnoVdQoRaJZbxVt6gY"}

Currencies

We will now demonstrate the currency capabilities of the developer wallet

Let's start by creating a sample token. Assuming you have the spl-token cli setup on your local machine , let's run the following commands.

spl-token create-token
> 8drYDKPUVahnv9KeNhBNsY44yUGYcJrEjEpCcd9TREyn
spl-token create-account 8drYDKPUVahnv9KeNhBNsY44yUGYcJrEjEpCcd9TREyn
spl-token mint 8drYDKPUVahnv9KeNhBNsY44yUGYcJrEjEpCcd9TREyn
spl-token transfer 8drYDKPUVahnv9KeNhBNsY44yUGYcJrEjEpCcd9TREyn 100 AHknJK4biVzW42zDQaWMhsYDYBtnoVdQoRaJZbxVt6gY --fund-recipient --allow-unfunded-recipient

Here, we use our private Solana keypair on our local machines to create a token, then transfer tokens to the developer wallet. Once you follow the directions to register a token , we can fetch the balances for currencies in your developer wallet.

curl -X 'GET' \
  'https://api.gameshift.dev/nx/developer-wallet/items?types=Currency' \
  -H 'accept: application/json' \
  -H 'x-api-key: <gameshift_key>'

Response:

{
  "data": [
    {
      "type": "Currency",
      "item": {
        "id": "SOL",
        "mintAddress": "11111111111111111111111111111111",
        "name": "SOL",
        "symbol": "SOL"
      },
      "quantity": "0"
    },
    {
      "type": "Currency",
      "item": {
        "id": "USDC",
        "mintAddress": "4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU",
        "name": "USD Coin",
        "symbol": "USDC"
      },
      "quantity": "0"
    },
    {
      "type": "Currency",
      "item": {
        "id": "0de168db-1e84-43b8-80fb-f31808f5a311",
        "mintAddress": "8drYDKPUVahnv9KeNhBNsY44yUGYcJrEjEpCcd9TREyn",
        "name": "",
        "symbol": ""
      },
      "quantity": "100"
    }
  ],
  "meta": {
    "page": 1,
    "perPage": 50,
    "totalPages": 1,
    "totalResults": 3
  }
}

You can also choose to transfer currencies from your developer wallet to a user of your project, or any other Solana wallet. (Make sure your developer wallet is funded with a small amount of SOL to be able to run the transaction):

curl -X 'POST' \
  'https://api.gameshift.dev/nx/developer-wallet/items/0de168db-1e84-43b8-80fb-f31808f5a311/transfer' \
  -H 'accept: application/json' \
  -H 'x-api-key: <api_key>' \
  -H 'x-wallet-key: <wallet_key>' \
  -H 'Content-Type: application/json' \
  -d '{
  "destinationUserReferenceId": "user1",
  "quantity": "2"
}'

Response:

{
  "id": "fcc25e2a-d2f9-4358-9f5a-feb7a03f8d69",
  "created": "2024-05-08T23:03:02.231Z",
  "status": {
    "status": "Pending"
  },
  "details": {
    "type": "TransferTokenFromDeveloper",
    "item": {
      "id": "e0dfdc68-a76f-4036-8f42-fae40238a27f",
      "mintAddress": "8drYDKPUVahnv9KeNhBNsY44yUGYcJrEjEpCcd9TREyn",
      "name": "",
      "symbol": ""
    }
  }
}

The Response is initially in pending state. We can later query the transaction status again:

curl -X 'GET' \
  'https://api.gameshift.dev/transactions/fcc25e2a-d2f9-4358-9f5a-feb7a03f8d69' \
  -H 'accept: application/json' \
  -H 'x-api-key: <api_key>'

Response:

{
  "id": "fcc25e2a-d2f9-4358-9f5a-feb7a03f8d69",
  "created": "2024-05-08T23:03:02.231Z",
  "status": {
    "status": "Confirmed",
    "txHash": "5R46c1nHJ7PWC7iZk9sExQLx7iWK59e3MxRLjysSpqqYemHMoxbiqyZRk5P5S31jAuVh6cGsM8YrJqA95AGzVnYW"
  },
  "details": {
    "type": "TransferTokenFromDeveloper",
    "item": {
      "id": "e0dfdc68-a76f-4036-8f42-fae40238a27f",
      "mintAddress": "8drYDKPUVahnv9KeNhBNsY44yUGYcJrEjEpCcd9TREyn",
      "name": "",
      "symbol": ""
    }
  }
}

Assets

Your developer wallet will also have the ability to hold assets. You can fetch all the assets in your developer wallet:

curl -X 'GET' \
  'https://api.gameshift.dev/nx/developer-wallet/items?types=UniqueAsset' \
  -H 'accept: application/json' \
  -H 'x-api-key: <api_key>'

Response

{
  "data": [
    {
      "type": "UniqueAsset",
      "item": {
        "id": "79926700-e0f4-4454-aec6-5287bfea40a3",
        "collection": {
          "id": "9266c642-b1ab-4b40-822a-aa3f5a56af10",
          "name": "Default",
          "description": "",
          "environment": "Development",
          "imported": false,
          "mintAddress": "9TLcFuCyWeHR3tySiMr7PjGmeUHhpFDiaJ4ykUQ2RyDu",
          "created": 1715211337661
        },
        "created": 1715211339018,
        "attributes": [
          {
            "value": "string",
            "traitType": "string"
          }
        ],
        "name": "daniel",
        "description": "string",
        "environment": "Development",
        "escrow": false,
        "imageUrl": "https://google.com",
        "imported": false,
        "priceCents": null,
        "status": "Processing",
        "mintAddress": "",
        "owner": {
          "referenceId": "self"
        }
      }
    }
  ],
  "meta": {
    "page": 1,
    "perPage": 50,
    "totalPages": 1,
    "totalResults": 1
  }
}

You can also transfer assets from your developer wallet to any user or wallet address

Transfer Asset:

curl -X 'POST' \
  'https://api.gameshift.dev/nx/developer-wallet/items/79926700-e0f4-4454-aec6-5287bfea40a3/transfer' \
  -H 'accept: application/json' \
  -H 'x-api-key: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJrZXkiOiJhY2U1N2VlNS0xN2M3LTQyMzQtOWNiMy02ZTk4NWNlZThjODUiLCJzdWIiOiJmNDI4YWE5OC0zOWNkLTQwYmYtYjIyZi01ZWJkYWI1ZTQ4NmMiLCJpYXQiOjE3MTUxMjcyNjV9.cDSTXNiASHwDiPfMe92gtAjs1GCA7s11WdD8u8hUrDw' \
  -H 'x-wallet-key: AqRwZdFFPHHoQle3X9FendrKiBHNd+AQLPPID/IozOwJ' \
  -H 'Content-Type: application/json' \
  -d '{
  "destinationUserReferenceId": "h1",
  "quantity": "1"
}'

Response

{
  "id": "9df80dda-1e55-44d0-9301-f4b47cb25d85",
  "created": "2024-05-08T23:36:04.894Z",
  "status": {
    "status": "Pending"
  },
  "details": {
    "type": "TransferAssetFromDeveloper",
    "item": {
      "id": "79926700-e0f4-4454-aec6-5287bfea40a3",
      "collection": {
        "id": "9266c642-b1ab-4b40-822a-aa3f5a56af10",
        "name": "Default",
        "description": "",
        "environment": "Development",
        "imported": false,
        "mintAddress": "9TLcFuCyWeHR3tySiMr7PjGmeUHhpFDiaJ4ykUQ2RyDu",
        "created": 1715211337661
      },
      "created": 1715211339018,
      "attributes": [
        {
          "value": "string",
          "traitType": "string"
        }
      ],
      "name": "daniel",
      "description": "string",
      "environment": "Development",
      "escrow": false,
      "imageUrl": "https://google.com",
      "imported": false,
      "priceCents": null,
      "status": "Committed",
      "mintAddress": "GrqWnthMKtqF76p1cZTJ7c9EdjSeyniHbZbnvzr9m1vo",
      "owner": {
        "address": "8CcvQQUruczgpBMyfVnnfcpfKeyaFmQzjKVPznLoo6qa",
        "referenceId": "self"
      }
    }
  }
}