Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 29 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

A command line tool for automating all-things Kadena.

![Example Animation](https://s1.gifyu.com/images/kda-tool-demo3.gif)
https://github.com/kda-community/kda-tool/releases

## Features

Expand Down Expand Up @@ -37,7 +37,7 @@ following file we'll call `transfer.ktpl`:

### Generating a single transaction

```
```yaml
code: |-
(coin.transfer "{{{from-acct}}}" "{{{to-acct}}}" {{amount}})
data:
Expand All @@ -61,7 +61,7 @@ type: exec
You can get a list of all the values this template needs with the `--holes`
option which prints the following:

```
```bash
$ kda gen -t transfer.ktpl --holes
amount: null
chain: null
Expand All @@ -72,7 +72,7 @@ to-acct: null
We can save this to a file with `kda gen -t transfer.ktpl --holes > data.yaml`.
Then we can edit this file with the following values:

```
```yaml
amount: 1.5
chain: 0
from-acct: alice
Expand All @@ -81,7 +81,7 @@ to-acct: bob

Then we can generate a transaction from this template as follows:

```
```bash
$ kda gen -t transfer.ktpl -d data.yaml
Wrote commands to: ["tx.yaml"]
```
Expand All @@ -99,7 +99,7 @@ information.
We can use the same `transfer.ktpl` template to generate transactions on
multiple chains by making a simple change to the `data.yaml` file:

```
```yaml
amount: 1.5
chain: [0,1,2]
from-acct: alice
Expand All @@ -110,7 +110,7 @@ All the data is the same as before except we changed the `chain` field to a
list. When kda-tool sees a list it generates a separate transaction using each
value in the list:

```
```bash
$ kda gen -t transfer.ktpl -d data.yaml
Wrote commands to: ["tx-0.yaml","tx-1.yaml","tx-2.yaml"]
```
Expand All @@ -130,7 +130,7 @@ to-acct: [bob, carol, dave]

Generating using this data gives something slightly different:

```
```bash
$ kda gen -t transfer.ktpl -d data.yaml
Wrote commands to: ["tx-bob.yaml","tx-carol.yaml","tx-dave.yaml"]
```
Expand All @@ -139,15 +139,15 @@ The filename is `tx-` followed by the value of the field you're looping over.
You can set your own filename scheme using the `-o` option and a
mustache-templated filename as follows:

```
```bash
$ kda gen -t transfer.ktpl -d data.yaml -o foo_{{to-acct}}_bar.yaml
Wrote commands to: ["foo_bob_bar.yaml","foo_carol_bar.yaml","foo_dave_bar.yaml"]
```

If you want to transfer a different amount on each chain, you can also put a
list in the amount field as follows:

```
```yaml
amount: ["1.0","2.0","3.0"]
chain: [0,1,2]
from-acct: alice
Expand Down Expand Up @@ -178,22 +178,31 @@ transaction repos by creating a config file. The default location for the config
file is `$HOME/.config/kda/config.json`. You can also pass the `-c` option to
use your own config file stored somewhere else. Here is an example config file:

```
```json
{
"tx-repos": [
"blockchaindev/my-marmalade-templates",
"blockchaindev/txlib",
"my-favorite-dex/txlib",
"kadena-io/txlib"
]
"kda-community/txlib"
],
"networks": {
"testnet04":"https://api.testnet.chainweb.com",
"testnet06":"https://api.testnet.chainweb-community.org",
"mainnet01":"https://api.chainweb-community.org"
}
}

```

Each repo is tried in the order they appear in the config file, stopping after
the first one that works. This allows projects building on Kadena to publish
libraries of transation templates for working with their smart contracts and for
users to use any combination of template sets that they desire.

Additionnally the config file allows you to setup network endpoints. Avoiding the need to sepcify it with thee `-n` flag for
each `local`, `send` or `poll` command.

## Transaction Signing

### Signing with key files
Expand All @@ -205,15 +214,15 @@ signed you can use the `kda sign` command to add signatures to these files.
In the above example of multiple transactions generated for chains 0, 1, and 2,
we can sign all those transactions with a single command:

```
```bash
kda sign -k my-key.kda tx-*.yaml
```

In this example, `my-key.kda` is a file with a plain ED25519 key pair in the
format generated by `pact -g` or `kda keygen plain`. You can also use a file
containing a Chainweaver-compatible HD recovery phrase with the same option:

```
```bash
kda keygen hd > my-hd-key.phrase
kda sign -k my-hd-key.phrase tx-*.yaml
```
Expand Down Expand Up @@ -302,7 +311,7 @@ transactions have been included in a mined block yet.

All three of these commands use the same basic format:

```
```bash
kda local *.json -n mynode.example.com:<service-api-port>
```

Expand All @@ -318,7 +327,7 @@ in transaction templates, you can use `codeFile` and `dataFile` to have kda-tool
read Pact code and data from disk. Here's an example of how you might do that.
First, put the following template in a file called `deploy.ktpl`:

```
```yaml
codeFile: my-contract.pact
dataFile: my-env-data.json
publicMeta:
Expand All @@ -338,13 +347,13 @@ This assumes that our smart contract is stored in a file called
imagine that our contract is deployed on chains 5, 6, and 7. We can encode this
in a file `deploy-data.yaml` as follows:

```
```yaml
chain: [5,6,7]
```

Now when you make changes to your smart contract, testing them is as simple as:

```
```bash
$ kda gen -t deploy.ktpl -d deploy.yaml
network: testnet04
Wrote commands to: ["tx-5.yaml","tx-6.yaml","tx-7.yaml"]
Expand Down Expand Up @@ -373,7 +382,7 @@ There are two key formats: plain and hd.
The first is a plain ED25519 key format compatible with Pact which is a YAML
file with two fields: `public` and `secret`.

```
```yaml
public: 40c1e2e86cc3974cc29b8953e127c1f31905665fcc98846ebf6c00cb8610a213
secret: badbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbade
```
Expand Down