-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into chore/clean-up-roadmap
- Loading branch information
Showing
8 changed files
with
223 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
// } | ||
// ] | ||
// } | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
// ... | ||
// } | ||
// ] | ||
// } | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
//} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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://..", | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.