Motivation:
- Signing transactions offline
- Creating meaningful and reproducible code for DEMOs and presentations. Also there is an idea to create something like Jupiter Notebook for such cases
- Other usages?
Capabilities:
- Creating an account by seed and nonce
- Signing transactions: for a given unsigned transaction in JSON it returns a signed JSON representation
- Verifying transactions in JSON
Requirements:
- Working with Windows, Linux and macOS
- Providing a seed or private key by a console prompt or file
- Zero dependencies
- bash-completions
Specifying a secret:
waves-cli --secret=[seed|pk] # "seed" by default
--secret-from=file:///path/to/secret # by default a secret is provided by prompt
--secret-format=[bin|base58] # defaults: "bin" for files, "base58" for prompt.
--secret-format=bin
is denied for prompt.
Creating an account:
waves-cli --create-account
--nonce=[number] # 0 by default
Prints (after prompt):
{
"privateKey": "Base58-encoded private key",
"publicKey": "Base58-encoded public key"
}
Signing a transfer transaction:
Example of transaction.json:
{
"type": 4,
"version": 1,
"sender": "Base58-encoded address of sender",
"senderPublicKey": "Base58-encoded public key of sender",
"fee": 100000,
"timestamp": 1527505909911,
"recipient": "Base58-encoded address of recipient",
"assetId": null,
"amount": 1699900000,
"feeAsset": null,
"attachment": "Base58-encoded string"
}
Here:
- An order of fields doesn’t matter;
- Optional fields are “version”, “sender”, “senderPublicKey”, “timestamp”, “attachment”;
- The default “version” is 1;
- The default “timestamp” is now;
- The default “attachment” is “” (an empty string);
- If “sender” and “senderPublicKey” are specified, they are validated against the secret;
Signing:
waves-cli --sign-tx
--tx-from=file:///path/to/transaction.json # by default a JSON will be parsed from STDIN
Example of output:
{
"type": 4,
"id": "Base58-encoded id of transaction",
"sender": "Base58-encoded address of sender",
"senderPublicKey": "Base58-encoded public key of sender",
"fee": 100000,
"timestamp": 1527505909911,
"signature": "Base58-encoded signature",
"recipient": "Base58-encoded address of recipient",
"assetId": null,
"amount": 1699900000,
"feeAsset": null,
"attachment": "",
"height": 1018524
}