In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
Today, the editor will share with you the relevant knowledge points about how to build the EOS environment of the blockchain. The content is detailed and the logic is clear. I believe most people still know too much about this, so share this article for your reference. I hope you can get something after reading this article. Let's take a look at it.
The overall framework of EOSIO
EOSIO is composed of several program modules, and the following three modules are often used:
Nodeos-EOSIO core module, used to start the eosio service, run in the background, you can start to add a variety of plug-ins plugin.
Cleos-Command Line Interface wallet tool, see "EOS Command Line Interface Wallet" (https://github.com/eoshackathon/eos_dapp_development_cn/blob/master/docs/eos_command_line_wallet.md), located at eos/build/programs/cleos/cleos
Keosd-manages the various components of the wallet, and by default, keosd will start with cleos. Located in eos/build/programs/keosd
The following figure shows the relationship between the above three tools:
In addition, there is a compilation tool for smart contracts, eosiocpp.
The relationship among wallet, key pair, account number and intelligent contract in EOS system
Compared with other block chain common chains, the combination relationship of EOS system is relatively free, which also brings difficulties in understanding. Brother Hui, combined with his own understanding, takes the house where people are most related in China as an example to make a metaphorical introduction.
1) the wallet is the landlord of Tuhao
Tuhao can have many houses and all kinds of keys to open the door. The city of Shanghai has many tuhao landlords, so one node can create multiple wallets.
Cleos wallet create ${parameters}
2) the key is used to open the east door of the room.
Keys are divided into private keys and public keys. The public key can be seen by others. For example, the picture below is the orange key bag of the Tuhao family, which is specially used to store the key of the large flat house in Renheng Binjiang. The private key is the key that actually opens the door in the key bag.
It's no use getting the key bag. You have to get the private key in the key box before you can open the door of Tuhao's house.
Tuhao landlords can make many houses with the same lock, open the door with a pair of public / private keys, or have different keys for different houses.
Cleos wallet import ${Parameter} Private key
3) the account is the house
The landlord can give multiple houses a pair of keys (key bags and keys), or different houses with different keys.
In addition, a house can be opened with two keys, one is owner key pair, the other is active key pair.
The owner key address of the house is expressed as the landlord's public key, indicating the ownership of the owner's property right. The house can be opened with its corresponding private key. This key bag is not even given by the landlord's sister-in-law.
The active key pair of the house is expressed as the tenant's public key, indicating that the user's private key can open the house. After the house is rented, the landlord will package the key to the tenant.
The public key of the public key Active of the cleos create account node account name Owner.
Set up practical operation
The flow chart of building the actual operation is as follows.
4. 1 start the private chain
1) start keosd
Keosd-http-server-address=127.0.0.1:8900
The command line interface wallet program is keosd, which is located under the eos/build/programs/keosd path and is used to store the private key of the transaction signature. Keosd runs on the local node and saves the private key on the local node.
By default, keosd generates a basic configuration file, config.ini, in the directory ~ / eosio-wallet. The wallet-dir in this configuration file specifies the directory where the wallet files are stored.
In addition, when running the command line wallet, you can specify the directory of the config.ini configuration file by configuring the command line parameter-- config-dir. The configuration file holds the server configuration http-server-address parameters for accessing the http link, as well as other configuration parameters for resource sharing.
By default, keosd saves the wallet file in the ~ / eosio-wallet directory and the wallet file name is: .wallet. For example, the default wallet file name is default.wallet. When other wallets are created, each wallet file is created separately in this directory, for example, when a wallet named "duncanwang" is created, a wallet file duncanwang.wallet is generated. Wallet files can be stored in a specified directory through the command line argument-data-dir.
* * [warning] * * starting from V1.0.5, it is found that you need to run keosd and then run nodeos before you can create a wallet.
The successful output result is as follows:
(copy the code and click "read the original text")
2) start the private chain
Enter the following command in a new command line window.
Cd ~ / eos/build/programs/nodeos. / nodeos-e-p eosio-- plugin eosio::wallet_plugin-- plugin eosio::chain_api_plugin-- plugin eosio::history_api_plugin-- replay-blockchain
When starting nodeos, you need to add the parameter eosio::wallet_plugin, otherwise, every time the node restarts, the previously created wallet and account will not be loaded.
-- replay-blockchain means to clear the state of the chain in the database and run it again, which will cause the previous chunk to be read and loaded first when restarting.
[note] when the node is closed, the wallet will be locked. After restarting nodeos, you need to use the unlock command to unlock the wallet.
For example:
Duncanwang@duncanwang:~/eos$ cleos wallet unlock-n duncanwang
Password: Unlocked: duncanwang
Enter nodes-help to see the help instructions for all parameters.
4.2 create a wallet
Cleos wallet create-n duncanwang
The duncanwang wallet was created successfully. The output is as follows:
Duncanwang@duncanwang:~/eos$ cleos wallet create-n duncanwangCreating wallet: duncanwangSave password to use in the future to unlock this wallet.Without password imported keys will not be retrievable. "PW5JMZdES2Cds5LsPRUBRo2THEXpbFSM17Xmcd2XWG7XBd49wveTo"
[result confirmed]
Duncanwang@duncanwang:~$ cleos wallet listWallets: ["duncanwang *"]
The duanwang wallet already exists. * indicates that the account has been unlocked.
[question 1] create a wallet with the same name, but cleos wallet list cannot see it
Duncanwang@duncanwang:~$ cleos wallet create-n duncanwang
Error 3120001: Wallet already exists Try to use different wallet name.
[solution]
This is mainly because the wallet-plugin eosio::wallet_plugin parameter is not imported in the running command, so that the created wallet is not loaded, but the created wallet file exists in the directory.
. / nodeos-e-p eosio-- plugin eosio::chain_api_plugin-- plugin eosio::history_api_plugin-- replay-blockchain
Delete the file duncanwang.wallet in the ~ / eosio-wallet directory and recreate it.
* * [problem 2] * * after restarting the node, cleos wallet list found that the wallet created does not exist.
Duncanwang@duncanwang:~$ cleos wallet listWallets: []
[solution 1]
Run the. / nodeos command with the parameter-- plugin eosio::wallet_plugin
[solution 2]
Later, it was found that this method was sometimes not feasible, and cleos wallet list did not see the wallet. After opening the wallet with the command 'cleos wallet open-n duncanwang', it loads normally.
* * [question 3] * * prompt that keosd is running and cannot be connected when creating the wallet
Duncanwang@duncanwang:~$ cleos wallet create-n duncanwang "/ usr/local/bin/keosd" launchedUnable to connect to keosd, if keosd is running please kill the process and try again.
[solution]
You need to restart keosd by entering the following command.
Ps-ef | grep keosd kill-9 pid keosd-- http-server-address=127.0.0.1:8900
Examples of operations are as follows:
Duncanwang@duncanwang:~$ ps-ef | grep keosdduncanw+ 2439 1 0 07:14 pts/1 00:00:00 / usr/local/bin/keosd-- http-server-address=::1:8900duncanw+ 2441 2389 0 07:16 pts/1 00:00:00 grep-- color=auto keosdduncanwang@duncanwang:~$ kill-9 2439
4.3 Wallet imports the private key of the system account
1) find the default public key / private key pair of the eosio system account
Find the configuration file, such as the following address, the config.ini of ~ / .local/share/eosio/nodeosconfig, and the default private key / public key is the same.
# signature-provider = EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV=KEY:5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3
2), import the wallet into the private key of the system account
> cleos wallet import 5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3-n duncanwangduncanwang@duncanwang:~/eos$ cleos wallet import 5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3-n duncanwangimported private key for: EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV
3) View the system account information
The following command can view the key and resource usage of the eosio system account.
> cleos get account eosioduncanwang@duncanwang:~/eos/build$ cleos get account eosioprivileged: truepermissions: owner 1: 1 EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV active 1: 1 EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CVmemory: quota: unlimited used: 60.75 KiB net bandwidth: used: unlimited available: unlimited limit: unlimitedcpu bandwidth: used: unlimited available: Unlimited limit: unlimited
4.4 load Bios contract
Now that we have a wallet and loaded the key for the eosio account, we can set up a default system contract. For development purposes, the default eosio.bios contract can be used. With this contract, you can directly control the resource allocation of other accounts and invoke other privileged API. In the public block chain, this system contract will manage the token mortgage and unmortgage operations of other accounts, reserving CPU, network activity bandwidth, and memory for contract execution.
The eosio.bios contract can be found in your EOSIO source folder: contracts/eosio.bios. The following command sequence is assumed to be executed in the root directory of the EOSIO source code. But you can execute this command from anywhere by specifying the full path: ${EOSIO_SOURCE} / build/contracts/eosio.bios.
As a result of this command sequence, cleos initiates a transaction (transaction) that contains two operations (actions): eosio::setcode and eosio::setabi.
The code defines how the contract runs, and abi describes how parameters are converted between binary and json representations. Although abi is technically optional, all EOSIO tools rely on it for ease of use.
Enter the command:
Cleos set contract eosio build/contracts/eosio.bios-p eosio
The output indicates that the local execution was successful.
Duncanwang@duncanwang:~/eos$ cleos set contract eosio build/contracts/eosio.bios-p eosioReading WAST/WASM from build/contracts/eosio.bios/eosio.bios.wasm...Using already assembled WASM...Publishing contract...executed transaction: f4c1cc4e953710645a4849eb41cf92d9d3881c756b227323a3ade221e3807fbb 3720 bytes 12685 us# eosio cleos create account eosio boss EOS6EHAzvrpQ4wo1BPcAk86X6aGDARZgqTcAq1mJRF1SxEYgNGWN1 EOS6EHAzvrpQ4wo1BPcAk86X6aGDARZgqTcAq1mJRF1SxEYgNGWN1
Create the output result successfully:
Duncanwang@duncanwang:~/eos$ cleos create account eosio boss EOS6EHAzvrpQ4wo1BPcAk86X6aGDARZgqTcAq1mJRF1SxEYgNGWN1 EOS6EHAzvrpQ4wo1BPcAk86X6aGDARZgqTcAq1mJRF1SxEYgNGWN1executed transaction: cb6801fe82816f94b447cbfb903ae8e9477f5c99920322d679a9c8c04347e536 200 bytes 367 us# eosio
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.