Seth CLI

Overview

The seth command can be used to interact with the Sawtooth Burrow-EVM transaction family. It provides functionality for loading and executing smart contracts, querying the data associated with a contract, and generating keys in the format used by the tool. The following section reproduces the CLI usage output obtained by running seth and its various subcommands with the -h flag.

See the final section for an explanation of how to generate contract initialization data and how to format function calls using the Ethereum Contract ABI.

seth

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
Usage:
  seth [OPTIONS] <command>

Application Options:
  -v, --verbose  Set the log level

Help Options:
  -h, --help     Show this help message

Available commands:
  account      Manage seth accounts
  contract     Deploy and execute contracts
  init         Initialize seth to communicate with the given URL
  permissions  Manage permissions of accounts
  show         Show all data associated with a given account

seth init

1
2
3
4
5
6
7
8
Usage:
  seth [OPTIONS] init [url]

Application Options:
  -v, --verbose    Set the log level

Help Options:
  -h, --help       Show this help message

seth show

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
Usage:
  seth [OPTIONS] show address

Application Options:
  -v, --verbose      Set the log level

Help Options:
  -h, --help         Show this help message

[show command arguments]
  address:           Address of account to show

seth account

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
Usage:
  seth [OPTIONS] account <create | import | list>

Application Options:
  -v, --verbose   Set the log level

Help Options:
  -h, --help      Show this help message

Available commands:
  create  Create a new externally owned account
  import  Import the private and create an alias for later reference
  list    List all imported accounts as "alias: address"

seth account import

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
Usage:
  seth [OPTIONS] account import [import-OPTIONS] [key-file] [alias]

Application Options:
  -v, --verbose       Set the log level

Help Options:
  -h, --help          Show this help message

[import command options]
      -f, --force     Overwrite key with the same alias if it exists

[import command arguments]
  key-file:           Path to the file that contains the private key to import
  alias:              Alias to assign the private key

seth account list

1
2
3
4
5
6
7
8
Usage:
  seth [OPTIONS] account list

Application Options:
  -v, --verbose   Set the log level

Help Options:
  -h, --help      Show this help message

seth account create

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
Usage:
  seth [OPTIONS] account create [create-OPTIONS] [alias]

Application Options:
  -v, --verbose          Set the log level

Help Options:
  -h, --help             Show this help message

[create command options]
      -m, --moderator=   Alias of another account to be used to create the
                         account
      -p, --permissions= Permissions for new account; see 'seth permissions -h'
                         for more info
      -n, --nonce=       Current nonce of moderator account (default: 0)

[create command arguments]
  alias:                 Alias of the imported key associated with the account
                         to be created

seth contract

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
Usage:
  seth [OPTIONS] contract <call | create>

Application Options:
  -v, --verbose   Set the log level

Help Options:
  -h, --help      Show this help message

Available commands:
  call    Execute a deployed contract account
  create  Deploy a new contract account

seth contract call

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
Usage:
  seth [OPTIONS] contract call [call-OPTIONS] [alias] [address] [data]

Application Options:
  -v, --verbose      Set the log level

Help Options:
  -h, --help         Show this help message

[call command options]
      -g, --gas=     Gas limit for contract creation (default: 0)
      -n, --nonce=   Current nonce of moderator account (default: 0)

[call command arguments]
  alias:             Alias of the imported key associated with the contract to
                     be created
  address:           Address of contract to call
  data:              Input data to pass to contract when called; must conform
                     to contract ABI

seth contract create

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
Usage:
  seth [OPTIONS] contract create [create-OPTIONS] [alias] [init]

Application Options:
  -v, --verbose          Set the log level

Help Options:
  -h, --help             Show this help message

[create command options]
      -p, --permissions= Permissions for new account; see 'seth permissions -h'
                         for more info
      -g, --gas=         Gas limit for contract creation (default: 0)
      -n, --nonce=       Current nonce of moderator account (default: 0)

[create command arguments]
  alias:                 Alias of the imported key associated with the
                         contract to be created
  init:                  Initialization code to be executed on deployment

seth permissions

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
Usage:
  seth [OPTIONS] permissions <set>

Permissions can be set for individual EVM accounts. If a permission is not set,
account permissions default to those set at the global permissions address. If
no permissions are set at the global permissions address, all permissions are
allowed.

Supported permissions are:
* root: Change permissions of accounts
* send: Transfer value from an owned account to another account
* call: Execute a deployed contract
* contract: Deploy new contracts from an owned account
* account: Create new externally owned accounts

When a new account is created, its permissions are inherited from the creating
account, with the exception of the "root" permission, which is set to disabled
during creation and must be set with a separate transaction. If the account is
creating itself, its permissions are inherited from the account at the global
permissions address. If no permissions are set at the global permissions
address, all permissions are enabled for the new account (including root).

To specify permissions on the command line, use a comma-separated list of
"prefixed" permissions from the list above. Permissions must be prefixed with a
plus ("+") or minus ("-") to indicated allowed and not allowed respectively.
Permissions that are omitted from the list will be left unset and default to
those set at the global permissions address.

"all" may be used as a special keyword to refer to all permissions. Duplicates
are allowed and items that come later in the list override earlier items.

Examples:

-all,+contract,+call      Disable all permissions except contract creation or
calling
+account,+send,-contract  Enable account creation and sending value; Disable
contract creation
+all,-root                Enable all permissions except setting permissions

Application Options:
  -v, --verbose   Set the log level

Help Options:
  -h, --help      Show this help message

Available commands:
  set  Change the permissions of accounts

seth permissions set

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
Usage:
  seth [OPTIONS] permissions set [set-OPTIONS] [moderator]

See 'seth permissions -h' for more info.

Application Options:
  -v, --verbose          Set the log level

Help Options:
  -h, --help             Show this help message

[set command options]
      -a, --address=     Address of account whose permissions are being
                         changed; 'global' may be used to refer to the zero
                         address
      -p, --permissions= New permissions for the account
      -n, --nonce=       Current nonce of the moderator account (default: 1)

[set command arguments]
  moderator:             Alias of key to be used for modifying permissions

Compiling Contracts

The seth load command has a –init flag which takes a hex-encoded byte array as an argument. This string is interpreted as the contract creation code. To generate this string given a Solidity smart contract, the solc compiler can be used. Assuming the contract is named contract.sol, the command is:

$ solc --bin contract.sol

======= contract.sol:SimpleStorage =======
Binary:
6060604052341561000c57fe5b5b60c68061001b6000396000f30060606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806360fe47b11460445780636d4ce63c146061575bfe5b3415604b57fe5b605f60048080359060200190919050506084565b005b3415606857fe5b606e608f565b6040518082815260200191505060405180910390f35b806000819055505b50565b600060005490505b905600a165627a7a7230582042f71fb995ac3f6a4ce0560bae1342e5a54e96ec0462f812340a305e3c94da910029

The hex string that is output by this command can be passed directly to the –init flag.

For more information on solc including how to install it and more advanced usage, read the Solidity Documentation.

ABI Formatting

The seth exec command has a –data flag which takes a hex-encoded byte array as an argument. This string is interpreted according to the Ethereum Contract ABI and, in the context of solidity, is used to select a function and pass in arguments to that function.

One option for generating this string given a Solidity function is to use the ethereumjs-abi library.

Given the solidity function set(uint key, uint val) {...} and the specific call set(19, 84), the commands to generate the byte array are:

$ node
> var abi = require('ethereumjs-abi')
> abi.simpleEncode("set(uint,uint)", "0x13", "0x54").toString("hex")
'1ab06ee500000000000000000000000000000000000000000000000000000000000000130000000000000000000000000000000000000000000000000000000000000054'

The hex string that is output by this command can be passed directly to the –data flag.

For more information on the Ethereum Contract ABI, read the wiki.