Build the first blockchain network (Fisco-Bcos), start and use the console

1. Build the first blockchain network

1. Install dependencies

centos7

sudo yum install -y openssl openssl-devel

Ubuntu

sudo apt install -y openssl curl

2. Create the operating directory and download the installation script

## 创建操作目录
cd ~ && mkdir -p fisco && cd fisco

## 下载脚本
curl -#LO https://osp-1257653870.cos.ap-guangzhou.myqcloud.com/FISCO-BCOS/FISCO-BCOS/releases/v2.9.1/build_chain.sh && chmod u+x build_chain.sh

3. Build a single group 4-node alliance chain

bash build_chain.sh -l 127.0.0.1:4 -p 30300,20200,8545

The screenshot of successful construction is as follows:

 4. Start the FISCO BCOS chain

bash nodes/127.0.0.1/start_all.sh

Screenshot of successful startup is as follows

 5. Check the progress

Check if the process is started

ps -ef | grep -v grep | grep fisco-bcos

 The output is as follows. If the number of processes is not 4, the process is not started (usually caused by the port being occupied)

 6. Check the log output

View the number of nodes linked to node node0

tail -f nodes/127.0.0.1/node0/log/log*  | grep connected

The output result is as follows. Under normal circumstances, connection information will be output continuously. From the output, it can be seen that node0 is connected to three other nodes.

 Check if consensus is reached

tail -f nodes/127.0.0.1/node0/log/log*  | grep +++

The output result is as follows. Under normal circumstances, it will continue to output ++++Generating seal, indicating that the consensus is normal

 

2. Configure and use the console

1. Prepare dependencies

 Install Java

# ubuntu系统安装java
sudo apt install -y default-jdk

#centos系统安装java
sudo yum install -y java java-devel

Get the console and go back to the fisco directory

cd ~/fisco && curl -#LO https://gitee.com/FISCO-BCOS/console/raw/master-2.0/tools/download_console.sh && bash download_console.sh

Copy console file

# 最新版本控制台使用如下命令拷贝配置文件
cp -n console/conf/config-example.toml console/conf/config.toml

Configure console certificate

cp -r nodes/127.0.0.1/sdk/* console/conf/

2. Start and use the console

 start up

cd ~/fisco/console && bash start.sh

The following information is output to indicate successful startup. Otherwise, please check whether the node port configuration in conf/config.toml is correct.

 Get information using the console

# 获取客户端版本
[group:1]> getNodeVersion
ClientVersion{
    version='2.6.0',
    supportedVersion='2.6.0',
    chainId='1',
    buildTime='20200819 15:47:59',
    buildType='Darwin/appleclang/RelWithDebInfo',
    gitBranch='HEAD',
    gitCommitHash='e4a5ef2ef64d1943fccc4ebc61467a91779fb1c0'
}
# 获取节点信息
[group:1]> getPeers
[
    PeerInfo{
        nodeID='c1bd77e188cd0783256ee06838020f24a697f9af785438403d3620967a4a3612e3abc4bbe986d1e9dddf62d4236bff0b7d19a935a3cd44889f681409d5bf8692',
        ipAndPort='127.0.0.1:30302',
        agency='agency',
        topic=[

        ],
        node='node2'
    },
    PeerInfo{
        nodeID='7f27f5d67f104eacf689790f09313e4343e7887a1a7b79c31cd151be33c7c8dd57c895a66086c3c8e0b54d2fa493407e0d9646b2bd9fc29a94fd3663a5332e6a',
        ipAndPort='127.0.0.1:57266',
        agency='agency',
        topic=[
            _block_notify_1
        ],
        node='node1'
    },
    PeerInfo{
        nodeID='862f26d9681ed4c12681bf81a50d0b8c66dd5b6ee7b0b42a4af12bb37b1ad2442f7dcfe8dac4e737ce9fa46aa94d904e8c474659eabf575d6715995553245be5',
        ipAndPort='127.0.0.1:30303',
        agency='agency',
        topic=[

        ],
        node='node3'
    }
]

[group:1]>

3. Deploy and call the HelloWorld contract

1.Write smart contracts

HelloWorld contract provides two interfaces, namelyget() and set(), which are used to obtain/set contract variablesname . The contract contents are as follows:

pragma solidity ^0.4.24;

contract HelloWorld {
    string name;

    function HelloWorld() {
        name = "Hello, World!";
    }

    function get()constant returns(string) {
        return name;
    }

    function set(string n) {
        name = n;
    }
}

2. Deploy the HelloWorld contract

 3. Call the HelloWorld contract

 

Guess you like

Origin blog.csdn.net/m0_72435337/article/details/131703601