API Royale

API Royale allows ROY ecosystem apps and games to interact with Crypto Royale in-game wallets, bypassing the Blockchain. This has several advantages:

To use API Royale, ecosystem devs need to:

  1. Set-up Discord authentication on their end, (CR uses Discord IDs as reference)
  2. Set-up an API account (done manually at the moment, contact us)
  3. Direct users to https://cryptoroyale.one/apps where they can give your app permission to access their wallet.

Info needed to set-up an API account:

In return you will receive a key that is needed for all API calls. This key must be held securely at all times. Make sure to not share it with anyone. If your key is compromised, please contact us immediately.

API Endpoints

POST /api/royale/decrement

Description: Transfer funds from user wallet to API wallet. Only possible if your API has been given the decrement permission by the user. Decrement calls are taxed by Crypto Royale at 0.5%. e.g. a 100 ROY decrement will result in 99.5 ROY showing up in your API balance.

Body parameters:

Return Messages and HTTP codes:

Body Example:

{
    "key": "d7e60d03-5121-4d37-926e-daaa9a1ef5ca",
    "amount": 100,
    "discordid": "85405022041071626",
    "reason": "test-decrement",
    "data": {"howdy": "sir"},
    "nonce": "7"
}

POST /api/royale/increment

Description: Transfer funds from API wallet to user wallet. Only possible if your API has been given the increment permission by the user.

Body parameters:

Return Messages and HTTP codes:

Body Example:

{
    "key": "d7e60d03-5121-4d37-926e-daaa9a1ef5ca",
    "amount": 50,
    "discordid": "85405022041071626",
    "reason": "test-incremenent",
    "data": {"howdy": "sir"},
    "nonce": "332"
}

POST /api/royale/balance

Description: Check how much ROY is in your API wallet. All increments and decrements happen between user wallets and your API wallet. If your API wallet reaches 0, you will not be able to increment user wallets anymore. Your API balance will NOT be immediately withdrawable, to give user's adequate time to report any incorrect charges.

Body parameters: Return Messages and HTTP codes:

Body Example:

{
    "key": "d7e60d03-5121-4d37-926e-daaa9a1ef5ca",
}

POST /api/royale/userbalance

Description: Check how much ROY is in a user's wallet. Only possible if your API has been given the userbalance permission by the user.

Body parameters:

Return Messages and HTTP codes:

Body Example:

{
    "key": "d7e60d03-5121-4d37-926e-daaa9a1ef5ca",
    "discordid": "85405022041071626"
}

POST /api/royale/userpermissions

Description: Check which permissions your app has been given, by a specific user. Ideally your app should degrade its UX gracefully, if less permissions are given than expected. For example, do not show a user's balance in your own app if the balance permission is not available.

Body parameters:

Return Messages and HTTP codes:

Body Example:

{
"key": "d7e60d03-5121-4d37-926e-daaa9a1ef5ca",
"discordid": "85405022041071626"
}

Response Example:

{
	"msg": "User Permissions retrieved",
	"data": {
		"permissions": [
			{
				"type": "balance",
				"value": false
			},
			{
				"type": "decrement",
				"value": false
			},
			{
				"type": "increment",
				"value": false
			}
		]
	}
}

POST /api/royale/incrementVP

Description: Give user Victory Points. Uses ROY from your API Balance at the current VP:ROY conversion rate. Only possible if your API has been given the skin AND increment permissions by the user.

Body parameters:

Return Messages and HTTP codes:

Body Example:

{
"key": "d7e60d03-5121-4d37-926e-daaa9a1ef5ca",
"amount": 100,
"discordid": "85405022041071626",
"skin": "cherry",
"enemies": 4000,
}

POST /api/royale/userequippedskin

Description: Check which skin a user has currently equipped. Only possible if your API has been given the skin permission by the user.

Body parameters:

Return Messages and HTTP codes:

Body Example:

{
"key": "d7e60d03-5121-4d37-926e-daaa9a1ef5ca",
"discordid": "85405022041071626"
}

POST /api/royale/incrementVP

Description: Give user Victory Points. Make sure to give a reasonable amount compared to other ecosystem games and the main game. Rough guideline: Do not exceed 1K VP per minute of playtime on average.. Only possible if your API has been given the skin AND increment permissions by the user.

Body parameters:

Return Messages and HTTP codes:

Body Example:

{
"key": "d7e60d03-5121-4d37-926e-daaa9a1ef5ca",
"amount": 100,
"discordid": "85405022041071626",
"skin": "cherry",
"enemies": 4000,
}

POST /api/royale/incrementZone

Description: Transfer ROY from your API account to your app's Skin Wars Zone, if you have one. Increasing your Skin Wars Zone will make it more attractive to players, as well as move it up the Zone leaderboard for additional exposure. Your zone's prize pool will be reset to its starting amount every day when the war resets.

Body parameters:

Return Messages and HTTP codes:

Body Example:

{
"key": "d7e60d03-5121-4d37-926e-daaa9a1ef5ca",
"amount": 100,
"nonce": "5032",

}

POST /api/royale/mintSkin

Description: Mint a skin managed by your app directly into a user's account. This does not charge the user any ROY, so make sure to do so seperately beforehand, if the mint is not meant to be free.

Body parameters:

Return Messages and HTTP codes:

Body Example:

{
"key": "d7e60d03-5121-4d37-926e-daaa9a1ef5ca",
"discordid": "85405022041071626",
"nft_id": 134,
"nonce": "5032",

}