testnets/README.md

160 lines
5.0 KiB
Markdown
Raw Normal View History

2018-04-23 09:35:03 -07:00
# Deploy a Testnet
2018-04-23 08:48:33 -07:00
2018-04-23 09:35:03 -07:00
## Starting Gaiad
2018-04-23 08:48:33 -07:00
2018-04-23 09:35:03 -07:00
Start the full node:
2018-04-23 08:48:33 -07:00
```
2018-04-23 09:35:03 -07:00
gaiad start
2018-04-23 08:48:33 -07:00
```
2018-04-23 09:35:03 -07:00
Check the everything is running smoothly:
2018-04-23 08:48:33 -07:00
```
2018-04-23 09:35:03 -07:00
gaiacli status
2018-04-23 08:48:33 -07:00
```
2018-04-23 09:35:03 -07:00
## Generate keys
You'll need a private and public key pair \(a.k.a. `sk, pk` respectively\) to be able to receive funds, send txs, bond tx, etc.
To generate your a new key \(default _ed25519 _elliptic curve\):
2018-04-23 08:48:33 -07:00
```
2018-04-23 09:35:03 -07:00
KEYNAME=<set_a_name_for_your_new_key>
gaiacli keys add $KEYNAME
2018-04-23 08:48:33 -07:00
```
2018-04-23 09:35:03 -07:00
Next, you will have to enter a passphrase for your`$KEYNAME`key twice. Save the _seed phrase _in a safe place in case you forget the password.
Now if you check your private keys you will see the `$KEYNAME `key among them:
2018-04-23 08:48:33 -07:00
```
2018-04-23 09:35:03 -07:00
gaiacli keys show $KEYNAME
2018-04-23 08:48:33 -07:00
```
2018-04-23 09:35:03 -07:00
You can see your other available keys by typing:
2018-04-23 08:48:33 -07:00
```
2018-04-23 09:35:03 -07:00
gaiacli keys list
2018-04-23 08:48:33 -07:00
```
2018-04-23 09:35:03 -07:00
Save your address and pubkey into a variable
2018-04-23 08:48:33 -07:00
```
2018-04-23 09:35:03 -07:00
MYADDR=<your_newly_generated_address>
MYPUBKEY=<your_newly_generated_public_key>
2018-04-23 08:48:33 -07:00
```
2018-04-23 09:35:03 -07:00
_IMPORTANT: We strongly recommend to **NOT** use the same passphrase for your different keys. The Tendermint team and the Interchain Foundation will not be responsible for the lost of funds._
2018-04-23 08:48:33 -07:00
2018-04-23 09:35:03 -07:00
## Getting Coins
Go to the faucet in [http://atomexplorer.com/](http://atomexplorer.com/) and claim some coins for your testnet by typing the address of your key, as printed out above.
2018-04-23 08:48:33 -07:00
2018-04-23 09:35:03 -07:00
## Send tokens
2018-04-23 08:48:33 -07:00
```
2018-04-23 09:35:03 -07:00
gaiacli send --from=$MYADDR --amount=1000fermion --chain-id=<name_of_testnet_chain> --sequence=1 --name=$KEYNAME --to=<destination_address>
```
The `--amount` flag defines the corresponding amount of the coin in the format `--amount=<value|coin_name>`
The `--sequence` flag corresponds to the sequence number to sign the tx.
2018-04-23 08:48:33 -07:00
2018-04-23 09:35:03 -07:00
Now check the destination account and your own account to check the updated balances \(by default the latest block\):
2018-04-23 08:48:33 -07:00
```
2018-04-23 09:35:03 -07:00
gaiacli account <destination_address>
gaiacli account $MYADDR
```
2018-04-23 08:48:33 -07:00
2018-04-23 09:35:03 -07:00
You can also check your balance at a given block by using the `--block` flag:
2018-04-23 08:48:33 -07:00
2018-04-23 09:35:03 -07:00
```
gaiacli account $MYADDR --block=<block_height>
2018-04-23 08:48:33 -07:00
```
2018-04-23 09:35:03 -07:00
##### Custom fee \(coming soon\)
2018-04-23 08:48:33 -07:00
2018-04-23 09:35:03 -07:00
You can also define a custom fee on the transaction by adding the `--fee` flag using the same format:
2018-04-23 08:48:33 -07:00
2018-04-23 09:35:03 -07:00
```
gaiacli send --from=$MYADDR --amount=1000fermion --fee=1fermion --chain-id=<name_of_testnet_chain> --sequence=1 --name=$KEYNAME --to=<destination_address>
```
### Transfer tokens to other chain
The command to`transfer`tokens to other chain is the same as`send`, we just need to add the`--chain`flag:
2018-04-23 08:48:33 -07:00
```
2018-04-23 09:35:03 -07:00
gaiacli transfer --from=$MYADDR --amount=20fermion --chain-id=<name_of_testnet_chain> --chain=<destination_chain> --sequence=1 --name=$KEYNAME --to=<sidechain_destination_address>
2018-04-23 08:48:33 -07:00
```
2018-04-23 09:35:03 -07:00
## Staking: Add a Validator
2018-04-23 08:48:33 -07:00
2018-04-23 09:35:03 -07:00
Get your public key by typing:
```
gaiad show_validator
```
2018-04-23 08:48:33 -07:00
2018-04-23 09:35:03 -07:00
The returned value is your validator address in hex. This can be used to create a new validator candidate by staking some tokens:
2018-04-23 08:48:33 -07:00
```
2018-04-23 09:35:03 -07:00
gaiacli declare-candidacy --amount=500fermions --pubkey=$PUBKEY --address-candidate=$MYADDR --moniker=satoshi --chain-id=<name_of_the_testnet_chain> --sequence=1 --name=$KEYNAME
2018-04-23 08:48:33 -07:00
```
2018-04-23 09:35:03 -07:00
You can add more information of the validator candidate such as`--website`, `--keybase-sig `or additional`--details`. If you want to edit the candidate info:
2018-04-23 08:48:33 -07:00
2018-04-23 09:35:03 -07:00
```
gaiacli edit-candidacy --details="To the cosmos !" --website="https://cosmos.network"
```
2018-04-23 08:48:33 -07:00
2018-04-23 09:35:03 -07:00
Finally, you can check all the candidate information by typing:
2018-04-23 08:48:33 -07:00
2018-04-23 09:35:03 -07:00
```
gaiacli candidate --address-candidate=$MYADDR --chain-id=<name_of_the_testnet_chain>
```
To check that the validator is active you can find it on the validator set list:
```
basecli validatorset <height>
```
2018-04-23 08:48:33 -07:00
2018-04-23 09:35:03 -07:00
\*_Note: Remember that to be in the validator set you need to have more total power than the Xnd validator, where X is the assigned size for the validator set \(by default _`X = 100`_\). _
2018-04-23 08:48:33 -07:00
2018-04-23 09:35:03 -07:00
#### Delegating: Bonding and unbonding to a validator
2018-04-23 08:48:33 -07:00
2018-04-23 09:35:03 -07:00
You can delegate \(i.e. bind\) **Atoms** to a validator to obtain a part of its fee revenue in exchange \(the fee token in the Cosmos Hub are **Photons**\).
2018-04-23 08:48:33 -07:00
```
2018-04-23 09:35:03 -07:00
gaiacli delegate --amount=10fermion --address-delegator=$MYADDR --address-candidate=<bonded_validator_address> --shares=MAX --name=$KEYNAME --chain-id=<name_of_testnet_chain> --sequence=1
```
If for any reason the validator misbehaves or you just want to unbond a certain amount of the bonded tokens:
```
gaiacli unbond --address-delegator=$MYADDR --address-candidate=<bonded_validator_address> --shares=MAX --name=$KEYNAME --chain-id=<name_of_testnet_chain> --sequence=1
```
You can unbond a specific amount of`shares`\(eg:`12.1`\) or all of them \(`MAX`\).
You should now see the unbonded tokens reflected in your balance and in your delegator bond :
```
gaiacli account $MYADDR
gaiacli delegator-bond --address-delegator=$MYADDR --address-candidate=<bonded_validator_address> --chain-id=<name_of_testnet_chain>
2018-04-23 08:48:33 -07:00
```
2018-04-23 09:35:03 -07:00
#### Relaying
2018-04-23 08:48:33 -07:00
2018-04-23 09:35:03 -07:00
Relaying is key to enable interoperability in the Cosmos Ecosystem. It allows IBC packets of data to be sent from one chain to another.
2018-04-23 08:48:33 -07:00
2018-04-23 09:35:03 -07:00
The command to relay packets is the following:
2018-04-23 08:48:33 -07:00
```
2018-04-23 09:35:03 -07:00
gaiacli relay --from-chain-id=<name_of_testnet_chain> --to-chain-id=<destination_chain_name> --from-chain-node=<host>:<port> --to-chain-node=<host>:<port> --name=$KEYNAME --sequence=1
2018-04-23 08:48:33 -07:00
```