github.com/KYVENetwork/cometbft/v38@v38.0.3/docs/guides/quick-start.md (about) 1 --- 2 order: 2 3 --- 4 5 # Quick Start 6 7 ## Overview 8 9 This is a quick start guide. If you have a vague idea about how CometBFT 10 works and want to get started right away, continue. 11 12 ## Install 13 14 See the [install guide](./install.md). 15 16 ## Initialization 17 18 Running: 19 20 ```sh 21 cometbft init 22 ``` 23 24 will create the required files for a single, local node. 25 26 These files are found in `$HOME/.cometbft`: 27 28 ```sh 29 $ ls $HOME/.cometbft 30 31 config data 32 33 $ ls $HOME/.cometbft/config/ 34 35 config.toml genesis.json node_key.json priv_validator.json 36 ``` 37 38 For a single, local node, no further configuration is required. 39 Configuring a cluster is covered further below. 40 41 ## Local Node 42 43 Start CometBFT with a simple in-process application: 44 45 ```sh 46 cometbft node --proxy_app=kvstore 47 ``` 48 49 > Note: `kvstore` is a non persistent app, if you would like to run an application with persistence run `--proxy_app=persistent_kvstore` 50 51 and blocks will start to stream in: 52 53 ```sh 54 I[01-06|01:45:15.592] Executed block module=state height=1 validTxs=0 invalidTxs=0 55 I[01-06|01:45:15.624] Committed state module=state height=1 txs=0 appHash= 56 ``` 57 58 Check the status with: 59 60 ```sh 61 curl -s localhost:26657/status 62 ``` 63 64 ### Sending Transactions 65 66 With the KVstore app running, we can send transactions: 67 68 ```sh 69 curl -s 'localhost:26657/broadcast_tx_commit?tx="abcd"' 70 ``` 71 72 and check that it worked with: 73 74 ```sh 75 curl -s 'localhost:26657/abci_query?data="abcd"' 76 ``` 77 78 We can send transactions with a key and value too: 79 80 ```sh 81 curl -s 'localhost:26657/broadcast_tx_commit?tx="name=satoshi"' 82 ``` 83 84 and query the key: 85 86 ```sh 87 curl -s 'localhost:26657/abci_query?data="name"' 88 ``` 89 90 where the value is returned in hex. 91 92 ## Cluster of Nodes 93 94 First create four Ubuntu cloud machines. The following was tested on Digital 95 Ocean Ubuntu 16.04 x64 (3GB/1CPU, 20GB SSD). We'll refer to their respective IP 96 addresses below as IP1, IP2, IP3, IP4. 97 98 Then, `ssh` into each machine and install CometBFT following the [instructions](./install.md). 99 100 Next, use the `cometbft testnet` command to create four directories of config files (found in `./mytestnet`) and copy each directory to the relevant machine in the cloud, so that each machine has `$HOME/mytestnet/node[0-3]` directory. 101 102 Before you can start the network, you'll need peers identifiers (IPs are not enough and can change). We'll refer to them as ID1, ID2, ID3, ID4. 103 104 ```sh 105 cometbft show_node_id --home ./mytestnet/node0 106 cometbft show_node_id --home ./mytestnet/node1 107 cometbft show_node_id --home ./mytestnet/node2 108 cometbft show_node_id --home ./mytestnet/node3 109 ``` 110 111 Here's a handy Bash script to compile the persistent peers string, which will 112 be needed for our next step: 113 114 ```bash 115 #!/bin/bash 116 117 # Check if the required argument is provided 118 if [ $# -eq 0 ]; then 119 echo "Usage: $0 <ip1> <ip2> <ip3> ..." 120 exit 1 121 fi 122 123 # Command to run on each IP 124 BASE_COMMAND="cometbft show_node_id --home ./mytestnet/node" 125 126 # Initialize an array to store results 127 PERSISTENT_PEERS="" 128 129 # Iterate through provided IPs 130 for i in "${!@}"; do 131 IP="${!i}" 132 NODE_IDX=$((i - 1)) # Adjust for zero-based indexing 133 134 echo "Getting ID of $IP (node $NODE_IDX)..." 135 136 # Run the command on the current IP and capture the result 137 ID=$($BASE_COMMAND$NODE_IDX) 138 139 # Store the result in the array 140 PERSISTENT_PEERS+="$ID@$IP:26656" 141 142 # Add a comma if not the last IP 143 if [ $i -lt $# ]; then 144 PERSISTENT_PEERS+="," 145 fi 146 done 147 148 echo "$PERSISTENT_PEERS" 149 ``` 150 151 Finally, from each machine, run: 152 153 ```sh 154 cometbft node --home ./mytestnet/node0 --proxy_app=kvstore --p2p.persistent_peers="ID1@IP1:26656,ID2@IP2:26656,ID3@IP3:26656,ID4@IP4:26656" 155 cometbft node --home ./mytestnet/node1 --proxy_app=kvstore --p2p.persistent_peers="ID1@IP1:26656,ID2@IP2:26656,ID3@IP3:26656,ID4@IP4:26656" 156 cometbft node --home ./mytestnet/node2 --proxy_app=kvstore --p2p.persistent_peers="ID1@IP1:26656,ID2@IP2:26656,ID3@IP3:26656,ID4@IP4:26656" 157 cometbft node --home ./mytestnet/node3 --proxy_app=kvstore --p2p.persistent_peers="ID1@IP1:26656,ID2@IP2:26656,ID3@IP3:26656,ID4@IP4:26656" 158 ``` 159 160 Note that after the third node is started, blocks will start to stream in 161 because >2/3 of validators (defined in the `genesis.json`) have come online. 162 Persistent peers can also be specified in the `config.toml`. See [here](../core/configuration.md) for more information about configuration options. 163 164 Transactions can then be sent as covered in the single, local node example above.