EOS RAM and Bandwith Analysis: Airdropping steps on Junglenet

in #eos6 years ago (edited)

I was studying about EOS RAM Allocation, CPU and NET bandwith and I was wondering about how much it costs to organize a real airdrop. So I just came up with this small experiment in Jungle testnet which can be totally adapted to Mainnet, because the storage and bandwith are the same you can just adjust the current EOS and RAM prices.

It's actually super simple to Airdrop a token in EOS <3

  1. Create an account for your smart contract
  2. Download the official eosio.token from eos repository
  3. Compile and deploy it to your contract
  4. Create your token symbol and supply
  5. Start issuing tokens

I'm going to cover all the above steps below, let's go!

EOS AirDropping
Getty Images

Default Account creation on Junglenet

Created account eosairdroper from http://dev.cryptolions.io/#account

Here's the initial account balance and stake stats:

$ cleos get account eosairdroper
permissions:
     owner     1:    1 EOS84uT4DBAJQpagWDfZPbk2hd9aaH8ZGZUxHTrpdjCqCzMEVP8cB
        active     1:    1 EOS84uT4DBAJQpagWDfZPbk2hd9aaH8ZGZUxHTrpdjCqCzMEVP8cB
memory:
     quota:     623.2 Kb     used:     3.365 Kb

net bandwidth:
     staked:        100.0000 EOS           (total stake delegated from account to self)
     delegated:       0.0000 EOS           (total staked delegated to account from others)
     used:                 0 bytes
     available:        19.29 Mb
     limit:            19.29 Mb

cpu bandwidth:
     staked:        100.0000 EOS           (total stake delegated from account to self)
     delegated:       0.0000 EOS           (total staked delegated to account from others)
     used:                 0 us
     available:        3.862 sec
     limit:            3.862 sec

Deploying the eosio.token contract

Simple deploy from original EOS Repo without any changes:

$ cleos set contract eosairdroper ~/eos/build/contracts/eosio.token ~/eos/build/contracts/eosio.token/eosio.token.wast ~/eos/build/contracts/eosio.token/eosio.token.abi
Reading WAST/WASM...
Assembling WASM...
Publishing contract...
executed transaction: d4025c7627d3a8334451ca382be86867eed55f2a442205ac269db8d4228554ca  8496 bytes  3203 us
#         eosio <= eosio::setcode               {"account":"eosairdroper","vmtype":0,"vmversion":0,"code":"0061736d01000000017e1560037f7e7f0060057f7...
#         eosio <= eosio::setabi                {"account":"eosairdroper","abi":"0e656f73696f3a3a6162692f312e30010c6163636f756e745f6e616d65046e616d6...

# >>>> checking account stats <<<<
$ cleos get account eosairdroper
permissions:
     owner     1:    1 EOS84uT4DBAJQpagWDfZPbk2hd9aaH8ZGZUxHTrpdjCqCzMEVP8cB
        active     1:    1 EOS84uT4DBAJQpagWDfZPbk2hd9aaH8ZGZUxHTrpdjCqCzMEVP8cB
memory:
     quota:     623.2 Kb     used:     189.7 Kb

net bandwidth:
     staked:        100.0000 EOS           (total stake delegated from account to self)
     delegated:       0.0000 EOS           (total staked delegated to account from others)
     used:             8.298 Kb
     available:        19.28 Mb
     limit:            19.29 Mb

cpu bandwidth:
     staked:        100.0000 EOS           (total stake delegated from account to self)
     delegated:       0.0000 EOS           (total staked delegated to account from others)
     used:             1.817 ms
     available:         3.86 sec
     limit:            3.862 sec

Balance stats:

  • Used RAM: 186.335 Kb (From 3.365 Kb, To 189.7 Kb)
  • Used NET: 8.298 Kb (From 0 Kb, To 8.298 Kb)
  • Used CPU: 1.817 ms (From 0 ms, To 1.817 ms)

Yeah, the cost to deploy eosio.token is 186.335 Kb with today's version! Ok, the fun begins... Let's create a token!

Creating a token

Default token, 1 billion supply and four decimals exactly like EOS.

$ cleos push action eosairdroper create '[ "eosairdroper", "1000000000.0000 TOKEN", 0, 0, 0]' -p eosairdroper
executed transaction: 7123c8e34853205b9176a8d02526a570f32e908212f0a3eff7e9dd9544803101  120 bytes  738 us
#  eosairdroper <= eosairdroper::create         {"issuer":"eosairdroper","maximum_supply":"1000000000.0000 TOKEN"}

# >>>> checking account stats <<<<
$ cleos get account eosairdroper
permissions:
     owner     1:    1 EOS84uT4DBAJQpagWDfZPbk2hd9aaH8ZGZUxHTrpdjCqCzMEVP8cB
        active     1:    1 EOS84uT4DBAJQpagWDfZPbk2hd9aaH8ZGZUxHTrpdjCqCzMEVP8cB
memory:
     quota:     623.2 Kb     used:       190 Kb

net bandwidth:
     staked:        100.0000 EOS           (total stake delegated from account to self)
     delegated:       0.0000 EOS           (total staked delegated to account from others)
     used:             8.314 Kb
     available:        19.28 Mb
     limit:            19.29 Mb

cpu bandwidth:
     staked:        100.0000 EOS           (total stake delegated from account to self)
     delegated:       0.0000 EOS           (total staked delegated to account from others)
     used:             2.656 ms
     available:        3.859 sec
     limit:            3.862 sec

Balance stats:

  • Used RAM: 0.3 Kb (From 189.7 Kb, To 190 Kb)
  • Used NET: 0.016 Kb (From 8.298 Kb, To 8.314 Kb)
  • Used CPU: 0.839 ms (From 1.817 ms, To 2.656 ms)

Neat! To create a token we spent very little resources, almost nothing...

Issuing some Tokens

Now let's airdrop some tokens!

I'm using some random accounts from the official snapshot (sorry if you are one of them):

accountsnapshot balance
gm4domrtgqge12.6521 EOS
gu2dkmztgage606.0000 EOS
gu2dgmrrguge6233.0000 EOS
gu2dgmrshege15000.9383 EOS
ge3tgmzxhege172150.0000 EOS
cleos push action eosairdroper issue '["gu2dgmrshege", "15000.9383 TOKEN", "airdrop"]' -p eosairdroper
executed transaction: f81bf85f5fe51e2bb78e8f3398e384b17587d1abb21255ca4e5dc64874fac263  128 bytes  2467 us
#  eosairdroper <= eosairdroper::issue          {"to":"gu2dgmrshege","quantity":"15000.9383 TOKEN","memo":"airdrop"}
#  eosairdroper <= eosairdroper::transfer       {"from":"eosairdroper","to":"gu2dgmrshege","quantity":"15000.9383 TOKEN","memo":"airdrop"}
#  gu2dgmrshege <= eosairdroper::transfer       {"from":"eosairdroper","to":"gu2dgmrshege","quantity":"15000.9383 TOKEN","memo":"airdrop"}

cleos get account eosairdroper
permissions:
     owner     1:    1 EOS84uT4DBAJQpagWDfZPbk2hd9aaH8ZGZUxHTrpdjCqCzMEVP8cB
        active     1:    1 EOS84uT4DBAJQpagWDfZPbk2hd9aaH8ZGZUxHTrpdjCqCzMEVP8cB
memory:
     quota:     623.2 Kb     used:     190.2 Kb

net bandwidth:
     staked:        100.0000 EOS           (total stake delegated from account to self)
     delegated:       0.0000 EOS           (total staked delegated to account from others)
     used:             8.346 Kb
     available:        19.28 Mb
     limit:            19.29 Mb

cpu bandwidth:
     staked:        100.0000 EOS           (total stake delegated from account to self)
     delegated:       0.0000 EOS           (total staked delegated to account from others)
     used:             3.787 ms
     available:        3.858 sec
     limit:            3.862 sec

Balance stats:

  • Used RAM: 0.2 Kb (From 190 Kb, To 190.2 Kb)
  • Used NET: 0.032 Kb (From 8.314 Kb, To 8.346 Kb)
  • Used CPU: 1.131 ms (From 2.656 ms, To 3.787 ms)

More Tokens Issuing

cleos push action eosairdroper issue '["gu2dgmrrguge", "6233.0000 TOKEN", "airdrop"]' -p eosairdroper
executed transaction: 26a0477eaa5147e454a0a2c4c436ae5d4b356deddc303d4a0ad43108c3480307  128 bytes  2122 us

$ cleos get account eosairdroper
permissions:
     owner     1:    1 EOS84uT4DBAJQpagWDfZPbk2hd9aaH8ZGZUxHTrpdjCqCzMEVP8cB
        active     1:    1 EOS84uT4DBAJQpagWDfZPbk2hd9aaH8ZGZUxHTrpdjCqCzMEVP8cB
memory:
     quota:     623.2 Kb     used:     190.4 Kb

net bandwidth:
     staked:        100.0000 EOS           (total stake delegated from account to self)
     delegated:       0.0000 EOS           (total staked delegated to account from others)
     used:             7.506 Kb
     available:        19.28 Mb
     limit:            19.29 Mb

cpu bandwidth:
     staked:        100.0000 EOS           (total stake delegated from account to self)
     delegated:       0.0000 EOS           (total staked delegated to account from others)
     used:             5.567 ms
     available:        3.856 sec
     limit:            3.862 sec

$ cleosjn push action eosairdroper issue '["gu2dkmztgage", "606.0000 TOKEN", "airdrop"]' -p eosairdroper
executed transaction: a642adfaf2a715e7bf9a8ecb2d9f8cd1cbc4925ffb7edbbbe1c78b77383de487  128 bytes  2291 us

$ cleos get account eosairdroper
permissions:
     owner     1:    1 EOS84uT4DBAJQpagWDfZPbk2hd9aaH8ZGZUxHTrpdjCqCzMEVP8cB
        active     1:    1 EOS84uT4DBAJQpagWDfZPbk2hd9aaH8ZGZUxHTrpdjCqCzMEVP8cB
memory:
     quota:     623.2 Kb     used:     190.7 Kb

net bandwidth:
     staked:        100.0000 EOS           (total stake delegated from account to self)
     delegated:       0.0000 EOS           (total staked delegated to account from others)
     used:             7.443 Kb
     available:        19.28 Mb
     limit:            19.29 Mb

cpu bandwidth:
     staked:        100.0000 EOS           (total stake delegated from account to self)
     delegated:       0.0000 EOS           (total staked delegated to account from others)
     used:             7.719 ms
     available:        3.854 sec
     limit:            3.862 sec

cleos push action eosairdroper issue '["gm4domrtgqge", "12.6521 TOKEN", "airdrop"]' -p eosairdroper
executed transaction: 6a9695ba0508bb967b08341794ba49a597276971d2c34f7178a06db089b39943  128 bytes  2326 us

$ cleos get account eosairdroper
permissions:
     owner     1:    1 EOS84uT4DBAJQpagWDfZPbk2hd9aaH8ZGZUxHTrpdjCqCzMEVP8cB
        active     1:    1 EOS84uT4DBAJQpagWDfZPbk2hd9aaH8ZGZUxHTrpdjCqCzMEVP8cB
memory:
     quota:     623.2 Kb     used:     190.9 Kb

net bandwidth:
     staked:        100.0000 EOS           (total stake delegated from account to self)
     delegated:       0.0000 EOS           (total staked delegated to account from others)
     used:             7.561 Kb
     available:        19.28 Mb
     limit:            19.29 Mb

cpu bandwidth:
     staked:        100.0000 EOS           (total stake delegated from account to self)
     delegated:       0.0000 EOS           (total staked delegated to account from others)
     used:             9.026 ms
     available:        3.853 sec
     limit:            3.862 sec

After 6 Hours sleep ZzZzz

It looked like my net and cpu bandwith has reduced a little bit, perfect!

$ cleos push action eosairdroper issue '["ge3tgmzxhege", "172150.0000 TOKEN", "airdrop"]' -p eosairdroper
executed transaction: 704ba42b779cbb7a77ca0160511c7178117c65700ec2da40f0579e3ecdaa6594  128 bytes  2375 us

$ cleos get account eosairdroper
permissions:
     owner     1:    1 EOS84uT4DBAJQpagWDfZPbk2hd9aaH8ZGZUxHTrpdjCqCzMEVP8cB
        active     1:    1 EOS84uT4DBAJQpagWDfZPbk2hd9aaH8ZGZUxHTrpdjCqCzMEVP8cB
memory:
     quota:     623.2 Kb     used:     191.2 Kb

net bandwidth:
     staked:        100.0000 EOS           (total stake delegated from account to self)
     delegated:       0.0000 EOS           (total staked delegated to account from others)
     used:             6.129 Kb
     available:         19.2 Mb
     limit:             19.2 Mb

cpu bandwidth:
     staked:        100.0000 EOS           (total stake delegated from account to self)
     delegated:       0.0000 EOS           (total staked delegated to account from others)
     used:             9.543 ms
     available:        3.835 sec
     limit:            3.845 sec

Big airdrop to B1

Testing a big amount Airdrop to b1 (not that they need it lol - usually this would go to the Airdrop team):

$ cleos push action eosairdroper issue '["b1", "100000000.0100 TOKEN", "airdrop"]' -p eosairdroper
executed transaction: 8458b5f23d6764333db5ba2d8133cabe65265abf6ecf674810a8eb1de05e25f7  128 bytes  2540 us
#  eosairdroper <= eosairdroper::issue          {"to":"b1","quantity":"100000000.0100 TOKEN","memo":"airdrop"}
#  eosairdroper <= eosairdroper::transfer       {"from":"eosairdroper","to":"b1","quantity":"100000000.0100 TOKEN","memo":"airdrop"}
#            b1 <= eosairdroper::transfer       {"from":"eosairdroper","to":"b1","quantity":"100000000.0100 TOKEN","memo":"airdrop"}

$ cleos get account eosairdroper
permissions:
     owner     1:    1 EOS84uT4DBAJQpagWDfZPbk2hd9aaH8ZGZUxHTrpdjCqCzMEVP8cB
        active     1:    1 EOS84uT4DBAJQpagWDfZPbk2hd9aaH8ZGZUxHTrpdjCqCzMEVP8cB
memory:
     quota:     623.2 Kb     used:     191.4 Kb

net bandwidth:
     staked:        100.0000 EOS           (total stake delegated from account to self)
     delegated:       0.0000 EOS           (total staked delegated to account from others)
     used:              6.22 Kb
     available:         19.2 Mb
     limit:             19.2 Mb

cpu bandwidth:
     staked:        100.0000 EOS           (total stake delegated from account to self)
     delegated:       0.0000 EOS           (total staked delegated to account from others)
     used:             11.66 ms
     available:        3.833 sec
     limit:            3.845 sec

No Memo

Testing an airdrop with no memo to another random account ge3dmgenesis: 1000.5425 EOS - it reduced from 128 bytes to 120 bytes of net bandwith usage, no significative changes in cpu and didn't affect anything on RAM, AT ALL - Remember, from the eosio.token contract we don't store the memo anywhere.

cleos push action eosairdroper issue '["ge3dmgenesis", "1000.5425 TOKEN", ""]' -p eosairdroper
executed transaction: 34d05c59c10049ae946ad4e66703bb42987d1a1ce248115f3bea4bb6b1120e7f  120 bytes  2387 us

$ cleosjn get account eosairdroper
permissions:
     owner     1:    1 EOS84uT4DBAJQpagWDfZPbk2hd9aaH8ZGZUxHTrpdjCqCzMEVP8cB
        active     1:    1 EOS84uT4DBAJQpagWDfZPbk2hd9aaH8ZGZUxHTrpdjCqCzMEVP8cB
memory:
     quota:     623.2 Kb     used:     191.6 Kb

net bandwidth:
     staked:        100.0000 EOS           (total stake delegated from account to self)
     delegated:       0.0000 EOS           (total staked delegated to account from others)
     used:             6.275 Kb
     available:         19.2 Mb
     limit:             19.2 Mb

cpu bandwidth:
     staked:        100.0000 EOS           (total stake delegated from account to self)
     delegated:       0.0000 EOS           (total staked delegated to account from others)
     used:             13.22 ms
     available:        3.831 sec
     limit:            3.845 sec

Results

If we assume the above values as an approximated average (I would need to load a batch of a couple thousands accounts to make sure), these are the stats that we will need for a full airdrop based on the official mainnet launch snapshot:

StatAvg / txTotal 163,930 Accounts
Net Bandwith128 bytes20.98 Mb
Cpu Bandwith~2.36 ms386.87 sec
RAM0.229 kb37,540 kb

You will eventually want to remove some accounts like B1, exchanges and so on from the airdrop.
Also these are other interesting stats from the genesis snapshot:

Minimum EOS BalanceNumber of Accounts
0.0000 EOS163,930
1.0000 EOS162,106
5.0000 EOS148,624
10.0000 EOS137,950
100.0000 EOS84,979

Mainnet

As of today's date, a couple hours ago we had an account creation with a RAM price of 0.015 EOS/Kb.

So if you are planning an Airdrop now, with the official genesis snapshot it would cost
around ~563 EOS, which right now translates to $6025.17 (USD). I'm not considering the net and cpu because it fully restores in 3 days, you could separate your airdrop in blocks.

My next step is to run a big batch of thousands of tokens issuing transactions so I can prove all of these stats are correct.

Also a BIG THANK YOU to @nsjames, @syedjafri and @blockliberty for the nice insights, discussions and prices! And of course to this amazing Jungle Testnet @cryptolions

**EDIT: Follow up article released: https://steemit.com/eos/@leordev/eos-ram-and-bandwith-analysis-2-tokens-claiming-and-achieving-zero-cost-airdrop **

Sort:  

Once people claim their tokens you get the ram back

Dan, thanks a lot for your input, it means A LOT to me!

So, that's something that I'm discussing with other fellas... What means "people claim"? I'm already engaged to create a claim action and setup a claim table (intermediary), so when people claim their airdrop I would just transfer from my contract account to the claimer account setting the claimer as the payer.

Am I missing something? It's already out-of-the-box on the issue action? Because it does not look like as the issuer is the payer.

I am confused about this as well, because in the eosio.token contract, the issuer pays for the new tokens storage. Even if you issued to a middleman account, the sender (from) always pays for storage, correct? @leordev I would love to be apart of this discussion with you and your team. I am also thinking about how the eosio.token contract is implemented on the mainnet and how we can create our own tokens using this contract.

sure man, just hit me up at telegram @leordev - I will be glad to help!

is there any guides to be a block producer?

I just saw your post on stack exchange as well. Thanks for this super useful information.

The existing code,

auto to = to_acnts.find( value.symbol.name() );
if( to == to_acnts.end() ) {
    to_acnts.emplace( ram_payer, [&]( auto& a ){
    a.balance = value;
});
} else {
  to_acnts.modify( to, 0, [&]( auto& a ) {
    a.balance += value;
  });
}

This means that should the receiver not be pre-existing in the table with the corresponding symbol then the sender pays the RAM cost to create a record to do so.

What if we created a preexisting record where there was a 'register' method which allowed anyone to call it and create an empty record in the to_acnts table, with a balance of 0.0000.

Then, your own computer can listen for such action, check if they're on the airdrop list, and then trigger a transfer action, transferring the tokens to the receiver without such RAM cost.

This wouldn't cast the net as wide as one would like as not every planned recipient would hit this 'register' action, however, you could have an 'Airdrop period' where if you do his this action, you're guaranteed to get the token early/day 1, if you don't, then you'll have to wait a little longer.

hey @johnwilliamson nice idea buddy! with that we don't even need an intermediary table! it looks perfect! I'm still waiting for @dan answer because I don't want to redo any job if he tell us that they are planning or working in something of eosio.token to claim tokens already!

That would mean the tokens are effectively moved from the smart contract account to the users account? or the user just pay the RAM used for his row in the smart contract?

Eos updates are still being posted on Steem Blockchain........ When will you update us on 2.0? @dan

nice! but if people never claim, can sender rescind tokens sent to restore ram?

probably burn it after some period? so only active users get it

Good work. The number of Airdrops on this chain will be astonishing .

Jungle is the best!!!

Fantastic post. We are prepping for a summer launch + airdrop. Posts like these make me so excited for 2018 and EOS. Nice work!

Nice work Leo ! Very interesting statistics!

Thank you @leordev, for putting this together! Awesome job! Many thanks also to @nsjames, @syedjafri and @blockliberty ... re-steemed!

Smart....... Do you have video tutorials on this and are you working on any project currently?

Thank you @leordev, as well as @nsjames and @syedjafri.
This really helps.

Thank you! This has been a hot question for a while.

I was able to update my response here: https://eosio.stackexchange.com/questions/679/what-are-the-staking-requirements-to-launch-an-airdrop

If anyone's interested in the awesome EOS Jobs that are out there, I compiled some of the best telegram posts:
https://steemit.com/eos/@natp/amazing-jobs-available-on-eos-right-now

I've also got an Ultimate Dev Link Guide for everything that's out there:
https://steemit.com/eos/@natp/ultimate-eos-developer-link-guide

Thanks very much for your effort in putting it together my friend! I appreciate your feedback!

No problem! You may want to add this amazing tool: https://acoutts.com/eos/ by EOS New York
SC: https://github.com/eosnewyork/erp

Great write up. Now I need to get up and running so I drop a token while RAM is cheap :p

I was going to ask you a question here but it is probably better for the SE, https://eosio.stackexchange.com/questions/898/get-cleos-without-building-eos

Know of any good instructions for installing cleos on Ubuntu without building a node?

I think they already answered you, you have an option to go with docker... I didn't have time to see it yet because I compile the whole eos build in my machine... Thanks my friend!

Would like to know this also.

Although i will probably just upgrade my RAM to 8Gb and compile and run a node...

Thank you loved your work ....

Coin Marketplace

STEEM 0.26
TRX 0.11
JST 0.033
BTC 64107.21
ETH 3073.84
USDT 1.00
SBD 3.88