Getting Started
First CometBFT App
As a general purpose blockchain engine, CometBFT is agnostic to the application you want to run. So, to run a complete blockchain that does something useful, you must start two programs: one is CometBFT, the other is your application, which can be written in any programming language. CometBFT handles all the p2p and consensus logic, and just forwards transactions to the application when they need to be validated, or when they’re ready to be executed and committed. In this guide, we show you some examples of how to run an application using CometBFT.Install
The first apps we will work with are written in Go. To install them, you need to install Go, put$GOPATH/bin in your $PATH and enable go modules. If you use bash,
follow these instructions:
abci-cli installed; run abci-cli to see the list of commands:
kvstore command, an example application written in Go.
Now, let’s run an app!
KVStore - A First Example
The kvstore app is a Merkle tree that just stores all transactions. If the transaction contains an=, e.g. key=value, then
the value is stored under the key in the Merkle tree. Otherwise, the
full transaction bytes are stored as the key and the value.
Let’s start a kvstore application.
cometbft unsafe-reset-all. Then you can run
cometbft node to start CometBFT, and connect to the app. For more
details, see the guide on using CometBFT.
You should see CometBFT making blocks! We can get the status of our
CometBFT node as follows:
-s just silences curl. For nicer output, pipe the result into a
tool like jq or json_pp.
Now let’s send some transactions to the kvstore.
') around the url, which ensures that the
double quotes (") are not escaped by bash. This command sent a
transaction with bytes abcd, so abcd will be stored as both the key
and the value in the Merkle tree. The response should look something
like:
value in the result (YWJjZA==); this is the base64-encoding
of the ASCII of abcd. You can verify this in a python 2 shell by
running "YWJjZA==".decode('base64') or in python 3 shell by running
import codecs; codecs.decode(b"YWJjZA==", 'base64').decode('ascii').
Stay tuned for a future release that makes this output more
human-readable.
Now let’s try setting a different key and value:
name, we should get satoshi, or c2F0b3NoaQ==
in base64: