Skip to content

Commit

Permalink
Merge branch 'main' into chore/clean-up-roadmap
Browse files Browse the repository at this point in the history
  • Loading branch information
Robby Uitbeijerse authored Nov 15, 2023
2 parents 3f5f51c + ce44657 commit 1e782c6
Show file tree
Hide file tree
Showing 8 changed files with 223 additions and 53 deletions.
2 changes: 1 addition & 1 deletion pages/service/_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"type": "separator",
"title": "Guides"
},
"your-game": {
"game": {
"title": "Your game"
},
"profiles": {
Expand Down
6 changes: 6 additions & 0 deletions pages/service/game/_meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"introduction": "Introduction",
"api-keys": "API keys",
"managing-contracts": "Managing contracts",
"updating-game": "Updating game"
}
51 changes: 51 additions & 0 deletions pages/service/game/api-keys.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# API keys

When you've received your Beam accounts API key, you're received three different keys:

- **a read-only key** - this key allows you use read-only endpoints
- **a read & write key** - this key allows you to read and manage data
- **a regenerate key** - this allows you to regenerate your api keys

The **regenerate key** is reserved for one specific action - to invalidate, and re-create the API keys we provided to you. This could come in handy if you are looking to implement a rotating key solution where you would like to invalidate the API key being used in your backend every x hours/days.

Note that, as soon as you regenerate the keys, your existing keys will be invalidated as soon as you retrieve your new keys. When you use the method, the response will contain a new set of three keys - store them securely!

Below you'll find an example on how to regenerate your API keys.

```typescript
import { Beam } from "@onbeam/node";

const beam = new Beam("x-regenerate-api-key");

const keys = beam.game.regenerateApiKeys();

// {
// "id": "string",
// "createdAt": "string",
// "updatedAt": "string",
// "name": "string",
// "description": "string",
// "coverImageUrl": "string",
// "logoImageUrl": "string",
// "chainIds": [
// 0
// ],
// "apiKeys": [
// {
// "type": "ReadOnly",
// "createdAt": "string",
// "apiKey": "string",
// },
// {
// "type": "ReadWrite",
// "createdAt": "string",
// "apiKey": "string",
// }
// {
// "type": "Regenerate",
// "createdAt": "string",
// "apiKey": "string",
// }
// ]
// }
```
44 changes: 44 additions & 0 deletions pages/service/game/introduction.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Game

Your game registration within Beam consists of information that is managed by Beam, and information manageable by you. When we register your api key, we'll also be in touch about the assets you want to register in your game. We can either provide contract templates for generic in-game currencies, but are also happy to help you with bridging over assets from one chain to another - be in touch!

Here are some of the key pieces of info you'll need to get started with implementing with Beam:

- [API keys](/service/game/api-keys): API keys and how to invalidate them

- [Managing contracts](/service/game/managing-contracts): Add and remove asset contracts to your game

- [Updating your game](/service/game-updating-game): Update information (name, visuals) of your game in the Beam Companion app

---

## Retrieving your game

If you're just interested in the currently resgistered information of your game in the Beam accounts API, simply call the `getGame` method. You'll find an example on how to do this below.

**Note:** we don't expose your API keys in this request, as we don't want people to accidentally expose them in application logs.

```typescript
import { Beam } from "@onbeam/node";

const beam = new Beam("x-api-key");

const game = await beam.game.getGame();

// {
// "id": "string",
// "name": "string",
// "contracts": [
// {
// "type": "ERC20",
// ...
// }
// ],
// "policies": [
// {
// "id": "string",
// ...
// }
// ]
// }
```
92 changes: 92 additions & 0 deletions pages/service/game/managing-contracts.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
## Managing contracts

If you want to run transactions for profiles that interact with specific contracts, the contract address will need to be registered for your game.

We provide a method for you to add any contract to your game, as long as you can provide us with the ABI and contract address. As adding a contract address to your game is probably a one time action that you won't repeat (a lot) over time, we can also recommend simply interacting with the hosted [Swagger UI](https://api.testnet.onbeam.com/api/game) to simply add the necessary contracts to you rgame.

---

### Asset data

At the moment of writing **you are (technically) required** to submit your asset contracts to Sphere in order for the SDK to be hydrated with data, since we use Sphere (our NFT marketplace) as the source for all asset related data.

https://testnet.sphere.market/

---

### Companion app

If you're using the [Beam Companion](/service/companion/introduction) app, it might be good to know that as soon as you add a contract to your game, all connected users to profiles of your game are able to see said contract in the [Beam Companion](/service/companion/introduction) app.

---

### Adding a contract

Adding a contract is as simple as calling the `addContractToGame` method.

```typescript
import { Beam } from "@onbeam/node";

const beam = new Beam("x-api-key");

const contract = beam.game.addContractToGame({
address: "string", // the deployed contract address
type: "ERC20", // ERC721, ERC1155
chainId: 13337, // 13337 for Beam testnet
name: "string", // The name of the asset contract, for example: 'Card Packs'

// the JSON abi for the contract, we recommend you grabbing it from the explorer if you have a deployed & verified contract
abi: [
{
name: "string",
type: "string",
anonymous: true,
payable: true,
constant: true,
stateMutability: "string",
gas: "string",
inputs: [
{
name: "string",
type: "string",
indexed: true,
internalType: "string",
components: ["string"],
},
],
outputs: ["string"],
},
],
});

// {
// "type": "ERC20",
// "id": "string",
// "createdAt": "string",
// "updatedAt": "string",
// "externalId": "string",
// "address": "string",
// "name": "string",
// "chainId": 0,
// "gameId": "string"
//}
```

### Deleting a contract

Removing a contract from your game is just as simple, simply use the `removeContractFromGame` method to remove it.

```typescript
import { Beam } from "@onbeam/node";

const beam = new Beam("x-api-key");

const contract = beam.game.removeContractFromGame({
address: "string", // the deployed contract address
chainId: 13337, // 13337 for Beam testnet
});

// {
// "success": true
//}
```
28 changes: 28 additions & 0 deletions pages/service/game/updating-game.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
## Updating your game

Some of the fields for your game's registration are being used in the Beam companion app. You can update through the `updateGame` method that's available on any of our [SDK's](/service/sdk) or by directly communicating with our [RESTful API](/service/full-api-reference)

---

### Companion app

If you're using the [Beam Companion](/service/companion/introduction) app, it might be good to know that as soon as you change the name or visuals of your game, all connected users to profiles of your game are able to see these changes in the [Beam Companion](/service/companion/introduction) app.

---

### Updating your game

Updating your game is as simple as calling the `updateGame` method.

```typescript
import { Beam } from "@onbeam/node";

const beam = new Beam("x-api-key");

await beam.game.updateGame({
name: "Your game's name",
description: "Lorem ipsum dolor...",
coverImageUrl: "ipfs://..",
logoImageUrl: "ipfs://..",
});
```
2 changes: 1 addition & 1 deletion pages/service/marketplace/introduction.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Callout } from "nextra/components";
In order to get a marketplace going, we offer various methods that can help you get started with listing assets.
Keep in mind that the marketplace itself is a pre-release product waiting to be released in Q4.

In order to create a full marketplace integration it is important to understand all of the possibilities that you have.
In order to create a full marketplace integration it is important to understand all of the possibilities that you have, here are some articles to get you started:

- [Currencies](/service/marketplace/currencies): Supported currencies in Beam marketplace

Expand Down
51 changes: 0 additions & 51 deletions pages/service/your-game.mdx

This file was deleted.

0 comments on commit 1e782c6

Please sign in to comment.