Merge pull request #1057 from Kava-Labs/sh-docs-additions

restructured and improved docs
This commit is contained in:
samcode206 2021-12-06 15:47:29 -08:00 committed by GitHub
commit dc3c06d866
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
24 changed files with 1861 additions and 36 deletions

View File

@ -3,55 +3,68 @@ module.exports = {
title: "Kava Documentation",
themeConfig: {
logo: {
src: "/logo.svg",
src: "/logo.svg"
},
custom: true,
sidebar: {
auto: false,
nav: [
{
title: "Reference",
title: "Getting Started - Developers",
children: [
{
title: "Modules",
path: "/Modules",
directory: true
},
]
title: "Get Started",
path: "/education/getting_started.html"
},
{
title: "Kava Tools",
title: "Building Modules",
path: "/education/hello_kava.html"
},
{
title: "Javascript SDK",
path: "/building/javascript-sdk.html"
},
{
title: "Run Validator Node",
path: "/validator_guide"
},
{
title: "Run Bots",
children: [
{
title: "Chainlink Price Oracle",
path: "/tools/oracle.html"
},
{
title: "Community Tools",
path: "/tools/community.html",
},
{
title: "Sentinel",
path: "/tools/sentinel.html",
title: "Sentinel Bot",
path: "/tools/sentinel.html"
},
{
title: "Auction Bot",
path: "/tools/auction.html",
path: "/tools/auction.html"
}
]
},
{
title: "Building on Kava",
children: [
{
title: "JavaScript SDK",
path: "/building/javascript-sdk.html"
title: "Migration Guide",
path: "/kava-8",
directory: true
}
]
},
{
title: "Resources",
children: [
{
title: "Community Tools",
path: "/tools/community.html"
},
{
title: "Module Specs",
path: "/Modules",
directory: true,
},
{
title: "CLI Docs",
path: "/education/user_actions/",
directory: true,
},
{
title: "REST API Spec",
path: "https://swagger.kava.io/"
@ -92,8 +105,7 @@ module.exports = {
url: "https://github.com/kava-labs"
}
],
smallprint:
`© ${new Date().getFullYear()} Kava Labs.`,
smallprint: "© 2021 Kava Labs.",
links: [
{
title: "Community",
@ -113,8 +125,7 @@ module.exports = {
children: [
{
title: "Contributing to the docs",
url:
"https://github.com/Kava-Labs/kava/tree/master/docs"
url: "https://github.com/Kava-Labs/kava/tree/master/docs"
},
{
title: "Source code on GitHub",
@ -134,8 +145,8 @@ module.exports = {
url: "https://docs.binance.org"
}
]
},
}
]
}
}
};
}

View File

@ -0,0 +1,3 @@
# Application Process
We are working on updating our entire documentation to provide a better user experience, please check back later!

View File

@ -0,0 +1,3 @@
# Kava DAO Governance
We are working on updating our entire documentation to provide a better user experience, please check back later!

View File

@ -0,0 +1,3 @@
# Mainnet Upgrade
We are working on updating our entire documentation to provide a better user experience, please check back later!

View File

@ -0,0 +1,3 @@
# Testnet
We are working on updating our entire documentation to provide a better user experience, please check back later!

View File

@ -0,0 +1,88 @@
## Getting Started For Developers
In order for developers to start building modules, they must install the following tools:
1. [Go 1.6 or higher](https://golang.org/doc/install)
2. [Docker](https://docs.docker.com/get-docker/)
### Go Programming Language
Go is a language developed and used by some of the largest companies in the world for server/networking applications. Go is used to develop modules and provides optimum performance and flexibility to blockchain developers.
[A Tour Of Go](https://tour.golang.org/welcome/1)
### Docker
Docker is a software containerization tool used to spin up and shut down Kava nodes and allows software portability between different operating systems & environments. It is also used to spin up multiple Kava nodes locally and handles basic networking between them with `docker compose`.
[Docker Overview](https://docs.docker.com/get-started/overview/)
### Set Up bash_profile
Once Go & Docker are installed, update your bash_profile to include the go path and an alias command for one of the tools we will use to handle Kava node interactions
```
export PATH=/usr/local/go/bin:$PATH
export PATH=$HOME/go/bin:$PATH
export GOPATH=$HOME/go
export GO111MODULE=on
alias dkvcli='docker exec -it generated_kavanode_1 kvcli'
```
Make sure to source your bash profile or restart it for the changes to take place.
## Getting The Kava Repository & Development Tools
Once you have the core tools installed & set up, its now time to get the following repositories from Github:
- [kava](https://github.com/Kava-Labs/kava)
- Main Kava Repo that holds all modules
- [kvtool](https://github.com/Kava-Labs/kvtool)
- Dev tools to interact with a Kava node
## Set Up a Local Blockchain
Now that you have set up all the tools & repositories in your local machine its finally time to set up a local blockchain.
- Open a terminal and change into the ```kvtool``` directory.
- Ensure Docker is running.
- Run ```make install``` in your terminal which will install ```kvtool``` in your machine.
- Ensure Docker is running.
- Run ```kvtool testnet bootstrap``` this command will build against the master branch from the kava project, initialize the Docker containers and finally starts a local chain.
Now that you have a local chain running, you can start utilizing the ```dkvcli``` that we set up an alias for. If for whatever reason ```dkvcli``` doesn't work, you can try the following:
- Open a terminal and change into the ```kvtool``` directory.
- In the ```kvtool``` directory there should be a directory named ```full_configs``` change into it.
- Once at ```full_configs``` directory change into ```generated``` directory.
- Once you are at ```generated``` run the following command ```docker-compose exec kavanode bash```.
This should open up a bash terminal inside a docker container that will give you access to the ```kvcli``` command line interface. You should see something similar to the snippet below after typing ```kvcli help```:
```
bash-5.0# kvcli
Command line interface for interacting with kvd
Usage:
kvcli [command]
Available Commands:
status Query remote node for status
config Create or query an application CLI configuration file
query Querying subcommands
tx Transactions subcommands
rest-server Start LCD (light-client daemon), a local REST server
keys Add or view local private keys
version Print the app version
help Help about any command
Flags:
--chain-id string Chain ID of tendermint node
-e, --encoding string Binary encoding (hex|b64|btc) (default "hex")
-h, --help help for kvcli
--home string directory for config and data (default "/root/.kvcli")
-o, --output string Output format (text|json) (default "text")
--trace print out full stack trace on errors
Use "kvcli [command] --help" for more information about a command.
```

View File

@ -0,0 +1,777 @@
# Building a Module
In this tutorial we will be going over building a module in Kava to show how easy it is to build on top of the Kava ecosystem. This module will be simple in nature but will show how to set up and connect a module to Kava and can be used as a starting point for more complex modules.
## Set up
```
this tutorial is based on the v44 cosmos version which Kava is currently migrating to, to follow this tutorial clone the kava repo but ensure you
clone the upgrade-v44 branch as the master branch is currently on v39 & ensure you have kvtool, docker & go installed on your machine.
git clone -b upgrade-v44 https://github.com/Kava-Labs/kava.git
```
## Defining Protocol Buffer Types
The first step in building a new Kava Module is to define our Module's types. To do that we use Protocol Buffers which is a used for serializing structured data and generating code for multiple target languages, Protocol Buffers are also smaller than JSON & XML so sending data around the network will be less expensive. [Learn More](https://developers.google.com/protocol-buffers).
Our Protobuf files will all live in ```proto/kava``` directory. we will create a new directory with the new module ```greet``` and add the following files in the ```proto/greet/v1beta1/``` directory
```
genesis.proto
greet.proto
query.proto
tx.proto
```
### Defining The Greet Type
Inside the ```proto/greet/v1beta1/greet.proto``` file lets define our greet type:
```
syntax = "proto3";
package kava.greet.v1beta1;
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
option go_package = "github.com/kava-labs/kava/x/greet/types";
message Greet {
string owner = 1;
string id = 2;
string message = 3;
}
```
Here we are saying that we have a Greet type that will have an owner, an id and a message that will contain the greet string. Once we have that defined we are ready to set up a way to create this greet message and query it.
### Creating a new Greeting
Inside the ```proto/greet/v1beta1/tx.proto``` file lets define our Msg Type:
```
syntax = "proto3";
package kava.greet.v1beta1;
import "gogoproto/gogo.proto";
import "cosmos_proto/cosmos.proto";
option go_package = "github.com/kava-labs/kava/x/greet/types";
service Msg {
rpc CreateGreet(MsgCreateGreet) returns (MsgCreateGreetResponse);
}
message MsgCreateGreet {
string message = 1;
string owner = 2;
}
message MsgCreateGreetResponse {}
```
Now that we have defined how to create a new Greeting let's finish up by setting up our queries to view a specific greeting or all of them.
One thing to note here is that any state changing actions are transactions and for that reason we put them in our ```tx.proto``` files, we essentially said we are creating a new state changing message & defined the types for that message in our proto file, we will later add clients to trigger state change, which in our case will be adding a new message to our chain.
### Querying Greetings
Code inside the ```proto/greet/v1beta1/query.proto``` :
```
syntax = "proto3";
package kava.greet.v1beta1;
option go_package = "github.com/kava-labs/kava/x/greet/types";
import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "cosmos/base/query/v1beta1/pagination.proto";
import "cosmos_proto/cosmos.proto";
import "kava/greet/v1beta1/greet.proto";
service Query {
rpc Greet(QueryGetGreetRequest) returns (QueryGetGreetResponse) {
option (google.api.http).get = "/kava/greet/v1beta1/greetings/{id}";
}
rpc GreetAll(QueryAllGreetRequest) returns (QueryAllGreetResponse) {
option (google.api.http).get = "/kava/swap/v1beta1/greetings";
}
}
message QueryGetGreetRequest {
string id = 1;
}
message QueryGetGreetResponse {
Greet greeting = 1;
}
message QueryAllGreetRequest {
cosmos.base.query.v1beta1.PageRequest pagination = 1;
}
message QueryAllGreetResponse {
repeated Greet greetings = 1;
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}
```
Our ```query.proto``` now contains the types for our queries, we have defined a request type & a response type and those types will be returned once we trigger a query through the CLI, REST API, or Grpc. The response will follow the same structure regardless of the type of client initiating the request.
We defined our query, tx, and greet proto files we finally need to set up the genesis file and then we are ready to generate these types. In the genesis file we will create a minimal ```genesis.proto``` for this tutorial to keep things simple.
```
syntax = "proto3";
package kava.greet.v1beta1;
import "kava/greet/v1beta1/greet.proto";
import "gogoproto/gogo.proto";
import "google/protobuf/timestamp.proto";
import "cosmos_proto/cosmos.proto";
option go_package = "github.com/kava-labs/kava/x/greet/types";
// our gensis state message will be empty for this tutorial
message GenesisState {}
```
Once all the files are filled in we are ready to generate our proto types. in the Kava Directory run ```make proto-gen ``` to generate the types, this will create a folder inside the ```x/greet``` and will contain the auto-generated proto types.
## Developing Our Greet Module
we have successfully set up our Proto files & generated them, we now have a ```x/greet``` directory generated, this is where we will write our module's code. For starters we will define our module's types in a new file inside ```x/greet/types/greet.go```.
### Setting up constants & importing packages
Let's set up some basic constants for our module to help with routing, & fetching items from our store.
```
package types
import (
"fmt"
"strings"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/types/msgservice"
)
// defined our module's constants such as name, routerkey
// and prefixes for getting items from the store
const (
ModuleName = "greet"
StoreKey = ModuleName
RouterKey = ModuleName
QuerierRoute = ModuleName
GreetKey = "greet-value-" // used for getting a greeting from our store
GreetCountKey = "greet-count-" // used for getting count from out store
QueryGetGreeting = "get-greeting" // used for legacy querier routing
QueryListGreetings = "list-greetings"// used for legacy querier routing
)
// heler function simply returns []byte out of a prefix string
func KeyPrefix(p string) []byte {
return []byte(p)
}
// returns default genesis state
func DefaultGenesisState() GenesisState {
return GenesisState{}
}
// validates genesis state
func (gs GenesisState) Validate() error {
return nil
}
```
### Setting up our Msg for creating a new greeting
Our ```MsgCreateGreet``` struct was created when we generated our Proto Types, we now need to use that struct to implement the ```sdk.Msg``` interface such that we can create new greetings. the first thing we will do is defined an unnamed variable with the ```_``` syntax and have it implement the ```sdk.Msg``` type. This will help us catch unimplemented functions and guide us with syntax highlighting.
```
// MsgCreateGreet we defined it here to get type checking
//to make sure we are immplementing it correctly
var _ sdk.Msg = &MsgCreateGreet{}
// constructor for creating a new greeting
func NewMsgCreateGreet(owner string, message string) *MsgCreateGreet{
return &MsgCreateGreet{
Owner: owner,
Message: message,
}
}
// does a quick stateless validation on our new greeting
func (m *MsgCreateGreet) ValidateBasic() error {
// ensures address is valid
if _, err := sdk.AccAddressFromBech32(m.Owner); err != nil {
return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid owner address", err)
}
// ensures the greeting is not empty
if len(strings.TrimSpace(m.Message)) == 0 {
return fmt.Errorf("must provide a greeting message")
}
return nil
}
// gets the signer of the new message which will be the owner of the greeting
func (m *MsgCreateGreet) GetSigners() []sdk.AccAddress {
owner, err := sdk.AccAddressFromBech32(m.Owner);
if err != nil {
panic(err)
}
return []sdk.AccAddress{owner}
}
```
### Registering our Codec & interfaces
now that we have our ```MsgCreateGreet``` implement the ```sdk.Msg``` interface let's register our codec for marshaling/unmarshaling our greeting we will register both the deprecated legacy amino and the new Interface registry.
```
// registers the marshal/unmarsahl for greating a new greeting for our legacy amino codec
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino){
cdc.RegisterConcrete(&MsgCreateGreet{}, "greet/CreateGreet", nil)
}
// registers a module's interface types and their concrete implementations as proto.Message.
func RegisterInterfaces(registry types.InterfaceRegistry){
registry.RegisterImplementations((*sdk.Msg)(nil), &MsgCreateGreet{})
msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
}
var amino = codec.NewLegacyAmino()
var ModuleCdc = codec.NewAminoCodec(amino)
```
### Setting up a basic Keeper
we have finished up setting up our types, now it's time to implement our greet module's keeper, lets do that in a new folder & package named keeper, create ```x/greet/keeper/greet_keeper.go``` .
### Setting up the Keeper Struct & imports
keepers are an abstraction over the state defined by a module, every module would have a keeper which would be used to access the state of that module, or if given access a keeper can also use other module's keepers by providing reference to the other module's keeper.
```
package keeper
import (
"context"
"strconv"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/store/prefix"
sdk "github.com/cosmos/cosmos-sdk/types"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/kava-labs/kava/x/greet/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)
type Keeper struct {
cdc codec.Codec // used to marshall and unmarshall structs from & to []byte
key sdk.StoreKey // grant access to the store
}
// our constructor for creating a new Keeper for this module
func NewKeeper(c codec.Codec, k sdk.StoreKey) Keeper {
return Keeper{
cdc: c,
key: k,
}
}
```
### Wiring up our methods for handling new transactions & queries
Now that we have our Keeper Struct written, let's create some receiver functions on our keeper to handle adding a new greeting & looking up a greeting.
```
// get greet count will be used for setting an Id when a new greeting is created
func (k Keeper) GetGreetCount(ctx sdk.Context) int64 {
store := prefix.NewStore(ctx.KVStore(k.key), types.KeyPrefix(types.GreetCountKey))
byteKey := types.KeyPrefix(types.GreetCountKey)
bz := store.Get(byteKey)
if bz == nil {
return 0
}
count, err := strconv.ParseInt(string(bz), 10, 64)
if err != nil {
panic("cannot decode count")
}
return count
}
// sets the greet count
func (k Keeper) SetGreetCount(ctx sdk.Context, count int64){
store := prefix.NewStore(ctx.KVStore(k.key), types.KeyPrefix(types.GreetCountKey))
key := types.KeyPrefix(types.GreetCountKey)
value := []byte(strconv.FormatInt(count, 10))
store.Set(key, value)
}
// creates a new greeting
func (k Keeper) CreateGreet(ctx sdk.Context, m types.MsgCreateGreet){
count := k.GetGreetCount(ctx)
greet := types.Greet{
Id: strconv.FormatInt(count, 10),
Owner: m.Owner,
Message: m.Message,
}
store := prefix.NewStore(ctx.KVStore(k.key), types.KeyPrefix(types.GreetKey))
key := types.KeyPrefix(types.GreetKey + greet.Id)
value := k.cdc.MustMarshal(&greet)
store.Set(key, value)
k.SetGreetCount(ctx, count + 1)
}
// gets a greeting from the store
func (k Keeper) GetGreeting(ctx sdk.Context, key string) types.Greet {
store := prefix.NewStore(ctx.KVStore(k.key), types.KeyPrefix(types.GreetKey))
var Greet types.Greet
k.cdc.Unmarshal(store.Get(types.KeyPrefix(types.GreetKey + key)), &Greet)
return Greet
}
// checks if a greeting exists by an id
func (k Keeper) HasGreet(ctx sdk.Context, id string) bool {
store := prefix.NewStore(ctx.KVStore(k.key), types.KeyPrefix(types.GreetKey))
return store.Has(types.KeyPrefix(types.GreetKey + id))
}
// gets the owner of a greeting
func (k Keeper) GetGreetOwner(ctx sdk.Context, key string) string {
return k.GetGreeting(ctx, key).Owner
}
// gets a list of all greetings in the store
func (k Keeper) GetAllGreetings(ctx sdk.Context) (msgs []types.Greet){
store := prefix.NewStore(ctx.KVStore(k.key), types.KeyPrefix(types.GreetKey))
iterator := sdk.KVStorePrefixIterator(store, types.KeyPrefix(types.GreetKey))
defer iterator.Close()
for ; iterator.Valid(); iterator.Next() {
var msg types.Greet
k.cdc.Unmarshal(iterator.Value(), &msg)
msgs = append(msgs, msg)
}
return
}
```
### Handling queries
We have added methods for interacting with greetings such as creating or reading them, now let's set up our two query services so we can route them to the correct method, we will set up our legacy Querier & gRPC querier below the methods we defined above on our keeper.
```
func (k Keeper) GreetAll(c context.Context, req *types.QueryAllGreetRequest) (*types.QueryAllGreetResponse, error){
ctx := sdk.UnwrapSDKContext(c)
var greetings []*types.Greet
for _, g := range k.GetAllGreetings(ctx) {
var greeting = &g
greetings = append(greetings,greeting)
}
return &types.QueryAllGreetResponse{Greetings: greetings, Pagination: nil}, nil
}
func (k Keeper) Greet(c context.Context, req *types.QueryGetGreetRequest) (*types.QueryGetGreetResponse, error){
sdk.UnwrapSDKContext(c)
var greeting = k.GetGreeting(sdk.UnwrapSDKContext(c), req.Id)
return &types.QueryGetGreetResponse{Greeting: &greeting}, nil
}
// LEGACY QUERIER will be deperacted but for the sake of competeness this is how to set it up
func NewQuerier(k Keeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier {
return func(ctx sdk.Context, path []string, req abci.RequestQuery) ([]byte, error) {
switch path[0] {
case types.QueryGetGreeting:
var getGreetRequest types.QueryGetGreetRequest
err := legacyQuerierCdc.UnmarshalJSON(req.Data, &getGreetRequest)
if err != nil {
return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error())
}
val := k.GetGreeting(ctx, getGreetRequest.GetId())
bz, err := legacyQuerierCdc.MarshalJSON(val)
if err != nil {
return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error())
}
return bz, nil
case types.QueryListGreetings:
val := k.GetAllGreetings(ctx)
bz, err := codec.MarshalJSONIndent(legacyQuerierCdc, val)
if err != nil {
return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error())
}
return bz, nil
default:
return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unknow request at %s query endpoint", types.ModuleName)
}
}
}
```
### Setting up a command to create a new greeting
let's set up a way for clients to submit a new greeting & query existing greetings, we can do that with a CLI, REST, & gRPC clients. for this tutorial we will focus on setting up our CLI client. create ```x/greet/client/cli/tx.go```.
here We will define a command to create a new greeting:
```
package cli
import (
"fmt"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/client/tx"
"github.com/kava-labs/kava/x/greet/types"
"github.com/spf13/cobra"
)
func GetTxCmd() *cobra.Command {
cmd := &cobra.Command{
Use: types.ModuleName,
Short: fmt.Sprintf("%s transactions subcommands", types.ModuleName),
DisableFlagParsing: true,
SuggestionsMinimumDistance: 2,
RunE: client.ValidateCmd,
}
cmd.AddCommand(CmdCreateGreeting())
return cmd
}
func CmdCreateGreeting() *cobra.Command {
cmd:= &cobra.Command{
Use: "create-greeting [message]",
Short: "creates a new greetings",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
message := string(args[0])
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}
msg := types.NewMsgCreateGreet(clientCtx.GetFromAddress().String(), string(message))
if err := msg.ValidateBasic(); err != nil {
return err
}
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
},
}
flags.AddTxFlagsToCmd(cmd)
return cmd
}
```
### Querying greetings
We will now set up two different commands for querying, one will be to list all greetings & the other will be to get a greeting by it's id. inside ```x/greet/cli/query.go```:
```
package cli
import (
"context"
"fmt"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/kava-labs/kava/x/greet/types"
"github.com/spf13/cobra"
)
// this is the parent query command for the greet module everytime we add a new command we will register it here
func GetQueryCmd(queryRoute string) *cobra.Command {
// Group todos queries under a subcommand
cmd := &cobra.Command{
Use: types.ModuleName,
Short: fmt.Sprintf("Querying commands for the %s module", types.ModuleName),
DisableFlagParsing: true,
SuggestionsMinimumDistance: 2,
RunE: client.ValidateCmd,
}
cmd.AddCommand(CmdListGreetings())
cmd.AddCommand(CmdShowGreeting())
return cmd
}
// build the list greet command function
func CmdListGreetings() *cobra.Command {
cmd := &cobra.Command{
Use: "list-greetings",
Short: "list all greetings",
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}
pageReq, err := client.ReadPageRequest(cmd.Flags())
if err != nil {
return err
}
queryClient := types.NewQueryClient(clientCtx)
params := &types.QueryAllGreetRequest{
Pagination: pageReq,
}
res, err := queryClient.GreetAll(context.Background(), params)
if err != nil {
return err
}
return clientCtx.PrintProto(res)
},
}
flags.AddQueryFlagsToCmd(cmd)
return cmd
}
// build the show greet command function
func CmdShowGreeting() *cobra.Command {
cmd := &cobra.Command{
Use: "get-greeting [id]",
Short: "shows a greeting",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}
queryClient := types.NewQueryClient(clientCtx)
params := &types.QueryGetGreetRequest{
Id: args[0],
}
res, err := queryClient.Greet(context.Background(), params)
if err != nil {
return err
}
return clientCtx.PrintProto(res)
},
}
flags.AddQueryFlagsToCmd(cmd)
return cmd
}
```
### Setting up our Module's package
Now that we have all the basic functionality set up for our greet module, let's bring it all together and get our module ready to be used & tested, create a new file ```x/greet/module.go```.
Here we will start by implementing our ```AppModuleBasic``` && ```AppModule``` interfaces.
```
package greet
import (
"context"
"encoding/json"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
cdctypes "github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/gorilla/mux"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/kava-labs/kava/x/greet/client/cli"
"github.com/kava-labs/kava/x/greet/keeper"
"github.com/kava-labs/kava/x/greet/types"
"github.com/spf13/cobra"
abci "github.com/tendermint/tendermint/abci/types"
)
var (
_ module.AppModule = AppModule{}
_ module.AppModuleBasic = AppModuleBasic{}
)
/*
The AppModuleBasic interface defines the independent methods modules need to implement
it follows this interface below
type AppModuleBasic interface {
Name() string
RegisterLegacyAminoCodec(*codec.LegacyAmino)
RegisterInterfaces(codectypes.InterfaceRegistry)
DefaultGenesis(codec.JSONMarshaler) json.RawMessage
ValidateGenesis(codec.JSONMarshaler, client.TxEncodingConfig, json.RawMessage) error
// client functionality
RegisterRESTRoutes(client.Context, *mux.Router)
RegisterGRPCRoutes(client.Context, *runtime.ServeMux)
GetTxCmd() *cobra.Command
GetQueryCmd() *cobra.Command
}
*/
type AppModuleBasic struct{}
// Returns the name of the module as a string
func (AppModuleBasic) Name() string {
return types.ModuleName
}
func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage {
gs := types.DefaultGenesisState()
return cdc.MustMarshalJSON(&gs)
}
func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error {
return nil
}
// Registers the amino codec for the module, which is used to marshal
// and unmarshal structs to/from []byte in order to persist them in the module's KVStore.
func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino){
types.RegisterLegacyAminoCodec(cdc)
}
// Registers a module's interface types and their concrete implementations as proto.Message
func (AppModuleBasic) RegisterInterfaces(registry cdctypes.InterfaceRegistry) {
types.RegisterInterfaces(registry)
}
// Registers gRPC routes for the module.
func (a AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) {
if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil {
panic(err)
}
}
// Registers the REST routes for the module. These routes will be used to map REST request to the module in order to process them
func (a AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) { }
// Returns the root Tx command for the module. The subcommands of this root command are used by end-users
// to generate new transactions containing messages defined in the module
func (AppModuleBasic) GetTxCmd() *cobra.Command {
return cli.GetTxCmd()
}
// Return the root query command for the module. The subcommands of this root command are used by end-users
// to generate new queries to the subset of the state defined by the module.
func (AppModuleBasic) GetQueryCmd() *cobra.Command {
return cli.GetQueryCmd(types.StoreKey)
}
// -------------------------------------APPMODULE BELOW------------------------------------------------- //
/*
The AppModule interface defines the inter-dependent methods that modules need to implement
follows the interface below
type AppModule interface {
AppModuleGenesis
// registers
RegisterInvariants(sdk.InvariantRegistry)
// routes
Route() sdk.Route
// Deprecated: use RegisterServices
QuerierRoute() string
// Deprecated: use RegisterServices
LegacyQuerierHandler(*codec.LegacyAmino) sdk.Querier
// RegisterServices allows a module to register services
RegisterServices(Configurator)
// ABCI
BeginBlock(sdk.Context, abci.RequestBeginBlock)
EndBlock(sdk.Context, abci.RequestEndBlock) []abci.ValidatorUpdate
}
*/
type AppModule struct{
AppModuleBasic
keeper keeper.Keeper
}
// constructor
func NewAppModule(keeper keeper.Keeper) AppModule {
return AppModule{
AppModuleBasic: AppModuleBasic{},
keeper: keeper,
}
}
// Returns the route for messages to be routed to the module by BaseApp.
func (am AppModule) Name() string {
return am.AppModuleBasic.Name()
}
// registers the invariants of the module. If an invariant deviates from its predicted value,
// the InvariantRegistry triggers appropriate logic (most often the chain will be halted).
func (AppModule) RegisterInvariants(ir sdk.InvariantRegistry) { }
// Returns the route for messages to be routed to the module by BaseApp.
func (AppModule) Route() sdk.Route {
return sdk.Route{}
}
// Returns the name of the module's query route, for queries to be routes to the module by BaseApp.deprecated
func (AppModule) QuerierRoute() string {
return types.QuerierRoute
}
// Returns a querier given the query path, in order to process the query.
func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sdk.Querier {
return keeper.NewQuerier(am.keeper, legacyQuerierCdc)
}
func (AppModule) ConsensusVersion() uint64 {
return 1
}
// Allows a module to register services.
func (am AppModule) RegisterServices(cfg module.Configurator) {
types.RegisterMsgServer(cfg.MsgServer(), NewMsgServerImpl(am.keeper))
types.RegisterQueryServer(cfg.QueryServer(), am.keeper)
}
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.RawMessage) []abci.ValidatorUpdate {
return []abci.ValidatorUpdate{}
}
func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage {
gs := types.DefaultGenesisState()
return cdc.MustMarshalJSON(&gs)
}
func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) { }
func (am AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate {
return []abci.ValidatorUpdate{}
}
// ----------------------------------MSGSERVER REGISTER------------------------//
var _ types.MsgServer = msgServer{}
type msgServer struct {
keeper keeper.Keeper
}
func (m msgServer) CreateGreet(c context.Context, msg *types.MsgCreateGreet) (*types.MsgCreateGreetResponse, error) {
ctx := sdk.UnwrapSDKContext(c)
m.keeper.CreateGreet(ctx, types.MsgCreateGreet{Owner: msg.Owner, Message: msg.Message})
return &types.MsgCreateGreetResponse{}, nil
}
func NewMsgServerImpl(keeper keeper.Keeper) types.MsgServer {
return &msgServer{keeper: keeper}
}
```
### Hooking up our module inside App.go
inside ```app/app.go``` start off importing the greet module, it's types & keeper packages and add them to the following places:
1. ```module.NewBasicManager()``` add ```greet.AppModuleBasic{}```
2. ```type App struct {}``` add ```greetkeeper.Keeper```
3. ```sdk.NewKVStoreKeys()``` inside ```NewApp``` func add ```greettypes.StoreKey```
4. inside ```NewApp``` func add ```app.greetKeeper = greetKeeper.NewKeeper()``` and add arguments ```appCodec``` & ```keys[greettypes.StoreKey]```
5. inside ```NewApp``` find where we define ```app.mm``` & add ```greet.NewAppModule(app.greetKeeper),```
6. finally add the greet module's name to ```SetOrderBeginBlockers```, ```SetOrderEndBlockers``` && ```SetOrderInitGenesis```
## Testing our new Module
1. inside the root of our directory run ```docker build -t kava/kava:tutorial-demo .```
2. find the directory for ```kvtool``` and open in your favorite code editor
3. run ```kvtool testnet gen-config kava --kava.configTemplate upgrade-v44``` which will create a bunch of files inside ```full_configs/generated```
4. open up the two ```docker-compose.yaml``` files the one inside ```generated``` & the one inside ```generated/kava``` and change the image to point to ```kava/kava:tutorial-demo``` this will point to the local image we just built
5. change into the ```full_configs/generated``` directory and run ```docker compose up -d```
6. now run ```docker compose exec kavanode bash``` to bash into our ```kava``` cli inside the running container
We should now have access to our greet commands that we defined first we will test creating a new greeting, for that we will run the following command:
```kava tx greet create-greeting "hello world from kava chain" --from whale```
now let's test to see if the greeting message is able to be queried:
```kava q greet list-greetings```
We should see something like this below:
```
greetings:
- id: "0"
message: hello world from kava chain
owner: kava173w2zz287s36ewnnkf4mjansnthnnsz7rtrxqc
pagination: null
```
Now let's test if we can query the greeting by it's id which in our case will be ```"0"```, run the following:
```kava q greet get-greeting 0```
We should see:
```
greeting:
id: "0"
message: hello world from kava chain
owner: kava173w2zz287s36ewnnkf4mjansnthnnsz7rtrxqc
```

View File

@ -0,0 +1,3 @@
# Lite Paper
We are working on updating our entire documentation to provide a better user experience, please check back later!

View File

@ -0,0 +1,50 @@
<!--
title: vote
-->
## kvcli tx committee vote
Vote for an active proposal
### Synopsis
Submit a ```[yes/no/abstain]``` vote for the proposal with id ```[proposal-id]```.
```
kvcli tx committee vote [proposal-id] [vote] [flags]
```
### Examples
```
kvcli tx committee vote 2 yes
```
### Options
```
-a, --account-number uint The account number of the signing account (offline mode only)
-b, --broadcast-mode string Transaction broadcasting mode (sync|async|block) (default "sync")
--dry-run ignore the --gas flag and perform a simulation of a transaction, but don't broadcast it
--fees string Fees to pay along with transaction; eg: 10uatom
--from string Name or address of private key with which to sign
--gas string gas limit to set per-transaction; set to "auto" to calculate required gas automatically (default 200000) (default "200000")
--gas-adjustment float adjustment factor to be multiplied against the estimate returned by the tx simulation; if the gas limit is set manually this flag is ignored (default 1)
--gas-prices string Gas prices to determine the transaction fee (e.g. 10uatom)
--generate-only Build an unsigned transaction and write it to STDOUT (when enabled, the local Keybase is not accessible and the node operates offline)
-h, --help help for vote
--indent Add indent to JSON response
--keyring-backend string Select keyring's backend (os|file|test) (default "os")
--ledger Use a connected Ledger device
--memo string Memo to send along with transaction
--node string <host>:<port> to tendermint rpc interface for this chain (default "tcp://localhost:26657")
-s, --sequence uint The sequence number of the signing account (offline mode only)
--trust-node Trust connected full node (don't verify proofs for responses) (default true)
-y, --yes Skip tx broadcasting prompt confirmation
```
### Options inherited from parent commands
```
--chain-id string Chain ID of tendermint node
```

View File

@ -0,0 +1,95 @@
<!--
title: committee
-->
## kvcli tx gov submit-proposal committee
Submit a governance proposal to change a committee.
### Synopsis
Submit a governance proposal to create, alter, or delete a committee.
The proposal file must be the json encoded form of the proposal type you want to submit.
For example, to create or update a committee:
```
{
"type": "kava/CommitteeChangeProposal",
"value": {
"title": "A Title",
"description": "A description of this proposal.",
"new_committee": {
"type": "kava/MemberCommittee",
"value": {
"base_committee": {
"id": "1",
"description": "The description of this committee.",
"members": [
"kava182k5kyx9sy4ap624gm9gukr3jfj7fdx8jzrdgq"
],
"permissions": [
{
"type": "kava/SimpleParamChangePermission",
"value": {
"allowed_params": [
{
"subspace": "cdp",
"key": "CircuitBreaker"
}
]
}
}
],
"vote_threshold": "0.800000000000000000",
"proposal_duration": "604800000000000",
"tally_option": "FirstPastThePost"
}
}
}
}
}
```
and to delete a committee:
```
{
"type": "kava/CommitteeDeleteProposal",
"value": {
"title": "A Title",
"description": "A description of this proposal.",
"committee_id": "1"
}
}
```
```
kvcli tx gov submit-proposal committee [proposal-file] [deposit] [flags]
```
### Options
```
-a, --account-number uint The account number of the signing account (offline mode only)
-b, --broadcast-mode string Transaction broadcasting mode (sync|async|block) (default "sync")
--dry-run ignore the --gas flag and perform a simulation of a transaction, but don't broadcast it
--fees string Fees to pay along with transaction; eg: 10uatom
--from string Name or address of private key with which to sign
--gas string gas limit to set per-transaction; set to "auto" to calculate required gas automatically (default 200000) (default "200000")
--gas-adjustment float adjustment factor to be multiplied against the estimate returned by the tx simulation; if the gas limit is set manually this flag is ignored (default 1)
--gas-prices string Gas prices to determine the transaction fee (e.g. 10uatom)
--generate-only Build an unsigned transaction and write it to STDOUT (when enabled, the local Keybase is not accessible and the node operates offline)
-h, --help help for committee
--indent Add indent to JSON response
--keyring-backend string Select keyring's backend (os|file|test) (default "os")
--ledger Use a connected Ledger device
--memo string Memo to send along with transaction
--node string <host>:<port> to tendermint rpc interface for this chain (default "tcp://localhost:26657")
-s, --sequence uint The sequence number of the signing account (offline mode only)
--trust-node Trust connected full node (don't verify proofs for responses) (default true)
-y, --yes Skip tx broadcasting prompt confirmation
```
### Options inherited from parent commands
```
--chain-id string Chain ID of tendermint node
```

View File

@ -0,0 +1,80 @@
<!--
title: param-change
-->
## kvcli tx gov submit-proposal param-change
Submit a parameter change proposal
### Synopsis
Submit a parameter proposal along with an initial deposit.
The proposal details must be supplied via a JSON file. For values that contains
objects, only non-empty fields will be updated.
IMPORTANT: Currently parameter changes are evaluated but not validated, so it is
very important that any "value" change is valid (ie. correct type and within bounds)
for its respective parameter, eg. "MaxValidators" should be an integer and not a decimal.
Proper vetting of a parameter change proposal should prevent this from happening
(no deposits should occur during the governance process), but it should be noted
regardless.
Example:
```
$ kvcli tx gov submit-proposal param-change <path/to/proposal.json> --from=<key_or_address>
```
Where proposal.json contains:
```
{
"title": "Staking Param Change",
"description": "Update max validators",
"changes": [
{
"subspace": "staking",
"key": "MaxValidators",
"value": 105
}
],
"deposit": [
{
"denom": "stake",
"amount": "10000"
}
]
}
```
```
kvcli tx gov submit-proposal param-change [proposal-file] [flags]
```
### Options
```
-a, --account-number uint The account number of the signing account (offline mode only)
-b, --broadcast-mode string Transaction broadcasting mode (sync|async|block) (default "sync")
--dry-run ignore the --gas flag and perform a simulation of a transaction, but don't broadcast it
--fees string Fees to pay along with transaction; eg: 10uatom
--from string Name or address of private key with which to sign
--gas string gas limit to set per-transaction; set to "auto" to calculate required gas automatically (default 200000) (default "200000")
--gas-adjustment float adjustment factor to be multiplied against the estimate returned by the tx simulation; if the gas limit is set manually this flag is ignored (default 1)
--gas-prices string Gas prices to determine the transaction fee (e.g. 10uatom)
--generate-only Build an unsigned transaction and write it to STDOUT (when enabled, the local Keybase is not accessible and the node operates offline)
-h, --help help for param-change
--indent Add indent to JSON response
--keyring-backend string Select keyring's backend (os|file|test) (default "os")
--ledger Use a connected Ledger device
--memo string Memo to send along with transaction
--node string <host>:<port> to tendermint rpc interface for this chain (default "tcp://localhost:26657")
-s, --sequence uint The sequence number of the signing account (offline mode only)
--trust-node Trust connected full node (don't verify proofs for responses) (default true)
-y, --yes Skip tx broadcasting prompt confirmation
```
### Options inherited from parent commands
```
--chain-id string Chain ID of tendermint node
```

View File

@ -0,0 +1,50 @@
# Borrow
Borrow tokens from the hard protocol
## Command
```
kvcli tx hard borrow <amount> <flags>
```
Using ```kvcli``` call the ```tx``` subcommand followed by the module name which is```hard```, then define the action which is ```borrow``` and finally follow up with required arguments or flags.
### Arguments
position|name|expects
|--|--|--|
1|amount| amount & name (no spaces)
### Example
```
kvcli tx hard borrow 1000000000ukava --from <key>
```
### Options
```
-a, --account-number uint The account number of the signing account (offline mode only)
-b, --broadcast-mode string Transaction broadcasting mode (sync|async|block) (default "sync")
--dry-run ignore the --gas flag and perform a simulation of a transaction, but don't broadcast it
--fees string Fees to pay along with transaction; eg: 10uatom
--from string Name or address of private key with which to sign
--gas string gas limit to set per-transaction; set to "auto" to calculate required gas automatically (default 200000) (default "200000")
--gas-adjustment float adjustment factor to be multiplied against the estimate returned by the tx simulation; if the gas limit is set manually this flag is ignored (default 1)
--gas-prices string Gas prices to determine the transaction fee (e.g. 10uatom)
--generate-only Build an unsigned transaction and write it to STDOUT (when enabled, the local Keybase is not accessible and the node operates offline)
-h, --help help for borrow
--indent Add indent to JSON response
--keyring-backend string Select keyring's backend (os|file|test) (default "os")
--ledger Use a connected Ledger device
--memo string Memo to send along with transaction
--node string <host>:<port> to tendermint rpc interface for this chain (default "tcp://localhost:26657")
-s, --sequence uint The sequence number of the signing account (offline mode only)
--trust-node Trust connected full node (don't verify proofs for responses) (default true)
-y, --yes Skip tx broadcasting prompt confirmation
```
### Options inherited from parent commands
```
--chain-id string Chain ID of tendermint node
```

View File

@ -0,0 +1,53 @@
# Deposit
Deposit coins to hard
## Command
```
kvcli tx hard deposit <amount> <flags>
```
Using ```kvcli``` call the ```tx``` subcommand followed by the module name which is```hard```, then define the action which is ```deposit``` and finally follow up with required arguments or flags.
### Arguments
position|name|expects
|--|--|--|
1|amount| amount & name (no spaces)
### Example
```
kvcli tx hard deposit 10000000bnb --from <key>
```
### Options
```
-a, --account-number uint The account number of the signing account (offline mode only)
-b, --broadcast-mode string Transaction broadcasting mode (sync|async|block) (default "sync")
--dry-run ignore the --gas flag and perform a simulation of a transaction, but don't broadcast it
--fees string Fees to pay along with transaction; eg: 10uatom
--from string Name or address of private key with which to sign
--gas string gas limit to set per-transaction; set to "auto" to calculate required gas automatically (default 200000) (default "200000")
--gas-adjustment float adjustment factor to be multiplied against the estimate returned by the tx simulation; if the gas limit is set manually this flag is ignored (default 1)
--gas-prices string Gas prices to determine the transaction fee (e.g. 10uatom)
--generate-only Build an unsigned transaction and write it to STDOUT (when enabled, the local Keybase is not accessible and the node operates offline)
-h, --help help for deposit
--indent Add indent to JSON response
--keyring-backend string Select keyring's backend (os|file|test) (default "os")
--ledger Use a connected Ledger device
--memo string Memo to send along with transaction
--node string <host>:<port> to tendermint rpc interface for this chain (default "tcp://localhost:26657")
-s, --sequence uint The sequence number of the signing account (offline mode only)
--trust-node Trust connected full node (don't verify proofs for responses) (default true)
-y, --yes Skip tx broadcasting prompt confirmation
```
### Options inherited from parent commands
```
--chain-id string Chain ID of tendermint node
```

View File

@ -0,0 +1,56 @@
# Repay
Repay tokens to the hard protocol
## Command
```
kvcli tx hard repay <amount> <flags>
```
Using ```kvcli``` call the ```tx``` subcommand followed by the module name which is```hard```, then define the action which is ```repay``` and finally follow up with required arguments or flags.
### Arguments
position|name|expects
|--|--|--|
1|amount| amount & name (no spaces)
### Example
```
kvcli tx hard repay 1000000000ukava --from <key>
kvcli tx hard repay 1000000000ukava,25000000000bnb --from <key>
kvcli tx hard repay 1000000000ukava,25000000000bnb --owner <owner-address> --from <key>
```
### Options
```
-a, --account-number uint The account number of the signing account (offline mode only)
-b, --broadcast-mode string Transaction broadcasting mode (sync|async|block) (default "sync")
--dry-run ignore the --gas flag and perform a simulation of a transaction, but don't broadcast it
--fees string Fees to pay along with transaction; eg: 10uatom
--from string Name or address of private key with which to sign
--gas string gas limit to set per-transaction; set to "auto" to calculate required gas automatically (default 200000) (default "200000")
--gas-adjustment float adjustment factor to be multiplied against the estimate returned by the tx simulation; if the gas limit is set manually this flag is ignored (default 1)
--gas-prices string Gas prices to determine the transaction fee (e.g. 10uatom)
--generate-only Build an unsigned transaction and write it to STDOUT (when enabled, the local Keybase is not accessible and the node operates offline)
-h, --help help for repay
--indent Add indent to JSON response
--keyring-backend string Select keyring's backend (os|file|test) (default "os")
--ledger Use a connected Ledger device
--memo string Memo to send along with transaction
--node string <host>:<port> to tendermint rpc interface for this chain (default "tcp://localhost:26657")
--owner string original borrower's address whose loan will be repaid
-s, --sequence uint The sequence number of the signing account (offline mode only)
--trust-node Trust connected full node (don't verify proofs for responses) (default true)
-y, --yes Skip tx broadcasting prompt confirmation
```
### Options inherited from parent commands
```
--chain-id string Chain ID of tendermint node
```

View File

@ -0,0 +1,53 @@
# Withdraw
Withdraw coins from hard
## Command
```
kvcli tx hard withdraw <amount> <flags>
```
Using ```kvcli``` call the ```tx``` subcommand followed by the module name which is```hard```, then define the action which is ```withdraw``` and finally follow up with required arguments or flags.
### Arguments
position|name|expects
|--|--|--|
1|amount| amount & name (no spaces)
### Example
```
kvcli tx hard withdraw 10000000bnb --from <key>
```
### Options
```
-a, --account-number uint The account number of the signing account (offline mode only)
-b, --broadcast-mode string Transaction broadcasting mode (sync|async|block) (default "sync")
--dry-run ignore the --gas flag and perform a simulation of a transaction, but don't broadcast it
--fees string Fees to pay along with transaction; eg: 10uatom
--from string Name or address of private key with which to sign
--gas string gas limit to set per-transaction; set to "auto" to calculate required gas automatically (default 200000) (default "200000")
--gas-adjustment float adjustment factor to be multiplied against the estimate returned by the tx simulation; if the gas limit is set manually this flag is ignored (default 1)
--gas-prices string Gas prices to determine the transaction fee (e.g. 10uatom)
--generate-only Build an unsigned transaction and write it to STDOUT (when enabled, the local Keybase is not accessible and the node operates offline)
-h, --help help for withdraw
--indent Add indent to JSON response
--keyring-backend string Select keyring's backend (os|file|test) (default "os")
--ledger Use a connected Ledger device
--memo string Memo to send along with transaction
--node string <host>:<port> to tendermint rpc interface for this chain (default "tcp://localhost:26657")
-s, --sequence uint The sequence number of the signing account (offline mode only)
--trust-node Trust connected full node (don't verify proofs for responses) (default true)
-y, --yes Skip tx broadcasting prompt confirmation
```
### Options inherited from parent commands
```
--chain-id string Chain ID of tendermint node
```

View File

@ -0,0 +1,51 @@
# Create New CDP
Create a new cdp, depositing some collateral and drawing some debt.
## Command
```
kvcli tx cdp create <collateral> <debt> <collateral-type> <flags>
```
Using ```kvcli``` call the ```tx``` subcommand followed by the module name which is```cdp```, then define the action which is ```create``` and finally follow up with required arguments or flags.
### Arguments
position|name|expects
|--|--|--|
1|collateral| amount & name (no spaces)
2|debt| amount & name (no spaces)
3|collateral-type| name
### Example
```
kvcli tx cdp create 10000000uatom 1000usdx atom-a --from myKeyName
```
### Options
```
-a, --account-number uint The account number of the signing account (offline mode only)
-b, --broadcast-mode string Transaction broadcasting mode (sync|async|block) (default "sync")
--dry-run ignore the --gas flag and perform a simulation of a transaction, but don't broadcast it
--fees string Fees to pay along with transaction; eg: 10uatom
--from string Name or address of private key with which to sign
--gas string gas limit to set per-transaction; set to "auto" to calculate required gas automatically (default 200000) (default "200000")
--gas-adjustment float adjustment factor to be multiplied against the estimate returned by the tx simulation; if the gas limit is set manually this flag is ignored (default 1)
--gas-prices string Gas prices to determine the transaction fee (e.g. 10uatom)
--generate-only Build an unsigned transaction and write it to STDOUT (when enabled, the local Keybase is not accessible and the node operates offline)
-h, --help help for create
--indent Add indent to JSON response
--keyring-backend string Select keyring's backend (os|file|test) (default "os")
--ledger Use a connected Ledger device
--memo string Memo to send along with transaction
--node string <host>:<port> to tendermint rpc interface for this chain (default "tcp://localhost:26657")
-s, --sequence uint The sequence number of the signing account (offline mode only)
--trust-node Trust connected full node (don't verify proofs for responses) (default true)
-y, --yes Skip tx broadcasting prompt confirmation
```
### Options inherited from parent commands
```
--chain-id string Chain ID of tendermint node
```

View File

@ -0,0 +1,51 @@
# Add Collateral
Add collateral to an existing cdp.
## Command
```
kvcli tx cdp deposit <owner-addr> <collateral> <collateral-type> <flags>
```
Using ```kvcli``` call the ```tx``` subcommand followed by the module name which is```cdp```, then define the action which is ```deposit``` and finally follow up with required arguments or flags.
### Arguments
position|name|expects
|--|--|--|
1|owner-addr| kava address
2|collateral| amount & name (no spaces)
3|collateral-type| name
### Example
```
kvcli tx cdp deposit kava15qdefkmwswysgg4qxgqpqr35k3m49pkx2jdfnw 10000000uatom atom-a --from myKeyName
```
### Options
```
-a, --account-number uint The account number of the signing account (offline mode only)
-b, --broadcast-mode string Transaction broadcasting mode (sync|async|block) (default "sync")
--dry-run ignore the --gas flag and perform a simulation of a transaction, but don't broadcast it
--fees string Fees to pay along with transaction; eg: 10uatom
--from string Name or address of private key with which to sign
--gas string gas limit to set per-transaction; set to "auto" to calculate required gas automatically (default 200000) (default "200000")
--gas-adjustment float adjustment factor to be multiplied against the estimate returned by the tx simulation; if the gas limit is set manually this flag is ignored (default 1)
--gas-prices string Gas prices to determine the transaction fee (e.g. 10uatom)
--generate-only Build an unsigned transaction and write it to STDOUT (when enabled, the local Keybase is not accessible and the node operates offline)
-h, --help help for deposit
--indent Add indent to JSON response
--keyring-backend string Select keyring's backend (os|file|test) (default "os")
--ledger Use a connected Ledger device
--memo string Memo to send along with transaction
--node string <host>:<port> to tendermint rpc interface for this chain (default "tcp://localhost:26657")
-s, --sequence uint The sequence number of the signing account (offline mode only)
--trust-node Trust connected full node (don't verify proofs for responses) (default true)
-y, --yes Skip tx broadcasting prompt confirmation
```
### Options inherited from parent commands
```
--chain-id string Chain ID of tendermint node
```

View File

@ -0,0 +1,51 @@
# Draw Debt
Create debt in an existing cdp and send the newly minted asset to your account.
## Command
```
kvcli tx cdp draw <collateral-type> <debt> <flags>
```
Using ```kvcli``` call the ```tx``` subcommand followed by the module name which is```cdp```, then define the action which is ```draw``` and finally follow up with required arguments or flags.
### Arguments
position|name|expects
|--|--|--|
1|collateral-type| name
2|debt| amount & name (no spaces)
### Example
```
kvcli tx cdp draw atom-a 1000usdx --from myKeyName
```
### Options
```
-a, --account-number uint The account number of the signing account (offline mode only)
-b, --broadcast-mode string Transaction broadcasting mode (sync|async|block) (default "sync")
--dry-run ignore the --gas flag and perform a simulation of a transaction, but don't broadcast it
--fees string Fees to pay along with transaction; eg: 10uatom
--from string Name or address of private key with which to sign
--gas string gas limit to set per-transaction; set to "auto" to calculate required gas automatically (default 200000) (default "200000")
--gas-adjustment float adjustment factor to be multiplied against the estimate returned by the tx simulation; if the gas limit is set manually this flag is ignored (default 1)
--gas-prices string Gas prices to determine the transaction fee (e.g. 10uatom)
--generate-only Build an unsigned transaction and write it to STDOUT (when enabled, the local Keybase is not accessible and the node operates offline)
-h, --help help for draw
--indent Add indent to JSON response
--keyring-backend string Select keyring's backend (os|file|test) (default "os")
--ledger Use a connected Ledger device
--memo string Memo to send along with transaction
--node string <host>:<port> to tendermint rpc interface for this chain (default "tcp://localhost:26657")
-s, --sequence uint The sequence number of the signing account (offline mode only)
--trust-node Trust connected full node (don't verify proofs for responses) (default true)
-y, --yes Skip tx broadcasting prompt confirmation
```
### Options inherited from parent commands
```
--chain-id string Chain ID of tendermint node
```

View File

@ -0,0 +1,53 @@
# Repay Debt
Repay debt to an existing cdp
## Command
```
kvcli tx cdp repay <collateral-name> <debt> <flags>
```
Using ```kvcli``` call the ```tx``` subcommand followed by the module name which is```cdp```, then define the action which is ```repay``` and finally follow up with required arguments or flags.
### Arguments
position|name|expects
|--|--|--|
1|collateral-name| name
2|debt| amount & name (no spaces)
### Example
```
kvcli tx cdp repay atom-a 1000usdx --from myKeyName
```
### Options
```
-a, --account-number uint The account number of the signing account (offline mode only)
-b, --broadcast-mode string Transaction broadcasting mode (sync|async|block) (default "sync")
--dry-run ignore the --gas flag and perform a simulation of a transaction, but don't broadcast it
--fees string Fees to pay along with transaction; eg: 10uatom
--from string Name or address of private key with which to sign
--gas string gas limit to set per-transaction; set to "auto" to calculate required gas automatically (default 200000) (default "200000")
--gas-adjustment float adjustment factor to be multiplied against the estimate returned by the tx simulation; if the gas limit is set manually this flag is ignored (default 1)
--gas-prices string Gas prices to determine the transaction fee (e.g. 10uatom)
--generate-only Build an unsigned transaction and write it to STDOUT (when enabled, the local Keybase is not accessible and the node operates offline)
-h, --help help for repay
--indent Add indent to JSON response
--keyring-backend string Select keyring's backend (os|file|test) (default "os")
--ledger Use a connected Ledger device
--memo string Memo to send along with transaction
--node string <host>:<port> to tendermint rpc interface for this chain (default "tcp://localhost:26657")
-s, --sequence uint The sequence number of the signing account (offline mode only)
--trust-node Trust connected full node (don't verify proofs for responses) (default true)
-y, --yes Skip tx broadcasting prompt confirmation
--chain-id string Chain ID of tendermint node
```
### Options inherited from parent commands
```
--chain-id string Chain ID of tendermint node
```

View File

@ -0,0 +1,51 @@
# Remove Collateral
Withdraw collateral from an existing cdp
## Command
```
kvcli tx cdp withdraw <owner-addr> <collateral> <collateral-type> <flags>
```
Using ```kvcli``` call the ```tx``` subcommand followed by the module name which is```cdp```, then define the action which is ```withdraw``` and finally follow up with required arguments or flags.
### Arguments
position|name|expects
|--|--|--|
1|owner-addr| kava address
2|collateral| amount & name (no spaces)
3|collateral-type| name
### Example
```
kvcli tx cdp withdraw kava15qdefkmwswysgg4qxgqpqr35k3m49pkx2jdfnw 10000000uatom atom-a --from myKeyName
```
### Options
```
-a, --account-number uint The account number of the signing account (offline mode only)
-b, --broadcast-mode string Transaction broadcasting mode (sync|async|block) (default "sync")
--dry-run ignore the --gas flag and perform a simulation of a transaction, but don't broadcast it
--fees string Fees to pay along with transaction; eg: 10uatom
--from string Name or address of private key with which to sign
--gas string gas limit to set per-transaction; set to "auto" to calculate required gas automatically (default 200000) (default "200000")
--gas-adjustment float adjustment factor to be multiplied against the estimate returned by the tx simulation; if the gas limit is set manually this flag is ignored (default 1)
--gas-prices string Gas prices to determine the transaction fee (e.g. 10uatom)
--generate-only Build an unsigned transaction and write it to STDOUT (when enabled, the local Keybase is not accessible and the node operates offline)
-h, --help help for withdraw
--indent Add indent to JSON response
--keyring-backend string Select keyring's backend (os|file|test) (default "os")
--ledger Use a connected Ledger device
--memo string Memo to send along with transaction
--node string <host>:<port> to tendermint rpc interface for this chain (default "tcp://localhost:26657")
-s, --sequence uint The sequence number of the signing account (offline mode only)
--trust-node Trust connected full node (don't verify proofs for responses) (default true)
-y, --yes Skip tx broadcasting prompt confirmation
```
### Options inherited from parent commands
```
--chain-id string Chain ID of tendermint node
```

View File

@ -0,0 +1,57 @@
# Deposit
Deposit coins to a swap liquidity pool
## Command
```
kvcli tx swap deposit <tokenA> <tokenB> <slippage> <deadline> <flags>
```
Using ```kvcli``` call the ```tx``` subcommand followed by the module name which is```swap```, then define the action which is ```deposit``` and finally follow up with required arguments or flags.
### Arguments
position|name|expects
|--|--|--|
1|tokenA| amount & name (no spaces)
2|tokenB| amount & name (no spaces)
3|slippage| percentage float
4|deadline| deadline block
### Example
```
kvcli tx swap deposit 10000000ukava 10000000usdx 0.01 1624224736 --from <key>
```
### Options
```
-a, --account-number uint The account number of the signing account (offline mode only)
-b, --broadcast-mode string Transaction broadcasting mode (sync|async|block) (default "sync")
--dry-run ignore the --gas flag and perform a simulation of a transaction, but don't broadcast it
--fees string Fees to pay along with transaction; eg: 10uatom
--from string Name or address of private key with which to sign
--gas string gas limit to set per-transaction; set to "auto" to calculate required gas automatically (default 200000) (default "200000")
--gas-adjustment float adjustment factor to be multiplied against the estimate returned by the tx simulation; if the gas limit is set manually this flag is ignored (default 1)
--gas-prices string Gas prices to determine the transaction fee (e.g. 10uatom)
--generate-only Build an unsigned transaction and write it to STDOUT (when enabled, the local Keybase is not accessible and the node operates offline)
-h, --help help for deposit
--indent Add indent to JSON response
--keyring-backend string Select keyring's backend (os|file|test) (default "os")
--ledger Use a connected Ledger device
--memo string Memo to send along with transaction
--node string <host>:<port> to tendermint rpc interface for this chain (default "tcp://localhost:26657")
-s, --sequence uint The sequence number of the signing account (offline mode only)
--trust-node Trust connected full node (don't verify proofs for responses) (default true)
-y, --yes Skip tx broadcasting prompt confirmation
```
### Options inherited from parent commands
```
--chain-id string Chain ID of tendermint node
```

View File

@ -0,0 +1,56 @@
# Swap Tokens
Swap an exact amount of token a for token b
## Command
```
kvcli tx swap swap-exact-for-tokens <exactCoinA> <coinB> <slippage> <deadline> <flags>
```
Using ```kvcli``` call the ```tx``` subcommand followed by the module name which is```swap```, then define the action which is ```swap-exact-for-tokens``` and finally follow up with required arguments or flags.
### Arguments
position|name|expects
|--|--|--|
1|exactCoinA| exact amount & name (no spaces)
2|coinB| amount & name (no spaces)
3|slippage| percentage float
4|deadline| timestamp
### Example
```
kvcli tx swap swap-exact-for-tokens 1000000ukava 5000000usdx 0.01 1624224736 --from <key>
```
### Options
```
-a, --account-number uint The account number of the signing account (offline mode only)
-b, --broadcast-mode string Transaction broadcasting mode (sync|async|block) (default "sync")
--dry-run ignore the --gas flag and perform a simulation of a transaction, but don't broadcast it
--fees string Fees to pay along with transaction; eg: 10uatom
--from string Name or address of private key with which to sign
--gas string gas limit to set per-transaction; set to "auto" to calculate required gas automatically (default 200000) (default "200000")
--gas-adjustment float adjustment factor to be multiplied against the estimate returned by the tx simulation; if the gas limit is set manually this flag is ignored (default 1)
--gas-prices string Gas prices to determine the transaction fee (e.g. 10uatom)
--generate-only Build an unsigned transaction and write it to STDOUT (when enabled, the local Keybase is not accessible and the node operates offline)
-h, --help help for swap-exact-for-tokens
--indent Add indent to JSON response
--keyring-backend string Select keyring's backend (os|file|test) (default "os")
--ledger Use a connected Ledger device
--memo string Memo to send along with transaction
--node string <host>:<port> to tendermint rpc interface for this chain (default "tcp://localhost:26657")
-s, --sequence uint The sequence number of the signing account (offline mode only)
--trust-node Trust connected full node (don't verify proofs for responses) (default true)
-y, --yes Skip tx broadcasting prompt confirmation
```
### Options inherited from parent commands
```
--chain-id string Chain ID of tendermint node
```

View File

@ -0,0 +1,57 @@
# Withdraw
Withdraw coins from a swap liquidity pool
## Command
```
kvcli tx swap withdraw <shares> <minCoinA> <minCoinB> <deadline> <flags>
```
Using ```kvcli``` call the ```tx``` subcommand followed by the module name which is```swap```, then define the action which is ```withdraw``` and finally follow up with required arguments or flags.
### Arguments
position|name|expects
|--|--|--|
1|shares| number of shares
2|minCoinA| amount & name (no spaces)
3|minCoinB| amount & name (no spaces)
4|deadline| timestamp
### Example
```
kvcli tx swap withdraw 153000 10000000ukava 20000000usdx 176293740 --from <key>
```
### Options
```
-a, --account-number uint The account number of the signing account (offline mode only)
-b, --broadcast-mode string Transaction broadcasting mode (sync|async|block) (default "sync")
--dry-run ignore the --gas flag and perform a simulation of a transaction, but don't broadcast it
--fees string Fees to pay along with transaction; eg: 10uatom
--from string Name or address of private key with which to sign
--gas string gas limit to set per-transaction; set to "auto" to calculate required gas automatically (default 200000) (default "200000")
--gas-adjustment float adjustment factor to be multiplied against the estimate returned by the tx simulation; if the gas limit is set manually this flag is ignored (default 1)
--gas-prices string Gas prices to determine the transaction fee (e.g. 10uatom)
--generate-only Build an unsigned transaction and write it to STDOUT (when enabled, the local Keybase is not accessible and the node operates offline)
-h, --help help for withdraw
--indent Add indent to JSON response
--keyring-backend string Select keyring's backend (os|file|test) (default "os")
--ledger Use a connected Ledger device
--memo string Memo to send along with transaction
--node string <host>:<port> to tendermint rpc interface for this chain (default "tcp://localhost:26657")
-s, --sequence uint The sequence number of the signing account (offline mode only)
--trust-node Trust connected full node (don't verify proofs for responses) (default true)
-y, --yes Skip tx broadcasting prompt confirmation
```
### Options inherited from parent commands
```
--chain-id string Chain ID of tendermint node
```

View File

@ -0,0 +1,70 @@
<!--
order: 1
-->
# Quick Reference
### Get a list of all keys
```
kvcli keys list
```
### Query Account Tokens
```
kvcli q accounts <kava-addr>
```
### View Staking Delegations
```
kvcli q staking delegations <kava-addr>
```
### Claim staking rewards
```
kvcli tx distribution withdraw-all-rewards --gas 650000 --gas-prices 0.01ukava --from <kava-addr or key name>
```
### Querying outstanding staking rewards
```
kvcli q distribution rewards <kava-addr>
```
### Claim staking from individual validator
```
kvcli tx distribution withdraw-rewards <kava-validator-addre (starts with kavavaloper)> --gas 650000 --gas-prices 0.01ukava --from <kava-addr or key name>
```
### Claiming KAVA Delegator rewards (yielding HARD and SWP)
```
kvcli tx incentive claim-delegator --multiplier hard=large,swp=large --from <kava-addr or key name> --gas 800000 --gas-prices 0.01ukava
```
### Querying outstanding HARD rewards
```
kvcli q incentive rewards --type delegator --owner <kava-address>
```
### View HARD Incentives
```
kvcli q incentive rewards --type hard --owner <kava-address>
```
### Claim HARD Incentives
```
kvcli tx incentive claim-hard --multiplier hard=large --multiplier ukava=large --from <kava-addr or key name> --gas 800000 --gas-prices 0.01ukava
```
### Send Coins
```
kvcli tx send <key_name> <kava-account> <amount (100ukava for example)> --memo [memo] --gas-prices 0.01ukava
```
### Query Transaction Status Using TX Hash
```
kvcli q tx <tx_hash>
```
### Adding a Key to Ledger
```
kvcli keys add <key-name> --account <account-index> --legacy-hd-path --ledger
```