Closer Look at LiquidApps and vRAM

Attic Lab
Attic Lab
Published in
4 min readFeb 20, 2019

A little less than a month ago LiquidEOS announced the launch of LiquidApps, the project that is aimed to solve the issue of RAM prices. One of the key concepts of LiquidApps is vRAM, an alternative system for storing data on the EOS blockchain and a replacement of multi-index tables for developers.

We decided to have a closer look at how the project works and its key components. Here’s what we were able to find out. Note that all the examples provided in the article were used in the Kylin Testnet.

dApp developers

For the dApp developer to gain access to data storages (vRAM) provided by DSP’s (dApp service provider), he needs to include vRAM library into his smart contracts. More examples of smart contracts can be found here https://github.com/liquidapps-io/zeus-coldtoken-sample, https://github.com/liquidapps-io/vgrab.

The next step is to select a data package provided by a specific DSP and stake DAPP tokens from the smart contract to a specific DSP data storage and the selected DSP package.

Examples of commands for using vRAM in Kylin Testnet are provided later in the article.

dApp Service Providers

The account dApp Service Provider (DSP) provides a server with a running DSP node. The DSP node is also connected to the EOS node that uses state_history_plugin. All the vRAM data is always stored in the chain history and is available for reconstruction.

For the EOS node add the following data to config.ini

plugin = eosio::state_history_plugin

state-history-endpoint = 0.0.0.0:8889

trace-history = true

The DSP node uses a standard API endpoint of the EOS blockchain that receives all the transactions/actions that are sent to the dApp smart contract. The dApp smart contract with the vRAM library allows storing smart contract data in the temporary cache multi-index table in RAM. Each time when the dApp client calls a smart contract action, the DSP node checks if there is data in RAM for executing the action. If the required cache data is not found, the DSP node sends current data to the dApp smart contract thus executing a warmup operation. The dApp smart contract after verifying the validity of the data writes it into the cache table in RAM.

Once the result is used and sent, the temporary data of the cache table is removed from RAM. The DSP node continuously monitors the change history and stores up-to-date versions of data in the local IPFS cluster. It is necessary for the DSP account to have EOS staked for CPU to execute the warmup operation and write data into RAM.

Registering as DSP

  • Create an account for DSP, in this example: your_dsp_account
  • Account DSP requires staked EOS for the on-chain CPU

cleos system delegatebw your_dsp_account your_dsp_account “10 EOS” “10 EOS”

  • Register your provider with the IPFS DAPP service

cleos push action ipfsservice1 regprovider ‘{“provider”:”your_dsp_account”,”model”:{“model”:{“commit_model_field”:{“cost_per_action”:1},”cleanup_model_field”:{“cost_per_action”:1},”warmup_model_field”:{“cost_per_action”:1}},”endpoint”:”http://” }}’ -p your_dsp_account@active

  • Register your pricing package

Note: each DSP sets their own conditions of performance and availability of packages for users.

cleos push action dappservices regpkg ‘{“newpackage”:{“id”:0,”package_id”:”default”,”service”:”ipfsservice1",”provider”:”your_dsp_account”,”quota”:”100.0000 DAPP”, “package_period”:”100",”min_stake_quantity”:”1.0000 DAPP”,”min_unstake_period”:1,”enabled”:true}}’ -p your_dsp_account@active

All the registered packages:

https://kylin.eosx.io/account/dappservices?mode=contract&sub=tables&table=package&lowerBound=&upperBound=&limit=100

Registering dAPP

  1. Create an account for the dApp smart contract, in this example: your_dapp_contract.
  2. Set permission

cleos set account permission your_dapp_contract active ‘{“threshold”: 1,”keys”: [{“key”: “your_active_key”,”weight”: 1}],”accounts”: [{“permission”:{“actor”:”your_dapp_contract”,”permission”:”eosio.code”},”weight”:1}]}’ owner -p your_dapp_contract@owner.

3. Select a DSP Service Package/s that satisfies the initial dApp data storage and access requirements.

cleos push action dappservices selectpkg ‘{“owner”:”your_dapp_contract”,”service”:”ipfsservice1", “provider”:”dsp_account”, “package”:”default”}’ -p your_dapp_contract@active

4. Get DAPP Tokens. You can either buy them once the mainnet is up or in case of the testnet request them from admins in the LiquidApps telegram group.

5. Stake the DAPP Tokens from your contract towards a specific DSP data storage and access the package/s selected.

cleos push action dappservices stake ‘{“from”:”your_dapp_contract”,”service”:”ipfsservice1", “provider”:”dsp_account”, “quantity”:”100.0000 DAPP”}’ -p your_dapp_contract@active

‘Quantity’ is the amount of DAPP Tokens required in each smart contract to accommodate the dApp’s read/write needs. Note that it has to match the selected DSP package requirements. dApp developer can stake more tokens than the amount required to vote for a specific DSP. I should be mentioned though that as of now the whole mechanics of voting and rewarding is not totally clear and will be announced later.

Smart contract example: https://github.com/liquidapps-io/zeus-coldtoken-sample

6. Set the contract.

cleos set contract your_dapp_contract /path/to/contract/coldtoken

Actions

use Scatter

https://kylin.eosx.io/tools/contract?sub=interfaces&contractAccount=your_dapp_contract

use cleos

cleos push action your_dapp_contract create ‘{“issuer”:”your_dapp_contract”,”maximum_supply”:”1000.0000 some_token_name”}’ -p your_dapp_contract@active

cleos push action your_dapp_contract issue ‘{“to”:””,”quantity”:”100.0000 some_token_name”,”memo”:””}’ -p your_dapp_contract@active

cleos push action your_dapp_contract transfer ‘{“from”:””,”to”:””,”quantity”:”100.0000 some_token_name”,”memo”:””}’ -p @active

vRAM library actions

xsignal

cleos push action your_dapp_contract xsignal ‘{“service”:””,”action”:””,”provider”:””,”signalRawData”:””}’ -p your_dapp_contract

xwarmup

cleos push action your_dapp_contract xwarmup ‘{“current_provider”:””,”size”:”1",”uri”:””,”data”:””}’ -p your_dapp_contract

xcommit

cleos push action your_dapp_contract xcommit ‘{“current_provider”:””,”size”:””,”uri”:””}’ -p your_dapp_contract

xlogevent

cleos push action your_dapp_contract xlogevent ‘{“current_provider”:””,”size”:””,”reciept”:””}’ -p your_dapp_contract

xcleanup

cleos push action your_dapp_contract xcleanup ‘{“current_provider”:””,”size”:””,”uri”:””}’ -p your_dapp_contract

xlogclear

cleos push action your_dapp_contract xlogclear ‘{“current_provider”:””,”size”:”1",”reciept”:””}’ -p your_dapp_contract

Sources:

https://www.liquidapps.io

https://www.liquidapps.io/DAPP%20Network%20and%20DAPP%20Token%20Whitepaper%20v1.1.pdf

https://github.com/liquidapps-io

Follow us!

Website: http://atticlab.net/eos/
Twitter: https://twitter.com/atticlab_it
Facebook: https://www.facebook.com/atticlab/
Reddit: https://www.reddit.com/user/atticlab_it
Steemit: https://steemit.com/eos/@attic-lab
Medium: https://medium.com/eosatticlab
Golos: https://golos.io/@atticlab
Telegram Chat: https://t.me/atticlabeosb

--

--