EOSIO create 2 currencies on single wallet and Transfer funds

in #eosio2 years ago

Recently EOSIO been on everyone's lips, they have provided rapidly build and deploy high-performance and high-security blockchain-based applications platform. As there new version has been updated on GIT-Hub page.

Today we'll take the topic of creation of wallet, create different type of currencies in the wallet, create user accounts and then transfer created coins from one account to another.

EOS blockchain.png

Basic EOSIO Environment setup :


Before we start anything we should have a freshly installed EOSIO setup on our machine. Here I am using Ubuntu-16.04.
Follow the installation steps on Ubuntu machine from Developers portal for EIOSIO

Create wallet and accounts


After completing the setup simply start the nodeos and make sure your wallet is unlocked and then follow these steps,

  1. Create wallet - (lets use wallet name = flowers )
    cleos wallet create --name flowers
  2. now create owner and active keys for the wallet (execute the following command twice)
    cleos wallet create key
    • generated first public-private key pair is Owner kyes
    • generated second public-private key pair is Active keys
  3. Now import the generated keys into wallet
    1. import private Active key
      cleos wallet import --name flowers $(generated_private_active_key)
    2. import private Owner key
      cleos wallet import --name flowers $(generated_private_owner_key)
    3. import private EOSIO key
      cleos wallet import --name flowers $(generated_private_eosio_key)
  4. Now create the currency account (lets create 2 currencies bitcoin and ripple )
    • cleos create account eosio bitcoin $(owner_public_key$) $(active_public_key)
    • cleos create account eosio ripple $(owner_public_key$) $(active_public_key)
  5. Create an account (lets create 2 accounts rose and periwinkle
    • cleos create account eosio rose $(owner_public_key$) $(active_public_key)
    • cleos create account eosio periwinkle $(owner_public_key$) $(active_public_key)

Lets do the actual transactions

  1. load the Bios contracts into Ripple currency account
    cleos set contract ripple ~eos/build/contracts/eosio.bios -p ripple
    • Here first ripple is the currency account name in which you wish to load the contract
    • -p ripple the the account which will gonna allow all the transaction related permissions
  2. similarly load the Bios contract into Bitcoin currency account
    cleos set contract bitcoin ~eos/build/contracts/eosio.bios -p bitcoin
  3. After loading the contract into the account, check the hash code for that account, it must have changed from a string of zeros.
    cleos get code bitcoin
  4. Now deploy the token contract on your Ripple account which will gonna create the XRP currency
    cleos set contract ripple eos/build/contracts/eosio.token -p ripple
    • Here first ripple is the currency account name in which you wish to load the contract
    • -p ripple the the account which will gonna allow all the transaction related permissions
  5. Now deploy the token contract on your Bitcoin account which will gonna create the BTC currency
    cleos set contract ripple eos/build/contracts/eosio.token -p ripple
  6. Lets create the currency with some fixed amount and coin symbol
    cleos push action ripple create '[ "ripple", "1000000000.0000 XRP"]' -p ripple
    • here "ripple" is the account name which will gonna have this initial amount of tokens
    • and XRP is the coin symbol we wish to use for our currency
    • 1000000000.0000 ⇒ maximum_supply provided with upto 4 decimal scale/points only
  7. Similarly lets create the initial amount of 1 billion tokens for Bitcoin currency
    cleos push action bitcoin create '[ "bitcoin", "1000000000.0000 XRP"]' -p bitcoin
  8. Now issue those tokens/currency in any of the user account we created (e.g lets issue 100 ripple in rose account )
    cleos push action ripple issue '["rose", "100.0000 XRP", "memo"]' -p ripple
    • rose is the account name which will gonna issue
    • after this command, it'll gonna transfer 100 ripple coins from ripple account to rose account
  9. Similarly transfer 20 bitcoins to the periwinkle account
    cleos push action bitcoin issue '["periwinkle", "20.0000 BTC", "memo"]' -p bitcoin
  10. Also you can send/transfer coins from one user account to other user account
    cleos push action ripple transfer '[ "rose", "periwinkle", "51.0000 XRP", "my first transfer" ]' -p rose
    • here -p rose is the name of the account whose permission required to transfer the fund
  11. Now you can validate if transfer is actually happened or not, by checking the balance
    cleos get table ripple periwinkle accounts

Thanks for your patience to checking it out, Please add comments for suggestion as Its my first Blog ... :)

Sort:  

Congratulations @amolm! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

Award for the number of upvotes received

Click on the badge to view your Board of Honor.
If you no longer want to receive notifications, reply to this comment with the word STOP

Do not miss the last post from @steemitboard!


Participate in the SteemitBoard World Cup Contest!
Collect World Cup badges and win free SBD
Support the Gold Sponsors of the contest: @good-karma and @lukestokes


Do you like SteemitBoard's project? Then Vote for its witness and get one more award!

Congratulations @amolm! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 1 year!

You can view your badges on your Steem Board and compare to others on the Steem Ranking

Do not miss the last post from @steemitboard:

The Steem community has lost an epic member! Farewell @woflhart!
SteemitBoard - Witness Update
Do not miss the coming Rocky Mountain Steem Meetup and get a new community badge!
Vote for @Steemitboard as a witness to get one more award and increased upvotes!