EOS RESOURCES
As we all know EOS is a transaction fee less platform. Even though for a user to execute a transaction on the blockchain he/she need to reserve some resources such as RAM and Bandwidth. In this blog, we will see how these resources can be accessed.
Both RAM and bandwidth have different purposes to meet. RAM is used to store your data in your blockchain and you have to purchase it. In case of bandwidth, you don't have to purchase but all you need is to just stake some EOS to get your bandwidth. You can unstake them whenever you wanted.
CREATING AN ACCOUNT
As per the latest update of EOS blockchain, the new account can be created only by an existing account holder. So he can initiate some RAM and stake, some bandwidth for the new account holder.
./cleos.sh system newaccount account1 account2 <public key 2> <public key 2> --stake-net "100.0000 EOS" --stake-cpu "100.0000 EOS" --buy-ram "100.0000 EOS"
account 1 - existing account
account 2 - new account name
Public key2 - public key of the new account
--stake-net "100.0000 EOS" - Staking Net bandwidth worth 100 EOS
--stake-cpu "100.0000 EOS" - Staking CPU bandwidth worth 100 EOS
--buy-ram "100.0000 EOS" - Purchasing RAM worth 100 EOS
Cost of these resources will vary as per market demand.
Now let's explore more in-depth.
RAM
For data to be stored in blockchain (Like deploying a smart contract), the required amount of RAM should be purchased. It can be done using ‘buyram’ command. You will get a number of bytes of RAM corresponding to the EOS you are spending. RAM price will vary as per market value.
RAM market is based on a ‘pool’ concept. You don't need to wait for a seller to buy your RAM. There will be a pool of RAM from which you can purchase it. Only thing you have to do is to spend some EOS coins. When the RAM available in the pool is plenty, the RAM price will fall and, raise when only few RAM is available. Today (6th July 2018), you will get 196.2388 KB of RAM for 100 EOS which is plenty for a normal user.
Now let's see the code for purchasing the RAM
./cleos.sh system buyram account1 account2 “100.0000 EOS”
account 1 - seller (Must have the mentioned 100 EOS coins with his account)
account 2 - buyer (Receives the RAM worth 100 EOS)
One can buy RAM for himself, if he has enough EOS within. In that case account1 and account2 will be same.
./cleos.sh system buyram account1 account1 “100.0000 EOS”
Each transaction consumes some amount of RAM. The user can sell the unused RAM to the RAM pool and get liquid EOS instantly. But the rate may vary as per the current RAM market price.
The code for selling the RAM is as follows
./cleos.sh system sellram account1 “bytes”
account1 - (sells the unused ram and receives liquid EOS )
Bytes- Number of bytes of RAM to be sold.
BANDWIDTH
There are two types of bandwidth, Network Bandwidth, and CPU Bandwidth.
Most often, both bandwidths are temporarily consumed while sending an action. It is calculated by taking the average consumption in last 3 days. The concept of Bandwidth is entirely different from RAM. There is no need of purchasing the bandwidth. All you need to do is delegate some EOS and reserve bandwidth as per the requirement.
Command for delegating bandwidth is as follows
./cleos.sh system delegatebw account1 account2 “100.0000 EOS” “10.0000 EOS”
account1 - account which delegates EOS
account2 - account which receives BW
Above mentioned first “100.000 EOS” is for network bandwidth and second “10.0000 EOS” is for CPU bandwidth.
One can stake EOS for reserving bandwidth for himself. In that case the command will be
./cleos.sh system delegatebw account1 account1 “100.0000 EOS” “10.0000 EOS”
What makes Bandwidth different from RAM is that, one who delegates the bandwidth can undelegate it at any time instance. It takes exactly 3 days(72 hours) to get converted back to liquid EOS while un delegating/unstaking the bandwidth.
Command for un delegating bandwidth will be like,
./cleos.sh system undelegatebw account1 account2 “10.0000 EOS” “10.0000 EOS”
account1- account undelegating
account2- account which has the bandwidth in it
It is to be noted that account1 has the authority to un delegate the bandwidth from account2, only if it has been delegated earlier from account1.