Skip to content
SDKPlayer ServiceAssetsManaging player assets

Managing player assets

Through the API key, you are authorized to initalize Operations on Assets for all the players you created, for every contract that is registered to your game. Methods described below are available, but obviously ERC-20 token transfers will only be relevant to you if an ERC-20 contract was added to your game within Beam.

Currency transfers (ERC-20)

If an ERC-20 contract is registered for your game, you are able to manage the ERC-20 assets for all the players within your game. Sending these tokens around is easy. We simply expect you to know the ID of the sender, as well as the ID of the receiver, both of which you should have created a Player for. You can also send directly to an on-chain account address.

In the example below, we are not considering more complicated features like sponsoring transactions just yet - the transaction will be paid for by you - the game developer.

const transaction = await beam.assets.transferTokenV3("entity-id-of-user", {
  receiverEntityId: "your-receiver-entity-id",
  assetAddress: "your-contract-address",
  amountToTransfer: "10", // 10 means 10 - we don't expect you to consider any other format like gwei
});
 
// {
//   "status": "Pending",
//   "id": "string",
//   "createdAt": "2024-06-06T10:27:00.304Z",
//   "updatedAt": "2024-06-06T10:27:00.304Z",
//   "gameId": "string",
//   "userId": "string",
//   "chainId": 0,
//   "url": "string",
//   "transactions": [
//      (...)
//   ]
// }

The Operation returned by the method needs to be signed. Learn more about Operations here: Operations introduction.

NFTs transfers (ERC-721, ERC-1155)

Asset transfers work in a similar fashion as ERC-20 token transfers, but instead of calling transferToken, you will need to call the transferAsset method and pass an assetId property for the asset you want to move around.

const transaction = await beam.assets.transferAssetV3("entity-id-of-user", {
  receiverEntityId: "your-receiver-entity-id",
  assetAddress: "your-contract-address",
  assetId: "73",
  amountToTransfer: 1, // amountToTransfer is related to 1155, defaults to 1 and doesn't have to be passed for ERC721 contracts.
});
 
// {
//   "status": "Pending",
//   "id": "string",
//   "createdAt": "2024-06-06T10:27:00.304Z",
//   "updatedAt": "2024-06-06T10:27:00.304Z",
//   "gameId": "string",
//   "userId": "string",
//   "chainId": 0,
//   "url": "string",
//   "transactions": [
//      (...)
//   ]
// }

Native transfers (BEAM)

Lastly - we offer the possibility to transfer our native token: BEAM. Depending on the context of your game, you might want to be able to transfer the native token around between profiles.

const transaction = await beam.assets.transferNativeTokenV3("entity-id-of-user", {
  receiverEntityId: "your-receiver-entity-id",
  amountToTransfer: "10", // 10 means 10 - we don't expect you to consider any other format like gwei
});
 
// {
//   "status": "Pending",
//   "id": "string",
//   "createdAt": "2024-06-06T10:27:00.304Z",
//   "updatedAt": "2024-06-06T10:27:00.304Z",
//   "gameId": "string",
//   "userId": "string",
//   "chainId": 0,
//   "url": "string",
//   "transactions": [
//      (...)
//   ]
// }