After listening to Bettina Warburg’s talk, I became fascinated with the concept of decentralized economy (dApps). A traditional Web application is:

  • Front end → back end → database

DApp sites, by contrast, are:

  • Front end → smart contract → blockchain

For example, when you enter an electronic bank, the web page will invoke back-end code to retrieve your personal data and display it on the page. The back-end code runs on a centralized server.

Unlike traditional approaches, dApps run back-end code smart contracts on decentralized P2P networks and Blockchain.

Why is blockchain so hot?

Blockchain is the technology that underpins bitcoin, the digital currency, but it has broader applications and is being commercialized in a growing number of areas. It has generated a lot of interest in the tech community and others because it opens up new possibilities in financial services, the public sector and other areas. – THOUGHT LEADERSHIP Nov 2017

What is the EOSIO Blockchain?

EOSIO is billed as the operating system for DApps. It’s built from the ground up and performs millions of transactions per second (compared to the largest blockchain networks today: Ethernet has only 15 transactions per second), making it a better fit for a complex Dapp ecosystem and a decentralized, monetized economy.

What does this blog cover?

In this blog, I’ll show you how to set up the EOSIO blockchain and develop smart contracts. This is part 1 of this series. Here is a step-by-step demonstration of the EOSIO installation and how I set up my wallet, account, and token. Let’s get started.

A clean virtual machine

To avoid conflicts with existing software, I prepared a clean virtual machine for this experiment. I am using the Linux KVM virtualization infrastructure (KVM is much faster than Virtualbox, which is only 2% worse than bare metal). I assigned the following configuration to the VM:

  • 8 GB RAM, 4 Vcpus
  • 30 GB disk space
  • Ubuntu 17.10 desktop

1. Download EOSIO

After the operating system is installed, I perform the following operations on the terminal:

$ sudo apt install git-core

$ git clone https://github.com/EOSIO/eos --recursive

$ cd eos
$ git submodule update --init --recursive

$ ./eosio_build.sh

$ export PATH=${HOME}/opt/mongodb/bin:$PATH
$ ~/opt/mongodb/bin/mongod -f ~/opt/mongodb/mongod.conf &
$ cd ~/eos/build: make test

$ sudo make install
Copy the code

2. Start the server

Now that EOSIO is installed, I type the following command to start the server:

$ cd ~/eos/build/programs/keosd
$ keosd --http-server-address=localhost:8899
Copy the code

Open a new command line client:

$ cd ~/eos/build/programs/nodeos
$ nodeos -e -p eosio --contracts-console --plugin eosio::chain_api_plugin --plugin eosio::history_api_plugin --plugin eosio::wallet_api_plugin
Copy the code

Open a new command line client:

$ alias cleos='~/eos/build/programs/cleos/cleos --wallet-url=http://localhost:8899'
Copy the code

3. Create wallets, key pairs, accounts, and tokens

To store information in a blockchain, we need an account that identifies the data and wallet to protect the keys used to sign transactions. See here for an overview of EOSIO account and wallet concepts

I did the following:

$ cd ~/eos
$ cleos wallet create
Copy the code

Record the password on the screen for later use.

$ cleos wallet key
Copy the code

Record the key pair values for private1 and public2 on the screen for later use.

$ cleos wallet key
Copy the code

Take another set of private2 and public2 key pairs and record them for later use.

$ cleos wallet import ${private_key_1}
$ cleos wallet import ${private_key_2}
$ cleos wallet keys
Copy the code

After importing the keys into the wallet using the private keys private1 and private2 you should see the values of the two public keys displayed in the wallet on the screen.

$ cleos create account eosio myaccount ${public_key_1} ${public_key_2}
Copy the code

Following the above command, you should find error messages. It means your wallet is not unlocked.

$ find ~ -name config.ini 
$ nano ~/.local/share/eosio/nodes/config/config.ini
Copy the code

Ini may be in a different directory on another platform. If you see the configuration item signature-provider =******* in config.ini, import the private key with this value into your wallet:

$ cleos wallet import ${private_key_signature-provider}
$ cleos wallet keys
Copy the code

At this point you should be able to see three public keys in your wallet.

$ cleos create account eosio myaccount ${public_key_1} ${public_key_2}
Copy the code

The account will be successfully created, so let’s create a few more accounts.

$ cleos create account eosio user ${public_key_1} ${public_key_2}
$ cleos create account eosio tester ${public_key_1} ${public_key_2}
$ cleos create account eosio eosio.token ${public_key_1} ${public_key_2}
Copy the code

Create a contract on the EOSIo. token account.

$ cleos set contract eosio.token ~/eos/build/contracts/eosio.token -p eosio.token
Copy the code

Push contracts to blockchain:

$CLEos push action eosio.token create '{"issuer":" EOsio ", "maximum_supply":"1000000000.0000 SYS"}' -p eosio.tokenCopy the code

Do some single-action tests, create accounts, send tokens, transfer money:

$ cleos create account eosio user ${public_key_1} ${public_key_2} $ cleos push action eosio.token issue '[ "user", "100.0000 SYS", "Memo"]' -p EOSIO $CLEOS push action EOsio. token Transfer '["user", "Tester ", "1.0000 SYS", "m" ]' -p userCopy the code

Create an Exchange account and create an Exchange contract under contracts/, which is used to create and trade currencies:

$ cleos create account eosio exchange ${public_key_1} ${public_key_2}
$ cleos set contract exchange ~/eos/build/contracts/exchange -p exchange
Copy the code

Msig allows multiple parties to sign a single transaction asynchronously:

$ cleos create account eosio eosio.msig ${public_key_1} ${public_key_2}
$ cleos set contract eosio.msig ~/eos/build/contracts/eosio.msig -p eosio.msig
Copy the code

Backup wallet:

$ mkdir backup-my-wallet
$ cp -R ~/eosio-wallet ./backup-my-wallet/
Copy the code

4. Try writing a smart contract called Hello

EOSIO Smart Contract is a C ++ program that executes in the blockchain. See the documentation here.

EOSIO provides several sample contracts in the contracts/ directory, and I used the Hello contract hello.cpp directly:

#include <eosiolib/eosio.hpp> #include <eosiolib/print.hpp> using namespace eosio; class hello : public eosio::contract { public: using contract::contract; /// @abi action void hi( account_name user ) { print( "Hello, ", name{user} ); }}; EOSIO_ABI( hello, (hi) )Copy the code

Perform the following tests:

$ cd ~/eos/contracts/hello
$ eosiocpp -o hello.wast hello.cpp
$ eosiocpp -g hello.abi hello.cpp
Copy the code

Create an account:

$ cleos create account eosio hello.code ${public_key_1} ${public_key_2}
Copy the code

Create a contract:

$ cleos set contract hello.code .. /hello -p hello.codeCopy the code

Push contract:

$ cleos push action hello.code hi '["user"]' -p user
Copy the code

Print (” hello, “name{user}); Add require_auth(user).

Compile contract, update contract, push contract:

$ eosiocpp -o hello.wast hello.cpp $ cleos set contract hello.code .. /hello -p hello.code $ cleos push action hello.code hi '["tester"]' -p userCopy the code

There should be an error message, let’s change the push command:

$ cleos push action hello.code hi '["tester"]' -p tester
Copy the code

That should be all right this time.

$ pkill keosd && pkill nodeos
Copy the code

Shut down the server process.

= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

Share an interactive online programming primer for EOS Smart Contract and DApp development:

EOS tutorial

This course will help you get a quick introduction to the development of EOS blockchain decentralized applications. It covers core knowledge points such as EOS tool chain, account and wallet, issuing tokens, development and deployment of smart contracts, and interaction between codes and smart contracts. Finally, a note DApp will be developed using all knowledge points comprehensively.

  • Web3j tutorial, mainly for Java and Android programmers for blockchain Ethereum development web3J details.
  • Ethereum tutorial, mainly introduces smart contract and DAPP application development, suitable for getting started.
  • Ethereum development, mainly introduces the use of Node.js, mongodb, blockchain, IPFS to achieve decentralized e-commerce DApp combat, suitable for advanced.
  • Python Ethereum is a detailed explanation of blockchain ethereum development by Python engineers using Web3.py.
  • PHP Ethereum mainly introduces the use of PHP for smart contract development interaction, account creation, transactions, transfers, token development, filters and events and other content.
  • C# ethereum, mainly explains how to use C# based development. Net ethereum applications, including account management, status and transactions, smart contract development and interaction, filters and events, etc.

Huizhi net original translation, reprint please indicate the source. Here is the original text