RAM (Random Access Memory) is an amount of memory for data storage (e.g.
stores account names, keys, balances, contract status) in EOSIO blockchain.
RAM is the finite resource, its amount is defined by max_ram_size (64 GiB) in the contract eosio.system. To get the necessary memory amount to store your info data in the blockchain in KiB you need to buy it.
There is a domestic RAM market for buying and selling, where current RAM price in relation to EOS tokens is automatically adjusted by Bancor algorithm (supply and demand). The less amount of RAM is available for purchase, the higher its price is and the greater incentive is for selling RAM. If RAM price keeps growing till EOSIO blockchain usage becomes unprofitable, more RAM can be added by the Consensus of the BPs(15 from 21), who are RAM suppliers in fact.
That would expand the RAM amount available to buy & thus would decrease the price.
[The decision to double RAM amount was made of 26/07/2018 ( 64GiB to 128 GiB).
The RAM expansion is implementing gradually, every block produced adds 1 KiB to RAM (that is 168,75MiB per a day) till the total amount will make 128 GiB].
RAM cannot be transferred between accounts.
Users can only buy RAM from the system of sell it back through the contract eosio.system by the following actions.
To buy 10 KiB
• cleos system buyram payer_account receiver_account --kbytes 10
Or buy RAM on 1 EOS
• cleos system buyram payer_account receiver_account "1 EOS"
A contract in the eosio system uses revenues from selling RAM to ensure the liquidity for those who want to sell RAM.
When buying RAM on payer account, an eos-token payment goes into the system contract, and a receiver is the only one who can sell the RAM bought (payer_account and receiver_account can be of the same account).
Every time one buys or sells RAM, transaction fees makes of 0.5% for each. The fee raised in eos-tokens is withdrawn from service and destroyed.
To sell RAM
• cleos system sellram receiver_account 10240
Note: Amount is indicated in bytes
Account data storage
3 KiB needed to make a new account.
[Since the decision of update of 06.11.2018 by 15 from 21 BPS 3 KiB instead of 4 KiB is enough to create a new account.]
To create an account by the following action:
cleos ./cleos.sh system newaccount --stake-net "0.1 EOS" --stake-cpu "0.1 EOS" --buy-ram-kbytes 3 payer_account new_account_name owner_key_newaccount active_key_newaccount
payer_account (current account) provides payment in eos-tokens, in accordance with current market prices at that very moment, for 3 KiB RAM to a system-contract.
New memory is allocated for a new account in the EOSIO blockchain (for new account data storage).
quota: 2.978 KiB used: 2.926 KiB
Note: if you make& try new account creation with less amount of KiB, error appears.
Error: Account using more than allotted RAM usage
That is due to min 3 KiB set for an account in EOSIO.
Shortly the update is announced with 1.5 KiB required for a new account creation [Daniel Larimer’s post].
Smart account status storage
To develop your smart contract on EOSIO [https://steemit.com/blockchain/@attic-lab/eos-smart-contracts]
RAM amount is needed dependent on a file size of the smart contract code.
While a smart contract file updating, its new version adopts the new amount of ram in use and is automatically changeable.
The ram amount required for a smart account data storage depends on the size of a future smart contract table structure and a size of data obtained.
A data size you need to store in the blockchain could be roughly gauged by figuring a table structure size and multiplying on an expected table size( approximate amount of KiB/MiB you need to buy for a proper smart contract management, a rough approximation price).
That’s why it’s essential to estimate the time required and which data exactly to store in the EOSIO blockchain.
Telegram Chat: https://t.me/atticlabeosb
Telegram channel: https://t.me/eos_atticlab