Unreal Engine
General information
These assets are created as an example of working with the COFFE blockchain for developers. They demonstrate the ability to quickly write, store and read blockchain data and to use it in FPS applications. They also show the possibilities of crypto payments in games. In the near future, samples for VR will also be added as well as samples for creating 3D and VR ready NFT tokens and for using them in dapp.
You can download these assets at the link: https://coffe.io/files/samples/ue4sample.zip The asset is made in a standard UE4 room. The sample content is located in the folder named IO_sample
BP_3D_WidgetSocketIO are blueprints with a demonstration of connecting and working with the COFFE multichain network. W_SocketIO is an example of visualization on a widget.
an Account name input field and a ‘Connect’ button a Text input field for saving to blockchain and an ‘Add Action’ button a ‘Transfer’ button for sending tokens within the COFFEE network a ‘Get table’ button to read the table from the blockchain a ‘Clear action’ button is an example of clearing data in a contract ATTENTION! Clearing data does not remove data from blocks. Any data that you record on the blockchain ALWAYS remains on the blockchain. The table can be cleaned up, but data is has been filled in with can always be recovered by reading the blocks. Consider this fact when developing blockchain applications. ISSUES: You need have VS19 to compile third part plugins. Pls look it the link how to install and setup it:
Multichain Login blueprint
Go to blueprint and search for ‘connecting with your Account in COFFE to DAPP’.
Each user must be assigned with a 24-digit ID upon logging on to the network. You also need to subscribe to notifications for your ID. A how-to-do-this guide you can find at the link:
Next, send an authorization request. The parameters must contain the client ID, the Dapp account (that will be used for operations), and the username. Replace the Dapp variable with the name of your smart contract. In this example, it is accountname1. Information from the username input field are read into the User variable, which is the name of the account that interacts with the smart contract. To test an application, you need another account to connect to your application as a user. How to create an account was described earlier.
Launch the application and enter the created new user account.
Click ‘Connect’. You need to confirm the connection in CFFswop_bot
Call smart contract action
This blueprint performs the injectdata action in the smart contract. Form data in the form of json to transfer it to the blockchain. For a trial run, enter the name of your account with a smart contract:
Run the asset. Log in (see 2.2.). Enter ‘Hello COFFE’ in the text box and click the Add action button.
In the CFFswop_bot, the account on whose behalf you need to confirm.
When you receive a notification in the bot, carefully check that it matches your request. You must confirm the action or refuse it within 20 seconds. If the action being performed is not related to the transfer of tokens, then it can be added to the whitelist for automatic confirmation by the bot. This can be useful if your game provides for a regular action of collecting resources or attacking, improving, hiring, etc.
Account: accountname1 ------- write the name of the smart contract with which the user will interact. Name: injectdata ---------write the name of the action in the smart contract, the execution of which the user signs with his account. Data: {“from”: “abcdefghigkl”, “value”: “HELLO COFFE”} ------- write a json object with the data you are passing to the contract.
Read data from block
Set in the fields code and scope: accountname1, which is the contract in which the search is performed. Table -> testtable, a table for finding data. ‘Lower and upper bounds’ stand for the lower and upper bounds of the search, ‘limit’ is the number of requested records.
Take a look at the URL link to the API:
This is the blockchain history access API. Documentation on queries can be found here:
The History Server uses Hyperion software, the full documentation on which can be found here:
Run the asset and click ‘Get table’. In response, you will receive 10 records from the table.
Clear data action
Let’s take a look at the cleandata action to delete data from the testable as an example of another action in a contract.
Set the name of our smart contract: accountname1. Launch the asset and connect as your test user. Then click the ‘Clear action’ button.
Go to CFFswop_bot and confirm the action.
https://coffe.bloks.io/transaction/1db03bb95f0082c7b21293879001c942176693ff0473a745d8a5bae96ed40048
Go to accountname1 in the block explorer:
https://coffe.bloks.io/account/accountname1
In the screenshot above is shown that the user abcdefghigkl has performed the cleandata action in the smart contract accountname1.
If you go to the contract tab, then in the testtable you can see the lack of results. The table has been cleaned.
In smart contracts, it is possible to restrict the rights of users to perform certain actions, for example, to create an action that can only be performed by an account with the appropriate rights.
Pay request tokens transfer
And finally, the most interesting action which is sending tokens. The COFFE network has test-tokens for developers and testers. You can get them for free. To do this, go to the CFFswop_bot and type ‘h’.
‘wallet’ > ‘get 500 usdtest’
https://coffe.bloks.io/transaction/983eb897390c001a56cb44dfeea8f210fa28d9c8d9a3a8e2ad5768302e60271d
You will see the USDTEST token on your account balance.
There are no swaps for this token and it cannot be taken out of the network, but it can be used to test the mechanics of player monetary rewards, distribution of rewards across various pools, purchases in your smart contract, and more.
Let’s take a closer look at sending usdtest to the smart contract accountname1 in the screenshot. Set parameters:
o: accountname1 ------ write an account to which tokens will be sent quantity: 1.0000 USDTEST ----- write the number of tokens to be sent and the token symbol (all decimal places must be indicated. If the token has 4 decimal places, then all 4 must be specified, even if they are zeros). Memo: my memo ----- write the text that will be recorded in the transfer action. Token Account: toenrerere1 ----- write the account on which the smart contract of an usdtest token is to be recorded. If you would like to use your own token on the COFFE network, this is where you enter your account name where your token is issued.
Launch the asset, log in from the test account and press the ‘transfer’ button. Go to CFFswop_bot and check your data. Confirm the transaction.
https://coffe.bloks.io/transaction/8cdff068d672c1cc64135f18a2e9a1afb9227b5300588ad5e436e1c04b99053b
Go to accountname1 in the block explorer:
https://coffe.bloks.io/account/accountname1
Account abcdefghigkl transferred 1 USDTEST token with memo "my memo" to smart contract accountname1. How it can be useful: A smart contract can accept payment for units, ammunition, boosts, NFT tokens, etc. from a user. In a smart contract, you can verify that the sent token is indeed issued by a specific smart contract of the token and is not a fake. Memo can be used to identify a purchase, for example
Here, the player marquinadani performed a USDT token transfer with a memo ‘unit:1:1:mage’ to buy 10 wizard units.
Smart contracts can include the logic of distribution of the received resources from a player, for example, to distribute the daily profit among other players.
Or distribute the money received from a player across different distribution pools, for example
Here, the contract distributes funds from the purchase of a unit, returns part of the money to the player as change after calculating the value of the unit in the purchase token. Part of the money is sent to the accumulative prize pool, some part is sent to the team's account, some part is sent to those who keep the CFF token in the stake.
You can use absolutely any economic and financial model as a base of the contract.
As you can see, accepting payments in cryptocurrency is no more difficult than accepting fiat payments. The main advantage of the COFFE network is that any tokens of any networks connected to our network can be used for payments. It will allow you to engage the entire audience, and not just the audience of a specific network. COFFE MULTICHAIN is an official member of the Blockchain Game Alliance. The network is integrated into the dapp.com radar platform. The CFF network token is traded on our decentralized exchange https://coffe.one and on the https://p2pb2b.io exchange. If you have any questions, you can always ask them in the network chat https://t.me/coffeofficialgroup For commercial offers use the team@coffe.io e-mail COFFE multichain is included in the official eosio documents and is being developed as an independent branch of eosio software with its own consensus and a number of changes.