Skip to content

Commit 1b38ebf

Browse files
committed
Merge branch 'release/v0.5.0'
2 parents b044496 + 9788601 commit 1b38ebf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+5157
-1439
lines changed

CLI.md

Lines changed: 324 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,324 @@
1+
# FAT CLI Documentation
2+
3+
The fat-cli allows users to explore and interact with FAT chains.
4+
5+
fat-cli can be used to explore FAT chains to get balances, issuance, and
6+
transaction data. It can also be used to send transactions on existing FAT
7+
chains, and issue new FAT-0 or FAT-1 tokens.
8+
9+
**Chain ID Settings**
10+
11+
Most sub-commands need to be scoped to a specific FAT chain, identified by a
12+
`--chainid`. Alternatively, this can be specified by using both the `--tokenid`
13+
and `--identity`, which together determine the chain ID.
14+
15+
**API Settings**
16+
17+
fat-cli makes use of the fatd, factomd, and factom-walletd JSON-RPC 2.0 APIs
18+
for various operations. Trust in these API endpoints is imperative to secure
19+
operation.
20+
21+
The `--fatd` API is used to explore issuance, transactions, and balances for
22+
existing FAT chains.
23+
24+
The `--factomd` API is used to submit entries directly to the Factom
25+
blockchain, as well as for checking EC balances, chain existence, and identity
26+
keys.
27+
28+
The `--walletd` API is used to access private keys for FA and EC addresses. To
29+
avoid use of factom-walletd, use private Fs or Es keys directly on the CLI
30+
instead.
31+
32+
If `--debug` is set, all fatd and factomd API calls will be printed to stdout.
33+
API calls to factom-walletd are omitted to avoid leaking private key data.
34+
35+
**Offline Mode**
36+
37+
For increased security to protect private keys, it is possible to run fat-cli
38+
such that it makes no network calls when generating Factom entries for FAT
39+
transactions or token issuance.
40+
41+
Use `--curl` to skip submitting the entry directly to Factom, and instead print
42+
out the curl commands for committing and revealing the entry. These curl
43+
commands contain the encoded signed data and may be safely copied to, and run
44+
from, a computer with access to factomd.
45+
46+
Use `--force` to skip all sanity checks that involve API calls out factomd or
47+
fatd. As a result, this may result in generating a Factom Entry that is invalid
48+
for Factom or FAT, but may still use up Entry Credits to submit.
49+
50+
Use private keys for `--ecadr` and --input directly to avoid any network calls
51+
to factom-walletd.
52+
53+
**Entry Credits**
54+
Making FAT transactions or issuing new FAT tokens requires creating entries on
55+
the Factom blockchain. Creating Factom entries costs Entry Credits. Entry
56+
Credits have a relatively fixed price of about $0.001 USD. Entry Credits can be
57+
obtained by burning Factoids which can be done using the official factom-cli.
58+
FAT transactions normally cost 1 EC. The full FAT Token Issuance process
59+
normally costs 12 EC.
60+
61+
### CLI Completion
62+
After installing fat-cli in some permanent location in your PATH. Use
63+
--installcompletion to install CLI completion for Bash, Zsh, or Fish. This
64+
simply adds a single line to your `~/.bash_profile` (or shell equivalent),
65+
which can be removed with --uninstallcompletion. You must re-open your shell
66+
before completion changes take effect.
67+
68+
No other programs or files need to be installed because fat-cli is also its own
69+
completion program. If fat-cli is envoked by the completion system, it returns
70+
completions for the currently typed arguments.
71+
72+
If the `--fatd` endpoint is available, Token Chain IDs can be completed based
73+
on the chains that fatd is tracking.
74+
75+
If the `--walletd` endpoint is available, then all FA and EC addresses can be
76+
completed based on the addresses saved by factom-walletd.
77+
78+
Since both of these completion flags require successful API calls, any required
79+
API related flags must already be supplied before completion for Token Chain
80+
IDs, FA or EC addresses can succeed. Otherwise, if the default settings are
81+
incorrect, generating completion suggestions will fail silently. Note that
82+
--timeout is ignored as a very short timeout is always used to avoid noticeable
83+
blocking when generating completion suggestions.
84+
85+
86+
# Flags
87+
88+
## General
89+
90+
### `--debug`
91+
92+
Print fatd and factomd API calls
93+
94+
### `--verbose`
95+
96+
Print verbose details about sanity check and other operations
97+
98+
### `--help`
99+
100+
Get help with using the CLI. Can follow any command or subcommand to get
101+
detailed help.
102+
103+
104+
105+
## Network & Auth
106+
107+
### `--fatd`
108+
109+
Fatd URL
110+
111+
scheme://host:port for fatd (default `localhost:8078`)
112+
113+
### `--fatdpass`
114+
115+
Basic HTTP Auth Password for fatd
116+
117+
### `--fatduser`
118+
119+
Basic HTTP Auth User for fatd
120+
121+
### `--factomd`
122+
123+
Factomd URL
124+
125+
scheme://host:port for factomd (default `localhost:8088`)
126+
127+
### `--factomdpass`
128+
129+
Basic HTTP Auth Password for factomd
130+
131+
### `--factomduser`
132+
133+
Basic HTTP Auth User for factomd
134+
135+
### `--walletd`
136+
137+
Factom Walletd URL
138+
139+
scheme://host:port for factom-walletd (default `localhost:8089`)
140+
141+
### `--walletduser`
142+
143+
Basic HTTP Auth User for factom-walletd
144+
145+
### `--walletdpass`
146+
147+
Basic HTTP Auth Password for factom-walletd
148+
149+
### `--timeout`
150+
151+
Timeout for all API requests (i.e. `10s`, `1m`) (default `3s`)
152+
153+
154+
155+
## Tokens
156+
157+
### `--chainid`
158+
159+
The 32 Byte Factom Chain ID of the token to get data for. The token chain ID
160+
can be calculated from `--identity` & `--tokenid`. Either `--chainid` OR
161+
`--identity` & `--tokenid` should be supplied
162+
163+
### `--identity`
164+
165+
Token Issuer Identity Chain ID of a FAT token.
166+
167+
### `--tokenid`
168+
169+
The Token ID string of a FAT chain.
170+
171+
172+
173+
# Commands
174+
175+
## `get`
176+
177+
Retrieve data about FAT tokens or a specific FAT token
178+
179+
```
180+
fat-cli get [subcommand] [flags]
181+
```
182+
183+
### Subcommands
184+
185+
#### `chains`
186+
187+
Get information about tokens and token chains. Print a list including the Chain
188+
ID, Issuer identity chain ID, and token ID of each token currently tracked by
189+
the fat daemon.
190+
191+
```
192+
fat-cli get chains <chainid>
193+
```
194+
195+
If the optional `<chainid>` argument is supplied the info for that specific
196+
chain will be returned including statistics.
197+
198+
199+
#### `balance`
200+
201+
Get the balance of a Factoid address for a token
202+
203+
```
204+
fat-cli get balance --chainid <chainid> <FA Address>
205+
```
206+
207+
#### `transactions`
208+
209+
Get transaction history and specific transactions belonging to a specific FAT
210+
token.
211+
212+
213+
```
214+
fat-cli get transactions --chainid <chain-id> [--starttx <tx-hash>]
215+
[--page <page>] [--limit <limit>] [--order <"asc" | "desc">]
216+
[--address <FA> [--address <FA>]... [--to] [--from]]
217+
[--nftokenid <nf-token-id>]
218+
```
219+
220+
- `--address` - Add to the set of addresses to lookup txs for
221+
- `--from` - Request only txs FROM the given `--address` set
222+
- `--to` - Request only txs TO the given --address set
223+
- `--limit` - Limit of returned txs (default `10`)
224+
- `--nftokenid` - Request only txs involving this NF Token ID
225+
- `--order` - Order of returned txs (`asc`|`desc`, default `asc`)
226+
- `--page` - Page of returned txs (default `1`)
227+
- `--starttx` - Entryhash of tx to start indexing from
228+
229+
230+
231+
## `issue`
232+
233+
Issue a new FAT-0 or FAT-1 token chain.
234+
235+
Issuing a new FAT token chain is a two step process.
236+
237+
First the Token Chain must be created with the correct Name IDs on the Factom
238+
Blockchain. So both --tokenid and --identity are required and use of --chainid
239+
is not allowed for this step. If the Chain Creation Entry has already been
240+
submitted then this step is skipped over.
241+
242+
Second, the Token Initialization Entry must be added to the Token Chain. The
243+
Token Initialization Entry must be signed by the SK1 key corresponding to the
244+
ID1 key declared in the --identity chain. Both --type and --supply are
245+
required. The --supply must be positive or -1 for an unlimited supply of
246+
tokens.
247+
248+
Note that publishing a Token Initialization Entry is an immutable operation.
249+
The protocol does not permit altering the Token Initialization Entry in any
250+
way.
251+
252+
Sanity Checks
253+
Prior to composing the Chain Creation or Token Initialization Entry, a
254+
number of calls to fatd and factomd are made to ensure that the token
255+
can be issued. These checks are skipped if --force is used.
256+
257+
- Skip Chain Creation Entry if already submitted.
258+
- The token has not already been issued.
259+
- The --identity chain exists.
260+
- The --sk1 key corresponds to the --identity's id1 key.
261+
- The --ecadr has enough ECs to pay for all entries.
262+
263+
Identity Chain
264+
FAT token chains may only be issued by an entity controlling the
265+
sk1/id1 key established by the Identity Chain pointed to by the FAT
266+
token chain. An Identity Chain and the associated keys can be created
267+
using the factom-identity-cli.
268+
269+
https://github.com/PaulBernier/factom-identity-cli
270+
271+
Entry Credits
272+
Creating entries on the Factom blockchain costs Entry Credits. The full
273+
Token Issuance process normally costs 12 ECs. You must specify a funded
274+
Entry Credit address with --ecadr, which may be either a private Es
275+
address, or a pubilc EC address that can be fetched from
276+
factom-walletd.
277+
278+
Usage:
279+
fat-cli issue --ecadr <EC | Es> --sk1 <sk1-key>
280+
--identity <issuer-identity-chain-id> --tokenid <token-id>
281+
--type <"FAT-0" | "FAT-1"> --supply <supply> [--metadata <JSON>] [flags]
282+
283+
Flags:
284+
--curl Do not submit Factom entry; print curl commands
285+
-e, --ecadr <EC | Es> EC or Es address to pay for entries
286+
--force Skip sanity checks for balances, chain status, and sk1 key
287+
-h, --help help for issue
288+
-m, --metadata JSON JSON metadata to include in tx
289+
--sk1 sk1 Secret Identity Key 1 to sign entry
290+
--supply int Max Token supply, use -1 for unlimited
291+
--symbol string Optional abbreviated token symbol
292+
--type <"FAT-0" | "FAT-1"> Token standard to use
293+
294+
295+
## `transact`
296+
297+
Send or distribute FAT-0 or FAT-1 tokens.
298+
299+
Submitting a FAT transaction involves submitting a signed transaction entry to
300+
the given FAT Token Chain
301+
302+
**Usage**
303+
304+
```
305+
fat-cli transact <fat0 | fat1> --input <input> --output <output> [--metadata <metadata>] [--sk1 <sk1>] [--ecadr <EC | Es>] [--curl] [--force]
306+
```
307+
308+
- `--input` - An input to the transaction. May be specified multiple times. For
309+
example a FAT-0 tx input could look like
310+
`FA3SjebEevRe964p4tQ6eieEvzi7puv9JWF3S3Wgw2v3WGKueL3R:150`, a FAT-1 tx input
311+
could look like
312+
`FA3SjebEevRe964p4tQ6eieEvzi7puv9JWF3S3Wgw2v3WGKueL3R:[1,2,5-100]`. It is
313+
allowed to use private Factoid keys instead of public ones if `--walletd` is
314+
not specified or available.
315+
- `--output` - An output to the transaction. May be specified multiple times.
316+
Follows the same form as `--input` except no private Factoid keys are
317+
permitted.
318+
- `--metadata` - JSON compliant metadata to attach to the transaction
319+
- `--sk1` - The SK1 Private identity key belonging to the issuer of the token.
320+
Required for coinbase transactions.
321+
- `--ecadr` - EC or Es address to pay for the chain creation and token issuance
322+
entries, if `--factomd` is specified.
323+
- `--curl` - Do not submit the Factom entry; print curl commands instead!
324+
- `--force` - Skip sanity checks for balances, chain status, and sk1 key

Dockerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
FROM golang:1.12-alpine AS builder
2+
3+
RUN apk add make bash git gcc libc-dev
4+
5+
ARG GOBIN=/go/bin/
6+
ARG GOOS=linux
7+
ARG GOARCH=amd64
8+
ARG GO111MODULE=on
9+
ARG PKG_NAME=github.com/Factom-Asset-Tokens/fatd
10+
ARG PKG_PATH=${GOPATH}/src/${PKG_NAME}
11+
12+
WORKDIR ${PKG_PATH}
13+
COPY . ${PKG_PATH}/
14+
RUN make
15+
16+
FROM alpine:3.9
17+
18+
COPY --from=builder /go/src/github.com/Factom-Asset-Tokens/fatd/fatd .
19+
20+
ENTRYPOINT [ "./fatd" ]

LICENSE.md renamed to LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright 2018 Factom Asset Tokens
3+
Copyright 2018 Canonical Ledgers, LLC
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy of
66
this software and associated documentation files (the "Software"), to deal in

0 commit comments

Comments
 (0)