For helping in securely buying and selling in-game assets, you can use blockchain integration feature to add secured blockchain means to do those transactions. With it, brainCloud has the ability to back-up user items on blockchain.

Currently, brainCloud only supports EOS blockchain, if you have not set up your EOS blockchain account for your app, you can keep reading the following section - EOS Blockchain Account, otherwise, skip this part to section - Integration and Test.

EOS Blockchain Account

Before deploying your decentralized app on EOS MainNet, you can choose one of EOS testnet to test your EOSIO based application (such as Jungle Testnet, EOSIO Testnet...).

After you create an account on the Testnet, choose and stake a certain proper amount of RAM , CPU and NET for your account, brainCloud will deploy a pre-build EOS smart contract to your Testnet account once you publish a user-item to blockchain.

For a better understanding of how the Testnet interacts with a deployed smart contract, you should develop a smart contract and create some accounts to interact with the actions of this smart contract.

Since EOSIO software is developed in Linux based environments, if you are using a Windows system, you can use WSL to develop your EOS app with VS code remote WSL extension installed, so you can get into your code and edit them like local files.

Once you installed EOSIO and EOSIO.CDT on your machine, you can go ahead to create an EOS wallet and several accounts, run nodeos locally, create EOS smart contract etc. Once the contact .cpp file created, compile the contract with CDT command eosio-cpp, you should get .wasm file and .abi file.

eosio-cpp contractfilename.cpp -o contractfilename.wasm

Refer to EOSIO Developer Portal for more detail.

Then, you can deploy these two files to your Testnet account and test the contact actions from your Testnet.

Integration and Test

To get started with brainCloud part, find the Integrations - Blockchain page on brainCloud portal.

  • Check Enable Blockchain checkbox and fill in all the fields with your blockchain account info as above. (Currently, brainCloud only support EOS blockchain).

  • Navigate to Design | Cloud | API Explorer page, after authenticating a user, select Service Identity and Operation AttachBlockchainIdentity, put "blockchainConfig": "default" and the info of your EOS account publicKey. hit Run.

Note: In the future, brainCloud might have various blockchian configs setup, for now, you can ONLY use "default" as the config value.

  • Then run GetIdentities operation in the same service -- Identity. You should find your blockchain identity has been added to the list of current user identities.

  • Switch the Service to UserItems and select PublishUserItemToBlockchain Operation, put one of the current user's items info as the parameters, hit Run.

  • Now run GetUserItem with the same itemId as a parameter, check the returned response. You should find blockchain specific extra info blockItemId with blockPublishedAt from the return.

  • Now, go to your Testnet account, from the actions view history, you should find a create action with the account info that you set up on brainCloud integration blockchain page.

  • And from the transaction detail, you should find the user-item detail.

  • Check the detail of the deployed smart contract from the account -> smart contract.

{
"account_name": "koumpjyjucmq",
"abi": {
"version": "eosio::abi/1.1",
"types": [],
"structs": [
{
"name": "create",
"base": "",
"fields": [
{
"name": "app_id",
"type": "string"
},
{
"name": "block_owner_id",
"type": "name"
},
{
"name": "user_item_id",
"type": "string"
},
{
"name": "item_def_id",
"type": "string"
}
]
},
{
"name": "destroy",
"base": "",
"fields": [
{
"name": "block_item_id",
"type": "name"
}
]
},
{
"name": "item_ownership",
"base": "",
"fields": [
{
"name": "block_item_id",
"type": "name"
},
{
"name": "block_owner_id",
"type": "name"
}
]
},
{
"name": "ownership_details",
"base": "",
"fields": [
{
"name": "block_item_id",
"type": "name"
},
{
"name": "app_id",
"type": "string"
},
{
"name": "user_item_id",
"type": "string"
},
{
"name": "item_def_id",
"type": "string"
}
]
},
{
"name": "trade",
"base": "",
"fields": [
{
"name": "block_item_id",
"type": "name"
},
{
"name": "to",
"type": "name"
}
]
}
],
"actions": [
{
"name": "create",
"type": "create",
"ricardian_contract": "---\nspec-version: 0.0.2\ntitle: Create\nsummary: This action will create an entry in the multi-index table that establishes ownership of the given item to the given owner. The ram costs are paid by the smart contract.\nicon:"
},
{
"name": "destroy",
"type": "destroy",
"ricardian_contract": "---\nspec-version: 0.0.2\ntitle: Destroy\nsummary: This action will remove ownership of the given item from the current owner and clear the details of said item. Only the contract owner can execute the action. The ram costs are paid by the smart contract.\nicon:"
},
{
"name": "trade",
"type": "trade",
"ricardian_contract": "---\nspec-version: 0.0.2\ntitle: Trade\nsummary: This action will transfer ownership of the given item to the \"to\" owner. Only the current owner of the item can execute the action. The ram costs are paid by the smart contract.\nicon:"
}
],
"tables": [
{
"name": "bc.details",
"index_type": "i64",
"key_names": [],
"key_types": [],
"type": "ownership_details"
},
{
"name": "bc.owners",
"index_type": "i64",
"key_names": [],
"key_types": [],
"type": "item_ownership"
}
],
"ricardian_clauses": [
{
"id": "Data Storage",
"body": "---\nspec-version: 0.0.1\ntitle: General Data Storage\nsummary: This smart contract will store data added by the brainCloud BaaS. The owner consents to the storage of this data by signing the transaction.\nicon:"
},
{
"id": "Data Usage",
"body": "---\nspec-version: 0.0.1\ntitle: General Data Use\nsummary: This smart contract will store item and user data. The smart contract will not use the stored data for any purpose outside store and delete.\nicon:"
},
{
"id": "Data Ownership",
"body": "---\nspec-version: 0.0.1\ntitle: Data Ownership\nsummary: The user of this smart contract verifies that the data is owned by the smart contract, and that the smart contract can use the data in accordance to the terms defined in the Ricardian Contract.\nicon:"
},
{
"id": "Data Distribution",
"body": "---\nspec-version: 0.0.1\ntitle: Data Distribution\nsummary: The smart contract promises to not actively share or distribute the address data. The user of the smart contract understands that data stored in a multi index table is not private data and can be accessed by any user of the blockchain.\nicon:"
},
{
"id": "Data Future",
"body": "---\nspec-version: 0.0.1\ntitle: Data Future\nsummary: The smart contract promises to only use the data in accordance of the terms defined in the Ricardian Contract, now and at all future dates.\nicon:"
}
],
"error_messages": [],
"abi_extensions": [],
"variants": []
}
}

  • Notice there is an action called "destroy" , which will be invoked from brainCloud when calling RemoveUserItemFromBlockchain API.

  • Now the item is backed up to blockchain with a blockchain Transaction ID and Block Number.

Did this answer your question?