# Getting Started
# First Tendermint App
As a general purpose blockchain engine, Tendermint 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 Tendermint Core, the other is your application, which can be written in any programming language. Recall from the intro to ABCI that Tendermint Core handles all the p2p and consensus stuff, and just forwards transactions to the application when they need to be validated, or when they're ready to be committed to a block.
In this guide, we show you some examples of how to run an application using Tendermint.
The first apps we will work with are written in Go. To install them, you
need to install Go (opens new window), put
$GOPATH/bin in your
$PATH and enable go modules with these instructions:
Now you should have the
abci-cli installed; you'll see a couple of
kvstore) that are example applications written
Now, let's run some apps!
# KVStore - A First Example
The kvstore app is a Merkle
tree (opens new window) that just stores all
transactions. If the transaction contains an
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.
In another terminal, we can start Tendermint. You should already have the Tendermint binary installed. If not, follow the steps from here. If you have never run Tendermint before, use:
If you have used Tendermint, you may want to reset the data for a new
blockchain by running
tendermint unsafe_reset_all. Then you can run
tendermint node to start Tendermint, and connect to the app. For more
details, see the guide on using Tendermint.
You should see Tendermint making blocks! We can get the status of our Tendermint node as follows:
-s just silences
curl. For nicer output, pipe the result into a
tool like jq (opens new window) or
Now let's send some transactions to the kvstore.
Note the single quote (
') around the url, which ensures that the
double quotes (
") are not escaped by bash. This command sent a
transaction with bytes
abcd will be stored as both the key
and the value in the Merkle tree. The response should look something
We can confirm that our transaction worked and the value got stored by querying the app:
The result should look 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
"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 (opens new window).
Now let's try setting a different key and value:
Now if we query for
name, we should get
Try some other transactions and queries to make sure everything is working!
# Counter - Another Example
Now that we've got the hang of it, let's try another application, the
The counter app doesn't use a Merkle tree, it just counts how many times we've sent a transaction, or committed the state.
This application has two modes:
serial=on, transactions must be a big-endian encoded incrementing
integer, starting at 0.
serial=off, there are no restrictions on transactions.
In a live blockchain, transactions collect in memory before they are
committed into blocks. To avoid wasting resources on invalid
transactions, ABCI provides the
CheckTx message, which application
developers can use to accept or reject transactions, before they are
stored in memory or gossipped to other peers.
In this instance of the counter app, with
allows transactions whose integer is greater than the last committed
Let's kill the previous instance of
tendermint and the
application, and start the counter app. We can enable
serial=on with a
In another window, reset then start Tendermint:
Once again, you can see the blocks streaming by. Let's send some
transactions. Since we have set
serial=on, the first transaction must
be the number
Note the empty (hence successful) response. The next transaction must be
1. If instead, we try to send a
5, we get an error:
But if we send a
1, it works again:
For more details on the
broadcast_tx API, see the guide on using
# CounterJS - Example in Another Language
We also want to run applications in another language - in this case,
counter. To run it, you'll need
to install node (opens new window).
You'll also need to fetch the relevant repository, from here (opens new window), then install it:
Kill the previous
tendermint processes. Now run the app:
In another window, reset and start