### ChainMaker Cluster Startup Output Source: https://docs.chainmaker.org.cn/v2.4.0/html/_sources/quickstart/通过命令行体验链.md Example output demonstrating the successful startup of the ChainMaker cluster, including unzipping packages and starting Docker VM service containers for each node. ```bash ===> Unzip chainmaker installation package unzipped chainmaker installation package already exists ===> Starting chainmaker cluster START ==> /root/chainmaker/chainmaker-go/build/release/chainmaker-v2.4.0_alpha-wx-org1.chainmaker.org start docker vm service container succeed: VM-GO-wx-org1.chainmaker.org-name-20250526151413 start docker vm service container succeed: VM-JAVA-wx-org1.chainmaker.org-name-20250526151413 chainmaker is starting, pls check log... START ==> /root/chainmaker/chainmaker-go/build/release/chainmaker-v2.4.0_alpha-wx-org2.chainmaker.org start docker vm service container succeed: VM-GO-wx-org2.chainmaker.org-name-20250526151413 start docker vm service container succeed: VM-JAVA-wx-org2.chainmaker.org-name-20250526151413 chainmaker is starting, pls check log... START ==> /root/chainmaker/chainmaker-go/build/release/chainmaker-v2.4.0_alpha-wx-org3.chainmaker.org start docker vm service container succeed: VM-GO-wx-org3.chainmaker.org-name-20250526151413 start docker vm service container succeed: VM-JAVA-wx-org3.chainmaker.org-name-20250526151413 chainmaker is starting, pls check log... START ==> /root/chainmaker/chainmaker-go/build/release/chainmaker-v2.4.0_alpha-wx-org4.chainmaker.org start docker vm service container succeed: VM-GO-wx-org4.chainmaker.org-name-20250526151413 start docker vm service container succeed: VM-JAVA-wx-org4.chainmaker.org-name-20250526151413 chainmaker is starting, pls check log... ``` -------------------------------- ### Start ChainMaker Node Cluster Source: https://docs.chainmaker.org.cn/v2.4.0/html/_sources/quickstart/通过命令行体验链.md Initiates the ChainMaker node cluster by executing the `cluster_quick_start.sh` script. This script unpacks the generated installation packages and starts the `chainmaker` nodes using the `start.sh` script located in the `bin` directory. ```bash $ ./cluster_quick_start.sh normal ``` -------------------------------- ### ChainMaker Directory Structure Example Source: https://docs.chainmaker.org.cn/v2.4.0/html/quickstart/FAQ Illustrates a typical directory structure for a ChainMaker cluster started with the cluster_quick_start.sh script, showing the organization of binaries, data, configuration, and logs. ```bash tree -L 2 chainmaker-go/build/release/chainmaker-v2.3.2-wx-org1.chainmaker.org/ ├── bin │   ├── chainmaker │   ├── panic.log │   ├── start.sh │   ├── stop.sh │   └── version.sh ├── data ├── config │   └── wx-org1.chainmaker.org └── log ├── brief.log    └── system.log ``` -------------------------------- ### Start ChainMaker Node Cluster Source: https://docs.chainmaker.org.cn/v2.4.0/html/quickstart/%E9%80%9A%E8%BF%87%E5%91%BD%E4%BB%A4%E8%A1%8C%E4%BD%93%E9%AA%8C%E9%93%BE Executes the cluster_quick_start.sh script to initiate the ChainMaker node cluster. This script handles unpacking installation packages and starting the 'chainmaker' nodes. ```shell $ ./cluster_quick_start.sh normal ``` -------------------------------- ### ChainMaker prepare.sh Execution Example Source: https://docs.chainmaker.org.cn/v2.4.0/html/_sources/instructions/启动支持Docker_VM的链.md An example execution of the `prepare.sh` script to generate a single chain with 4 nodes, using TBFT consensus, INFO log level, and enabling both Go and Java Docker VMs with INFO log levels for each. ```shell # 进入脚本目录 $ cd ../scripts # 查看脚本帮助 $ ./prepare.sh -h # 生成单链4节点集群的证书和配置 ./prepare.sh 4 1 begin check params... param P2P_PORT 11301 param RPC_PORT 12301 param DOCKER_VM_RUNTIME_PORT 32351 param DOCKER_GO_ENGINE_PORT 22351 param DOCKER_JAVA_ENGINE_PORT 23351 input consensus type (1-TBFT(default),3-MAXBFT,4-RAFT,6-ABFT): param CONSENSUS_TYPE 1 input log level (DEBUG|INFO(default)|WARN|ERROR): param LOG_LEVEL INFO enable vm go (YES|NO(default))YES input vm go log level (DEBUG|INFO(default)|WARN|ERROR): param DOCKER_GO_LOG_LEVEL INFO param ENABLE_VM_GO true enable vm java (YES|NO(default))YES input vm java log level (DEBUG|INFO(default)|WARN|ERROR): param DOCKER_JAVA_LOG_LEVEL INFO param ENABLE_VM_JAVA true config node total 4 begin generate node1 config... begin node1 chain1 cert config... begin node1 trust config... begin generate node2 config... begin node2 chain1 cert config... begin node2 trust config... begin generate node3 config... begin node3 chain1 cert config... begin node3 trust config... begin generate node4 config... begin node4 chain1 cert config... begin node4 trust config... ``` -------------------------------- ### Start MySQL and Load ChainMaker Plugin Source: https://docs.chainmaker.org.cn/v2.4.0/html/dev/%E5%8F%AF%E9%AA%8C%E8%AF%81%E6%95%B0%E6%8D%AE%E5%BA%93%E4%BD%BF%E7%94%A8%E6%96%87%E6%A1%A3 Initializes the MySQL server, starts it, and then loads the ChainMaker plugin using SQL commands. Includes setting the root password and verifying plugin installation. ```shell sudo ./mysqld --initialize --user=mysql sudo ./mysqld_safe --user=mysql ``` ```sql mysql -uroot -p ALTER USER 'root'@'localhost' IDENTIFIED BY '123456'; INSTALL PLUGIN mbtree SONAME 'ha_mbtree.so'; SHOW PLUGINS; ``` -------------------------------- ### Start ChainMaker Cluster Source: https://docs.chainmaker.org.cn/v2.4.0/html/instructions/%E5%90%AF%E5%8A%A8%E6%94%AF%E6%8C%81%E6%97%A7%E7%89%88%E6%9C%ACDocker_VM%E7%9A%84%E9%93%BE Initiates the ChainMaker cluster and DockerVMs by executing a cluster quick start script. This script unpacks installation packages and starts ChainMaker nodes and their required DockerVM containers. ```shell ./cluster_quick_start.sh normal ``` -------------------------------- ### godoc and pkgsite Installation and Usage Source: https://docs.chainmaker.org.cn/v2.4.0/html/others/%E8%B4%A1%E7%8C%AE%E4%BB%A3%E7%A0%81%E7%AE%A1%E7%90%86%E8%A7%84%E8%8C%83%E5%8F%8A%E6%B5%81%E7%A8%8B Instructions for installing and running `godoc` and `pkgsite` tools to view Go documentation. These tools help generate web-based documentation from Go source code comments. ```Shell go install golang.org/x/tools/cmd/godoc@latest godoc -http=:6060 pksite的用法类似 go install golang.org/x/pkgsite/cmd/pkgsite@latest pksite -http=:6060 然后打开浏览器访问 http://localhost:6060/chainmaker.org/chainmaker/xxxx/v2 即可查看web文档 ``` -------------------------------- ### Install ChainMaker Python SDK from Source Source: https://docs.chainmaker.org.cn/v2.4.0/html/_sources/sdk/PythonSDK使用说明.md Installs the ChainMaker Python SDK by cloning or downloading the source code and running the setup script. This method is useful for development or offline installations. ```bash python3 setup.py install ``` -------------------------------- ### Extract ChainMaker Installation Package Source: https://docs.chainmaker.org.cn/v2.4.0/html/_sources/instructions/启动支持Docker_VM的链.md Unpacks a ChainMaker installation archive. This step is necessary before deploying standalone Docker VMs, as it contains the necessary configuration and binaries for a specific organization's setup. ```shell tar -zxvf chainmaker-v2.4.0-wx-org4.chainmaker.org-20220824115035-x86_64.tar.gz ``` -------------------------------- ### Install ChainMaker Python SDK via pip Source: https://docs.chainmaker.org.cn/v2.4.0/html/_sources/sdk/PythonSDK使用说明.md Installs the ChainMaker Python SDK directly from its Git repository using pip. This method requires Git to be installed on the system. ```bash pip3 install git+https://git.chainmaker.org.cn/chainmaker/sdk-python.git ``` -------------------------------- ### Source Code Service Startup and Management Source: https://docs.chainmaker.org.cn/v2.4.0/html/dev/%E9%A2%84%E8%A8%80%E6%9C%BA%E5%B7%A5%E5%85%B7 Instructions for compiling the service from source, initializing the database, starting the service with default or custom configurations, checking health, viewing logs, and stopping the service. ```bash # Compile cd chainmaker-oracle && go build -o chainmaker-oracle # Initialize database mysql -uroot -p < scripts/init.sql # Start service # Direct start ./chainmaker-oracle # Or specify configuration file ./chainmaker-oracle -i config_files/smart_oracle.yml # Check service health status curl -X GET localhost:10123/v1/health # View logs tail -100 log/system.log # Stop service kill ${pid} ``` -------------------------------- ### Configure and Test CMC Tool Source: https://docs.chainmaker.org.cn/v2.4.0/html/quickstart/%E9%80%9A%E8%BF%87%E5%91%BD%E4%BB%A4%E8%A1%8C%E4%BD%93%E9%AA%8C%E9%93%BE Details the steps for configuring the CMC tool by copying crypto-config and then running the tool with the `--help` flag to verify its setup and understand available commands. ```shell # Configure test data $ cp -rf ../../build/crypto-config ../../tools/cmc/testdata/ # 使用chainmaker-cryptogen生成的测试链的证书 # View help $ cd ../../chainmaker-go/tools/cmc $ ./cmc --help ``` -------------------------------- ### Start ChainMaker Cluster with cluster_quick_start.sh Source: https://docs.chainmaker.org.cn/v2.4.0/html/_sources/instructions/启动支持Docker_VM的链.md Executes the cluster_quick_start.sh script to unpack installation packages and start ChainMaker nodes along with their required Docker VMs. This is the primary method for initiating a multi-node ChainMaker cluster. ```shell ./cluster_quick_start.sh normal ``` -------------------------------- ### Start ChainMaker Docker Network (Built-in Certs) Source: https://docs.chainmaker.org.cn/v2.4.0/html/_sources/instructions/通过Docker部署链.md This snippet shows how to start a pre-configured 4-node ChainMaker network using Docker with built-in certificates. It includes commands to start, send a transaction, and stop/clean up the network. ```sh cd chainmaker-go/scripts/docker/2.4.0 # 启动 ./four-nodes_up.sh # 等待10s左右,发交易 cd .. && ./sendTx.sh # 停止并删除数据 ./2.4.0/four-nodes_down.sh ``` -------------------------------- ### Quick Start Deployment Script Sequence Source: https://docs.chainmaker.org.cn/v2.4.0/html/instructions/%E5%9F%BA%E4%BA%8ECA%E6%9C%8D%E5%8A%A1%E6%90%AD%E5%BB%BA%E9%95%BF%E5%AE%89%E9%93%BE A sequence of shell commands for preparing certificates, compiling the project, unpacking the release, replacing node certificates and configuration values, and finally starting the blockchain cluster. ```shell # 1、准备证书和配置文件 ./prepare.sh 4 1 # 2、编译,打包可执行文件 ./build_release.sh # 3、解压缩打包的文件 cd ../build/release tar -xzf chainmaker-v2.3.5-wx-org1.chainmaker.org-20230919104740-x86_64.tar.gz # 4、替换各个节点的证书和节点ID # 4.1、替换chainmaker-v2.3.5-wx-org1.chainmaker.org/config/wx-org1.chainmaker.org/certs下的所有证书和nodeid # 4.2、替换chainmaker.yml,bc.yml的nodeId # 5、启动 ./cluster_quick_start.sh normal ``` -------------------------------- ### MySQL Initialization and Setup Source: https://docs.chainmaker.org.cn/v2.4.0/html/dev/%E5%8F%AF%E9%AA%8C%E8%AF%81%E6%95%B0%E6%8D%AE%E5%BA%93%E5%BC%80%E5%8F%91%E6%96%87%E6%A1%A3 Commands to compile MySQL client/admin tools, create necessary data directories, and copy error message system files for MySQL initialization. ```shell cd mysql-5.7.30/bld make mysql make mysqladmin mkdir /data/mysql_data/data/ mkdir /data/mysql_data/share/ mv ~/mysql-5.7.30/bld/sql/share/english/errmsg.sys /data/mysql_data/share/ ``` -------------------------------- ### Start ChainMaker Cluster Source: https://docs.chainmaker.org.cn/v2.4.0/html/_sources/instructions/启动国密证书模式的链.md Executes the cluster_quick_start.sh script to unpack installation packages and start ChainMaker nodes. This is the primary command for initiating a new cluster instance. ```shell ./cluster_quick_start.sh normal ``` -------------------------------- ### Start Chainmaker Cluster Source: https://docs.chainmaker.org.cn/v2.4.0/html/_sources/instructions/启动支持旧版本Docker_VM的链.md Executes the cluster_quick_start.sh script to unpack installation packages and start Chainmaker nodes along with their required DockerVM containers. This is the primary method for initiating a multi-node Chainmaker network. ```shell $ ./cluster_quick_start.sh normal ``` -------------------------------- ### Check Docker and Docker Compose Versions Source: https://docs.chainmaker.org.cn/v2.4.0/html/_sources/dev/区块链浏览器.md Verifies the installed versions of Docker and Docker Compose. This is a crucial step after installation to ensure compatibility and proper setup. ```bash docker -v docker-compose -v ``` -------------------------------- ### Prepare Script Execution Example Source: https://docs.chainmaker.org.cn/v2.4.0/html/instructions/%E5%90%AF%E5%8A%A8%E6%94%AF%E6%8C%81Docker_VM%E7%9A%84%E9%93%BE Demonstrates the execution of the `prepare.sh` script to generate certificates and configurations for a single chain with 4 nodes. It shows the script's interactive prompts for consensus type, log level, and VM enablement, along with the resulting parameter assignments. ```shell # 生成单链4节点集群的证书和配置 ./prepare.sh 4 1 begin check params... param P2P_PORT 11301 param RPC_PORT 12301 param DOCKER_VM_RUNTIME_PORT 32351 param DOCKER_GO_ENGINE_PORT 22351 param DOCKER_JAVA_ENGINE_PORT 23351 input consensus type (1-TBFT(default),3-MAXBFT,4-RAFT,6-ABFT): param CONSENSUS_TYPE 1 input log level (DEBUG|INFO(default)|WARN|ERROR): param LOG_LEVEL INFO enable vm go (YES|NO(default))YES input vm go log level (DEBUG|INFO(default)|WARN|ERROR): param DOCKER_GO_LOG_LEVEL INFO param ENABLE_VM_GO true enable vm java (YES|NO(default))YES input vm java log level (DEBUG|INFO(default)|WARN|ERROR): param DOCKER_JAVA_LOG_LEVEL INFO param ENABLE_VM_JAVA true config node total 4 begin generate node1 config... begin node1 chain1 cert config... begin node1 trust config... begin generate node2 config... begin node2 chain1 cert config... begin node2 trust config... begin generate node3 config... begin node3 chain1 cert config... begin node3 trust config... begin generate node4 config... begin node4 chain1 cert config... begin node4 trust config... ``` -------------------------------- ### Start ChainMaker Node Cluster Source: https://docs.chainmaker.org.cn/v2.4.0/html/_sources/manage/搭建ibc模式账户体系.md Starts the ChainMaker node cluster using the `cluster_quick_start.sh` script. This script unpacks the installation packages and calls the `start.sh` script within each node's bin directory. ```bash ./cluster_quick_start.sh normal ``` -------------------------------- ### Install MySQL 5.7.30 Source: https://docs.chainmaker.org.cn/v2.4.0/html/dev/%E5%8F%AF%E9%AA%8C%E8%AF%81%E6%95%B0%E6%8D%AE%E5%BA%93%E4%BD%BF%E7%94%A8%E6%96%87%E6%A1%A3 Steps to download, extract, and configure MySQL 5.7.30 on Linux. Includes installing dependencies, creating user accounts, and setting up configuration files. ```shell wget https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.30-linux-glibc2.12-x86_64.tar.gz tar zxvf mysql-5.7.30-linux-glibc2.12-x86_64.tar.gz sudo cp -r mysql-5.7.30-linux-glibc2.12-x86_64 /usr/local/mysql ``` ```shell sudo yum install -y libaio sudo groupadd -g 315 mysql sudo useradd -u 315 -g mysql -d /var/lib/mysql -M mysql ``` ```shell [mysqld] bind-address=0.0.0.0 port=3306 user=mysql basedir=/usr/local/mysql datadir=/data/mysql socket=/tmp/mysql.sock [mysqld_safe] log-error=/var/log/mysql/mysql.err pid-file=/var/log/mysql/mysql.pid # # include all files from the config directory # !includedir /etc/my.cnf.d ``` ```shell sudo mkdir /var/log/mysql sudo touch /var/log/mysql/mysql.err sudo touch /var/log/mysql/mysql.pid sudo chown -R mysql:mysql /var/log/mysql/ sudo mkdir -p /data/mysql sudo chown -R mysql:mysql /data/mysql/ ``` -------------------------------- ### Execute Deposit Contract Example with Go SDK Source: https://docs.chainmaker.org.cn/v2.4.0/html/instructions/%E9%83%A8%E7%BD%B2%E7%A4%BA%E4%BE%8B%E5%90%88%E7%BA%A6 Commands to navigate to the user contract claim example directory within the Go SDK and execute the main Go program. This example demonstrates deploying, invoking, and querying a deposit contract. ```shell cd sdk-go/examples/user_contract_claim go run main.go ``` -------------------------------- ### Start ChainMaker Docker Nodes Source: https://docs.chainmaker.org.cn/v2.4.0/html/_sources/instructions/通过Docker部署链.md Commands to start the ChainMaker blockchain network using Docker Compose. You can either use the `docker-compose` command directly or the provided `start.sh` script. ```sh $ cd chainmaker-go/scripts/docker/multi_node/ # 启动节点 $ docker-compose -f docker-compose1.yml up -d # or $./start.sh docker-compose1.yml ``` -------------------------------- ### ChainMaker Configuration: chainmaker.yml Example Source: https://docs.chainmaker.org.cn/v2.4.0/html/_sources/instructions/管理PK账户模式的链.md An example snippet of the chainmaker.yml configuration file, demonstrating network settings including the P2P provider, listen address, and seed peer list with node IDs. ```yaml net: # Network provider, can be libp2p or liquid. # libp2p: using libp2p components to build the p2p module. # liquid: a new p2p module we build from 0 to 1. # This item must be consistent across the blockchain network. provider: LibP2P # The address and port the node listens on. # By default, it uses 0.0.0.0 to listen on all network interfaces. listen_addr: /ip4/0.0.0.0/tcp/11301 # The seeds peer list used to join in the network when starting. # The connection supervisor will try to dial seed peer whenever the connection is broken. # Example ip format: "/ip4/127.0.0.1/tcp/11301/p2p/"+nodeid # Example dns format:"/dns/cm-node1.org/tcp/11301/p2p/"+nodeid seeds: - "/ip4/127.0.0.1/tcp/11301/p2p/QmeqnZEgGeQYyc4qX92XV3SxafqRJqCQ9388jWp2N1oA93" - "/ip4/127.0.0.1/tcp/11302/p2p/QmSXhWkujKh2PEN5tFuiTBnSbkx7vN6P9zPoa6RViLdpdA" - "/ip4/127.0.0.1/tcp/11303/p2p/QmfR4jNLsBK3FedeCLyTmzaCeaECK3VjDRoY6XcjiUpWYJ" - "/ip4/127.0.0.1/tcp/11304/p2p/QmRKZyDH89CH3zJaSC5VHn9tgcBbs7jc1mDVd9QgyzmKan" ``` -------------------------------- ### Deploy Chain Environment Source: https://docs.chainmaker.org.cn/v2.4.0/html/manage/%E9%9D%A2%E5%90%91%E8%B5%84%E4%BA%A7%E4%BA%92%E6%8D%A2%E7%9A%84%E5%8E%9F%E5%AD%90%E6%80%A7%E4%BF%9D%E9%9A%9C%E5%BA%94%E7%94%A8 Navigates into the downloaded application directory and builds the project using 'make', then restarts the blockchain environment. This prepares the necessary blockchain infrastructure. ```bash cd atomic-assets-swap/ make && ./restart.sh ``` -------------------------------- ### ChainMaker Configuration: bc1.yml Example Source: https://docs.chainmaker.org.cn/v2.4.0/html/_sources/instructions/管理PK账户模式的链.md An example snippet of the bc1.yml configuration file, showing how to specify consensus nodes and trust roots using generated node IDs and administrator public key file paths. ```yaml consensus: # Consensus type: 1-TBFT,5-DPOS type: 1 nodes: - org_id: "public" node_id: - "QmeqnZEgGeQYyc4qX92XV3SxafqRJqCQ9388jWp2N1oA93" - "QmSXhWkujKh2PEN5tFuiTBnSbkx7vN6P9zPoa6RViLdpdA" - "QmfR4jNLsBK3FedeCLyTmzaCeaECK3VjDRoY6XcjiUpWYJ" - "QmRKZyDH89CH3zJaSC5VHn9tgcBbs7jc1mDVd9QgyzmKan" trust_roots: - org_id: "public" root: - "../config/node1/admin/admin1/admin1.pem" - "../config/node1/admin/admin2/admin2.pem" - "../config/node1/admin/admin3/admin3.pem" - "../config/node1/admin/admin4/admin4.pem" ``` -------------------------------- ### Execute ChainMaker Go SDK Example Source: https://docs.chainmaker.org.cn/v2.4.0/html/recovery/%E9%80%9A%E8%BF%87%E5%91%BD%E4%BB%A4%E8%A1%8C%E5%B7%A5%E5%85%B7%E5%90%AF%E5%8A%A8%E9%93%BE Navigates to the user contract claim example directory and executes the main Go program. This verifies the SDK's functionality by deploying, invoking, and querying a smart contract. ```shell $ cd sdk-go/examples/user_contract_claim $ go run main.go ``` -------------------------------- ### Start Chainmaker Cluster Source: https://docs.chainmaker.org.cn/v2.4.0/html/instructions/%E5%90%AF%E5%8A%A8%E5%9B%BD%E5%AF%86%E8%AF%81%E4%B9%A6%E6%A8%A1%E5%BC%8F%E7%9A%84%E9%93%BE Initiates the Chainmaker cluster using a quick start script with a specified configuration mode (e.g., 'normal'). ```bash $ ./cluster_quick_start.sh normal ``` -------------------------------- ### Get User Balance Source: https://docs.chainmaker.org.cn/v2.4.0/html/_sources/manage/面向资产互换的原子性保障应用.md Fetches the current balance of a specified user on a particular chain. Example shows checking the balance for 'user2' on 'chain1'. ```APIDOC # getBalance chainName userName\ngetBalance chain1 user2\n# Output example:\ninfo: [chain1 user2 balance: 1000] ``` -------------------------------- ### Quick Start: Docker-VM Engine Chain Setup Source: https://docs.chainmaker.org.cn/v2.4.0/html/dev/%E9%A2%84%E8%A8%80%E6%9C%BA%E5%B7%A5%E5%85%B7 Provides commands to quickly set up a ChainMaker chain using a Docker-VM engine. This involves cloning the chainmaker-go and chainmaker-cryptogen repositories, building cryptogen, and creating a symbolic link for tools. ```bash $ git clone -b v2.3.1 --depth=1 https://git.chainmaker.org.cn/chainmaker/chainmaker-go.git $ git clone -b v2.2.0 --depth=1 https://git.chainmaker.org.cn/chainmaker/chainmaker-cryptogen.git $ cd chainmaker-cryptogen && make $ cd ../chainmaker-go/tools/ && ln -s ../../chainmaker-cryptogen/ . ``` -------------------------------- ### Docker Compose Service Startup and Management Source: https://docs.chainmaker.org.cn/v2.4.0/html/dev/%E9%A2%84%E8%A8%80%E6%9C%BA%E5%B7%A5%E5%85%B7 Steps to set up certificates, configure network IPs, start the service using Docker Compose, check health, view logs, and stop the service. ```bash # Set up certificates cd chainmaker-oracle rm -rf config_files/crypto-config/ && cp -rf ../chainmaker-go/build/crypto-config/ config_files/ # Modify chain node addresses to LAN IP vim config_files/sdk-config/sdk_config_chain1.yml vim config_files/sdk-config/sdk_config_chain2.yml # Start service docker-compose up # Check service health status curl -X GET localhost:10123/v1/health curl -X GET localhost:10124/v1/health # View logs docker logs -f --tail 100 chainmaker-oracle-1 docker logs -f --tail 100 chainmaker-oracle-2 # Stop service docker-compse down # Delete data in mysql rm -rf ./mysql-data-volumes/data/ ``` -------------------------------- ### Get User Address Source: https://docs.chainmaker.org.cn/v2.4.0/html/_sources/manage/面向资产互换的原子性保障应用.md Retrieves the blockchain address for a specified user on a given chain. Example shows fetching the address for 'user1' on 'chain1'. ```APIDOC # getAddress chainName userName\ngetAddress chain1 user1\n# Output example:\ninfo: [address:18bea55343220196ce02038b147c149e275b38cc] ``` -------------------------------- ### Timestamp Dependency Vulnerability Example (Rust) Source: https://docs.chainmaker.org.cn/v2.4.0/html/_sources/dev/智能合约漏洞检测工具.md Demonstrates a vulnerability caused by relying on system timestamps, which can lead to inconsistent execution results across different nodes and consensus issues. The example checks if the current time is within a minute of a start time for a purchase. ```Rust pub extern "C" fn sec_killing () { ... let now: DateTime = Local::now(); let start_time = Utc.ymd(2022, 11, 1).and_hms(0, 0, 0); if now.signed_duration_since(start_time) < Duration::seconds(60){ ctx.call_contract("mall", "buy", ec); } ... } ``` -------------------------------- ### start.sh Script Parameters Source: https://docs.chainmaker.org.cn/v2.4.0/html/dev/%E5%8F%AF%E9%AA%8C%E8%AF%81%E6%95%B0%E6%8D%AE%E5%BA%93%E5%BC%80%E5%8F%91%E6%96%87%E6%A1%A3 Configuration parameters for the start.sh script, used for testing and launching the project. These parameters specify paths for MySQL build artifacts, data directories, and executable files. ```APIDOC start.sh Script Parameters: - build_path: MySQL compilation directory (e.g., ~/mysql-5.7.30/bld/). - basedir: MySQL database files storage directory (e.g., /data/mysql_data/data/). - datadir: MySQL table files storage directory (should be ${basedir}data/). - mysqld_path: Path to the mysqld executable (e.g., ${build_path}sql/mysqld). - plugin_dir: Path to the compiled mbtree plugin (e.g., ${build_path}storage/${project_folder_name}/). - mysqladmin_path: Path to the mysqladmin executable (e.g., ${build_path}client/mysqladmin). - mysql_path: Path to the mysql client executable (e.g., ${build_path}client/mysql). - init function --user parameter: Should be set to the current user. ``` -------------------------------- ### Setup and Run ChainMaker SDK Subscriber Source: https://docs.chainmaker.org.cn/v2.4.0/html/_sources/dev/可验证数据库使用文档.md Instructions for setting up and running a Go subscriber program to listen for ChainMaker events. This involves cloning the SDK, copying the subscriber script, configuring SDK paths, and executing the Go program. ```Shell cd ~ git clone git@git.chainmaker.org.cn:chainmaker/sdk-go.git mkdir -p ~/sdk-go/examples/VerifiableDB cp subscribe.go ~/sdk-go/examples/VerifiableDB cp ~/chainmaker-go/tools/cmc/testdata/sdk_config.yml ~/sdk-go/examples/sdk_configs/sdk_config_org1_client1.yml cd ~/sdk-go/examples/VerifiableDB mkdir testdata cp -r ~/chainmaker-go/build/crypto-config/ ~/sdk-go/examples/VerifiableDB/testdata/ go run subscribe.go ``` -------------------------------- ### Build MySQL Binaries and Setup Data Directories Source: https://docs.chainmaker.org.cn/v2.4.0/html/_sources/dev/可验证数据库开发文档.md Builds the MySQL client and server executables and prepares the necessary data directories and configuration files for running MySQL and the verifiable database plugin. ```bash cd mysql-5.7.30/bld make mysql make mysqladmin mkdir /data/mysql_data/data/ mkdir /data/mysql_data/share/ mv ~/mysql-5.7.30/bld/sql/share/english/errmsg.sys /data/mysql_data/share/ ``` -------------------------------- ### Prepare Script Help and Usage Source: https://docs.chainmaker.org.cn/v2.4.0/html/instructions/%E5%90%AF%E5%8A%A8%E6%94%AF%E6%8C%81Docker_VM%E7%9A%84%E9%93%BE Displays the help message for the `prepare.sh` script, outlining its parameters for setting up a blockchain network. It details node count, chain count, ports, consensus types, log levels, and VM enablement options. ```shell # 查看脚本帮助 $ ./prepare.sh -h Usage: prepare.sh node_cnt(1/4/7/10/13/16) chain_cnt(1-4) p2p_port(default:11301) rpc_port(default:12301) docker_vm_runtime_port(default:32351) docker_go_engine_port(default:22351) docker_java_engine_port(default:23351) -c consense-type: 1-TBFT,3-MAXBFT,4-RAFT -l log-level: DEBUG,INFO,WARN,ERROR -v docker-vm-enable: true,false --vlog vm go log level: DEBUG,INFO,WARN,ERROR -j docker-java-enable: true,false --jlog vm go log level: DEBUG,INFO,WARN,ERROR -h show help eg1: prepare.sh 4 1 eg2: prepare.sh 4 1 11301 12301 eg2: prepare.sh 4 1 11301 12301 32351 22351 23351 eg2: prepare.sh 4 1 11301 12301 32351 22351 23351 -c 1 -l INFO -v true -j true --vlog=INFO --jlog=INFO eg2: prepare.sh 4 1 11301 12301 32351 22351 23351 -c 1 -l INFO -v false -j false --vlog=INFO --jlog=INFO ``` -------------------------------- ### Build ChainMaker Release Package (Bash) Source: https://docs.chainmaker.org.cn/v2.4.0/html/_sources/instructions/自拉起服务.md Generates the ChainMaker installation package. The package name follows a specific format: chainmaker-版本号-组织ID-打包时间-编译平台版本.tar.gz. ```bash ./build_release.sh ``` -------------------------------- ### Compile Privacy Computing Gateway Source: https://docs.chainmaker.org.cn/v2.4.0/html/_sources/cryptography/隐私计算使用指南.md Builds the ChainMaker privacy computing gateway application using Go. After compilation, the gateway can be started. ```sh cd ../gateway go build main.go ./main start ``` -------------------------------- ### Oracle Contract Installation API Source: https://docs.chainmaker.org.cn/v2.4.0/html/dev/%E9%A2%84%E8%A8%80%E6%9C%BA%E5%B7%A5%E5%85%B7 API endpoint for installing oracle contracts, requiring authentication token, address, chain alias, and the contract file. Includes example usage and a shell script for preparation. ```APIDOC POST /v1/install_contract Description: Installs an oracle contract onto a specified chain. Parameters: - admin_auth_token: (Header) Authentication token for the administrator. - address: (URL) The address where the oracle service is listening for HTTP requests. - chain_alias: (Form Data) The alias of the chain where the contract will be installed. - contract_version: (Form Data) The version of the contract. - runtime: (Form Data) The runtime environment for the contract (e.g., DOCKER_GO). - contract_file: (Form Data) The oracle contract binary compressed file (e.g., .7z). Example Usage: ```bash # Prepare contract file cd chainmaker-oracle 7z a oracle_contract_v1.7z standard_oracle_contract/oracle_contract_file/oracle_contract_v1 # Install oracle contract for chain1 curl -H 'admin_auth_token: si!*dfji@12mnku' -X POST localhost:10123/v1/install_contract -F "chain_alias=chain1_alias" -F "contract_version=1" -F "runtime=DOCKER_GO" -F "contract_file=@./oracle_contract_v1.7z" # Install oracle contract for chain2 curl -H 'admin_auth_token: si!*dfji@12mnku' -X POST localhost:10123/v1/install_contract -F "chain_alias=chain2_alias" -F "contract_version=1" -F "runtime=DOCKER_GO" -F "contract_file=@./oracle_contract_v1.7z" ``` Note: A helper script `install-upgrade-oracle-contract.sh` is also provided for convenience. ``` -------------------------------- ### ChainMaker Cluster Quick Start Source: https://docs.chainmaker.org.cn/v2.4.0/html/instructions/%E5%90%AF%E5%8A%A8PK%E6%A8%A1%E5%BC%8F%E7%9A%84%E9%93%BE Initiates the ChainMaker cluster startup process by executing the `cluster_quick_start.sh` script. This script unpacks the release archives and uses the `start.sh` script within the bin directory to launch the ChainMaker nodes. ```shell # 2.1.2.6. 启动和停止链[](#id11 "Permalink to this heading") * 执行cluster_quick_start.sh脚本,会解压各个安装包,调用bin目录中的start.sh脚本,启动chainmaker节点 ``` $ ./cluster_quick_start.sh normal ``` ``` -------------------------------- ### Start ChainMaker Cluster Source: https://docs.chainmaker.org.cn/v2.4.0/html/instructions/%E5%90%AF%E5%8A%A8%E6%94%AF%E6%8C%81Docker_VM%E7%9A%84%E9%93%BE Executes the cluster_quick_start.sh script to unpack installations and start ChainMaker nodes along with required DockerVM containers. This is the primary method for initiating a multi-node ChainMaker cluster. ```bash ./cluster_quick_start.sh normal ```