Obtain blockchain test environment in 30 seconds

Time:2022-5-17

This article is【Mr. Li takes you to play CITA】The second in a series of technical articles. The author leeyr is a low-level blockchain engineer from Hangzhou Xita technology. He has brought a simple chain starting tutorial for new friends who want to engage in blockchain. I hope you like it. Pay attention to the official account: Xita technology, reply to the “communication group”, and join the citahub family of the blockchain open source community.
Open source enterprise blockchain kernel CITA likes address:https://github.com/citahub/cita

Share text:
If you don’t know the meaning of all kinds of blockchain operations, you will get dizzy at the beginning.

It takes a lot of effort to get a testing environment and experience the charm of blockchain.
I also tried to get an Ethereum test environment. As a result, I spent a morning reading all kinds of materials to use it, and all kinds of operations are not very convenient.

Now, you can use CITA to get a blockchain test environment in 30 seconds. If you don’t have much to say, take the first step:

docker run -v "`pwd`":/opt/cita-run cita/cita-release:1.0.1-secp256k1-sha3 cita create --super_admin "0x37d1c7449bfe76fe9c445e626da06265e9377601" --nodes "127.0.0.1:4000"


docker run -d -p 1337:1337 -v "`pwd`":/opt/cita-run cita/cita-release:1.0.1-secp256k1-sha3 /bin/bash -c 'cita setup test-chain/0 && cita start test-chain/0 && sleep infinity'

usecita-cli 2Verify the operation status of blockchain.

cita> rpc blockNumber
{
  "id": 1,
  "jsonrpc": "2.0",
  "result": "0x1"
}

I carefully made a timing. On my personal computer, the time from entering the above two commands to the first block of the blockchain is less than 30 seconds (including the download time of CITA image).

Let’s briefly explain the meaning of these two commands.

Most of the friends who have used CITA are probably throughQuick start 4To start a local CITA test environment. But for a testing environment, I think it’s still too complicated. I’m here! I have simplified the operation here:

  • Start only one node. It is enough to use CITA to deploy smart contracts and other operations, and the performance is better.
  • The image of CITA is published directly using the docker. CITA will release the corresponding docker image synchronously in versions after 1.0.1. In this way, you no longer need to download the release package.
  • Start CITA directly with docker. Platform independence. Whether you use Linux, MacOS or windows, as long as you install docker service, you can quickly obtain CITA test environment without difference.

The first command above isGenerate configuration information of the chain (including creation block information) and node configuration information; The second command isStart node 0, because we only have one node, as long as we start one node, the blockchain can work normally.

Two commands, 30 seconds to obtain blockchain test environmentHave you learned?

About Xita Technology

Rivtower Co., Ltd. is committed to providing safe and reliable blockchain network services for small and medium-sized enterprises to ensure the sustainability and robustness of their business ecological development.

Enterprise blockchain core CITACITA is the first enterprise blockchain core developed independently and based on the open source community in China

Open source community ecology citahub: a development platform connecting the scene party and the technology development team. Citahub can combine resources from all parties to provide scenarios, development tools and best practices for the development of value networks

Pagoda net: the app store on the chain can meet the application needs of various scenarios of the industry in a one-stop way