SophiaTX Developers logo

Cli Wallet

Introduction

We provide a basic cli wallet for interfacing with sophiatxd. The wallet is self documented via command line help. The node you connect to via the cli wallet needs to be running the account_by_key_api, alexnadria_api, and needs to be configured to accept websocket connections via webserver-ws-endpoint.

RPC calls

create_account_with_keys

This method is used to create new accounts for other users which must provide their desired keys. The resulting account may not be controllable by the wallet unless new account’s private key is imported to the wallet. There is a fee associated with every account creation that is paid by the creator. The current account creation fee can be found using the ‘info’ wallet command. PUB_KEY can be generated by using suggest_brain_key method, that returns a pair of keys. Example curl command:

curl -s --data '{"jsonrpc":"2.0", "method":"create_account_with_keys", "params":["CREATOR", "SEED_FOR_NAME", "{}", PUB_KEY, PUB_KEY, PUB_KEY, true], "id":1}' -X POST CLI_WALLET_URL

Example output:

{
   "id":1,
   "result":{
      "ref_block_num":9705,
      "ref_block_prefix":344575789,
      "expiration":"2018-08-20T10:55:09",
      "operations":[
         [
            "account_create",
            {
               "fee":"0.000000 SPHTX",
               "creator":"CREATOR",
               "name_seed":"SEED_FOR_NAME",
               "owner":{
                  "weight_threshold":1,
                  "account_auths":[

                  ],
                  "key_auths":[
                     [
                        "SPH8Zbi8EeRbBFX79N7DfQvn9SXz1Fy4PFjmrYQ8TSnftnYyMCdCq",
                        1
                     ]
                  ]
               },
               "active":{
                  "weight_threshold":1,
                  "account_auths":[

                  ],
                  "key_auths":[
                     [
                        "SPH8Zbi8EeRbBFX79N7DfQvn9SXz1Fy4PFjmrYQ8TSnftnYyMCdCq",
                        1
                     ]
                  ]
               },
               "memo_key":"SPH8Zbi8EeRbBFX79N7DfQvn9SXz1Fy4PFjmrYQ8TSnftnYyMCdCq",
               "json_metadata":"{}"
            }
         ]
      ],
      "extensions":[

      ],
      "signatures":[
         "204dbb2f2a1975ab40c3c461b30fa8b4bbeb6dbc459397350a853f1f44701d9a0922dce3ad5b53bcce680af1b0d163749efa9ee9f2ae91584463c8e134032f9c00"
      ],
      "transaction_id":"1b43e4868976afea3eee35bd408eebd263ca9e27",
      "block_num":140778,
      "transaction_num":0
   }
}

get_account

Returns information about the desired account using name of the account. Example curl command:

curl -s --data '{"jsonrpc": "2.0", "method": "get_account", "params": ["ACC_NAME"], "id": 1}' -X POST CLI_WALLET_URL

Example output:

{
   "id":1,
   "result":[
      {
         "id":3,
         "name":"initminer",
         "owner":{
            "weight_threshold":1,
            "account_auths":[

            ],
            "key_auths":[
               [
                  "SPH7VNqGPfHXVu7try6KqdxG1feVt3SDwgkXZYdw44jkWdrUNDBhY",
                  1
               ]
            ]
         },
         "active":{
            "weight_threshold":1,
            "account_auths":[

            ],
            "key_auths":[
               [
                  "SPH7VNqGPfHXVu7try6KqdxG1feVt3SDwgkXZYdw44jkWdrUNDBhY",
                  1
               ]
            ]
         },
         "memo_key":"SPH7VNqGPfHXVu7try6KqdxG1feVt3SDwgkXZYdw44jkWdrUNDBhY",
         "json_metadata":"",
         "voting_proxy":"",
         "balance":"893.695508 SPHTX",
         "vesting_shares":"7224.158648 VESTS",
         "vesting_withdraw_rate":"0.000000 VESTS",
         "to_withdraw":0,
         "witness_votes":[

         ],
         "sponsored_accounts":[

         ],
         "sponsoring_account":""
      }
   ]
}

get_account_history

Returns operations done by the account. Account operations have sequence numbers from 0 to N where N is the most recent operation. This method returns operations in the range [from-limit, from] (-1 is the most recent operation performed by the given account). Example curl command:

curl -s --data '{"jsonrpc": "2.0", "method": "get_account_history", "params": ["ACC_NAME", -1, 3], "id": 1}' -X POST CLI_WALLET_URL

Example output:

{
   "id":1,
   "result":[
      [
         55543,
         {
            "trx_id":"0000000000000000000000000000000000000000",
            "block":740839,
            "trx_in_block":0,
            "op_in_trx":0,
            "virtual_op":0,
            "timestamp":"2018-08-20T08:54:00",
            "op":[
               "producer_reward",
               {
                  "producer":"initminer",
                  "vesting_shares":"0.142706 VESTS"
               }
            ],
            "fee_payer":""
         }
      ],
      [
         55544,
         {
            "trx_id":"0000000000000000000000000000000000000000",
            "block":740858,
            "trx_in_block":0,
            "op_in_trx":0,
            "virtual_op":0,
            "timestamp":"2018-08-20T08:54:57",
            "op":[
               "producer_reward",
               {
                  "producer":"initminer",
                  "vesting_shares":"0.142706 VESTS"
               }
            ],
            "fee_payer":""
         }
      ],
      [
         55545,
         {
            "trx_id":"0000000000000000000000000000000000000000",
            "block":740877,
            "trx_in_block":0,
            "op_in_trx":0,
            "virtual_op":0,
            "timestamp":"2018-08-20T08:55:54",
            "op":[
               "producer_reward",
               {
                  "producer":"initminer",
                  "vesting_shares":"0.142706 VESTS"
               }
            ],
            "fee_payer":""
         }
      ],
      [
         55546,
         {
            "trx_id":"0000000000000000000000000000000000000000",
            "block":740887,
            "trx_in_block":0,
            "op_in_trx":0,
            "virtual_op":0,
            "timestamp":"2018-08-20T08:56:24",
            "op":[
               "producer_reward",
               {
                  "producer":"initminer",
                  "vesting_shares":"0.142706 VESTS"
               }
            ],
            "fee_payer":""
         }
      ]
   ]
}

get_block

Returns the information about a block using block id. Example curl command:

curl -s --data '{"jsonrpc": "2.0", "method": "get_block", "params": [BLOCK_NUM], "id": 1}' -X POST CLI_WALLET_URL

Example output:

{
   "id":1,
   "result":{
      "previous":"000b49a113105af85e1f58cdc7dca4a891ab5af7",
      "timestamp":"2018-08-20T07:59:09",
      "witness":"vNoabZ5MIUb0hQT47Gr3OqK4K/8",
      "transaction_merkle_root":"ba3fcccbdc8c173a183e16970ef094fdf59efead",
      "extensions":[

      ],
      "witness_signature":"2043ab41ac42879b2fe6d9c16111e43518ae20e3b9ff72aa6ed8409954fddd35a3522f7bf8d2178c06fb8e251f090a6248508795624e746fe7e962bb47e970f363",
      "transactions":[
         {
            "ref_block_num":18849,
            "ref_block_prefix":4166651923,
            "expiration":"2018-08-20T07:59:36",
            "operations":[
               [
                  "account_create",
                  {
                     "fee":"0.050000 SPHTX",
                     "creator":"dhWFetBLqL05SgCYj3_vJ4XAHCs",
                     "name_seed":"2YGLSZZYXai4vFV4a786988448asya2WHtw5rC6S",
                     "owner":{
                        "weight_threshold":1,
                        "account_auths":[

                        ],
                        "key_auths":[
                           [
                              "SPH6W2YGLSZZYXai4vFVS6Cr5wtHW2aysa8QYwtwk2xjXis8hz6LQ",
                              1
                           ]
                        ]
                     },
                     "active":{
                        "weight_threshold":1,
                        "account_auths":[

                        ],
                        "key_auths":[
                           [
                              "SPH6W2YGLSZZYXai4vFVS6Cr5wtHW2aysa8QYwtwk2xjXis8hz6LQ",
                              1
                           ]
                        ]
                     },
                     "memo_key":"SPH6W2YGLSZZYXai4vFVS6Cr5wtHW2aysa8QYwtwk2xjXis8hz6LQ",
                     "json_metadata":"{}"
                  }
               ]
            ],
            "extensions":[

            ],
            "signatures":[
               "2030f1f0aeefd75fc3c0f9632d7eeb64b588077ac28da9262897944afb488a717c13a23c87f2af34172057940452d7938679c4fec8dffa62752feccc56caed203d"
            ]
         }
      ],
      "block_id":"000b49a2af6657ad97b1f500463f550c9694a03a",
      "signing_key":"SPH7Gvr82NQ7uiPBXWMFWwfr2kXkXgbgqkow6yMXFcUH4cnaA95GQ",
      "transaction_ids":[
         "c96a3749c5e604f45e471dcbe6d3d2815499d815"
      ]
   }
}

get_ops_in_block

Returns sequence of operations included/generated in a specified block. Example curl command:

curl -s --data '{"jsonrpc": "2.0", "method": "get_ops_in_block", "params": [BLOCK_NUM, false], "id": 1}' -X POST CLI_WALLET_URL

Example output:

{
   "id":1,
   "result":[
      {
         "trx_id":"c96a3749c5e604f45e471dcbe6d3d2815499d815",
         "block":739746,
         "trx_in_block":0,
         "op_in_trx":0,
         "virtual_op":0,
         "timestamp":"2018-08-20T07:59:06",
         "op":[
            "account_create",
            {
               "fee":"0.050000 SPHTX",
               "creator":"dhWFetBLqL05SgCYj3_vJ4XAHCs",
               "name_seed":"2YGLSZZYXai4vFV4a786988448asya2WHtw5rC6S",
               "owner":{
                  "weight_threshold":1,
                  "account_auths":[

                  ],
                  "key_auths":[
                     [
                        "SPH6W2YGLSZZYXai4vFVS6Cr5wtHW2aysa8QYwtwk2xjXis8hz6LQ",
                        1
                     ]
                  ]
               },
               "active":{
                  "weight_threshold":1,
                  "account_auths":[

                  ],
                  "key_auths":[
                     [
                        "SPH6W2YGLSZZYXai4vFVS6Cr5wtHW2aysa8QYwtwk2xjXis8hz6LQ",
                        1
                     ]
                  ]
               },
               "memo_key":"SPH6W2YGLSZZYXai4vFVS6Cr5wtHW2aysa8QYwtwk2xjXis8hz6LQ",
               "json_metadata":"{}"
            }
         ],
         "fee_payer":"dhWFetBLqL05SgCYj3_vJ4XAHCs"
      },
      {
         "trx_id":"0000000000000000000000000000000000000000",
         "block":739746,
         "trx_in_block":1,
         "op_in_trx":0,
         "virtual_op":0,
         "timestamp":"2018-08-20T07:59:09",
         "op":[
            "interest",
            {
               "owner":"wenfufeng",
               "interest":"0.079728 SPHTX"
            }
         ],
         "fee_payer":""
      },
      {
         "trx_id":"0000000000000000000000000000000000000000",
         "block":739746,
         "trx_in_block":1,
         "op_in_trx":0,
         "virtual_op":0,
         "timestamp":"2018-08-20T07:59:09",
         "op":[
            "interest",
            {
               "owner":"0xc18871892d9a0d5e49",
               "interest":"0.003814 SPHTX"
            }
         ],
         "fee_payer":""
      },
      {
         "trx_id":"0000000000000000000000000000000000000000",
         "block":739746,
         "trx_in_block":1,
         "op_in_trx":0,
         "virtual_op":0,
         "timestamp":"2018-08-20T07:59:09",
         "op":[
            "interest",
            {
               "owner":"0xbabb53b113890ba53f",
               "interest":"0.023913 SPHTX"
            }
         ],
         "fee_payer":""
      },
      {
         "trx_id":"0000000000000000000000000000000000000000",
         "block":739746,
         "trx_in_block":1,
         "op_in_trx":0,
         "virtual_op":0,
         "timestamp":"2018-08-20T07:59:09",
         "op":[
            "producer_reward",
            {
               "producer":"vNoabZ5MIUb0hQT47Gr3OqK4K_8",
               "vesting_shares":"0.142707 VESTS"
            }
         ],
         "fee_payer":""
      }
   ]
}

get_transaction

Returns transaction by ID/hash. Example curl command:

curl -s --data '{"jsonrpc": "2.0", "method": "get_transaction", "params": ["TX_ID"], "id": 1}' -X POST CLI_WALLET_URL 

Example output:

{
   "id":1,
   "result":{
      "ref_block_num":18849,
      "ref_block_prefix":4166651923,
      "expiration":"2018-08-20T07:59:36",
      "operations":[
         [
            "account_create",
            {
               "fee":"0.050000 SPHTX",
               "creator":"dhWFetBLqL05SgCYj3_vJ4XAHCs",
               "name_seed":"2YGLSZZYXai4vFV4a786988448asya2WHtw5rC6S",
               "owner":{
                  "weight_threshold":1,
                  "account_auths":[

                  ],
                  "key_auths":[
                     [
                        "SPH6W2YGLSZZYXai4vFVS6Cr5wtHW2aysa8QYwtwk2xjXis8hz6LQ",
                        1
                     ]
                  ]
               },
               "active":{
                  "weight_threshold":1,
                  "account_auths":[

                  ],
                  "key_auths":[
                     [
                        "SPH6W2YGLSZZYXai4vFVS6Cr5wtHW2aysa8QYwtwk2xjXis8hz6LQ",
                        1
                     ]
                  ]
               },
               "memo_key":"SPH6W2YGLSZZYXai4vFVS6Cr5wtHW2aysa8QYwtwk2xjXis8hz6LQ",
               "json_metadata":"{}"
            }
         ]
      ],
      "extensions":[

      ],
      "signatures":[
         "2030f1f0aeefd75fc3c0f9632d7eeb64b588077ac28da9262897944afb488a717c13a23c87f2af34172057940452d7938679c4fec8dffa62752feccc56caed203d"
      ],
      "transaction_id":"c96a3749c5e604f45e471dcbe6d3d2815499d815",
      "block_num":739746,
      "transaction_num":0
   }
}

transfer

Transfer funds from one account to another. Example curl command:

curl -s --data '{"jsonrpc": "2.0", "method": "transfer", "params": ["FROM_ACC", "TO_ACC", "10 SPHTX", "MEMO", true ], "id": 1}' -X POST CLI_WALLET_URL

Example output:

{
   "id":1,
   "result":{
      "ref_block_num":9796,
      "ref_block_prefix":3677353971,
      "expiration":"2018-08-20T10:59:42",
      "operations":[
         [
            "transfer",
            {
               "fee":"0.010000 SPHTX",
               "from":"FROM_ACC",
               "to":"TO_ACC",
               "amount":"10.000000 SPHTX",
               "memo":"MEMO"
            }
         ]
      ],
      "extensions":[

      ],
      "signatures":[
         "1f7f5b6f9aba7f81b5063be3ea105e30cd651de84a7998d9e8d5762e7a374ca8f246e2895b67982b712b4cd6f33e0da886a46ed67b353403ee32c7025a225209a3"
      ],
      "transaction_id":"f85c278b64791484a313905013eb12b579853368",
      "block_num":140869,
      "transaction_num":0
   }
}

transfer_to_vesting

Transfer SPHTX into a vesting fund represented by vesting shares (VESTS). Example curl command:

curl -s --data '{"jsonrpc": "2.0", "method": "transfer_to_vesting", "params": ["FROM_ACC", "TO_ACC", "10 SPHTX", true ], "id": 1}' -X POST CLI_WALLET_URL

Example output:

{
   "id":1,
   "result":{
      "ref_block_num":10117,
      "ref_block_prefix":1195757355,
      "expiration":"2018-08-20T11:15:45",
      "operations":[
         [
            "transfer_to_vesting",
            {
               "fee":"0.000000 SPHTX",
               "from":"FROM_ACC",
               "to":"TO_ACC",
               "amount":"10.000000 SPHTX"
            }
         ]
      ],
      "extensions":[

      ],
      "signatures":[
         "1f1256e41a0681a4edac50e64c6d961d1e4b8061daf7970c16a2402a05583c4547527e6b01f3f90b8c3cc3ee84f078af5f43586b38104a851decfb562c3cbdf7a0"
      ],
      "transaction_id":"b9279a1aefed6918e465362db6083c3949677fbd",
      "block_num":141190,
      "transaction_num":0
   }
}

withdraw_vesting

Set up a vesting withdraw request. The request is fulfilled once a day over the next 27 days. Example curl command:

curl -s --data '{"jsonrpc": "2.0", "method": "withdraw_vesting", "params": ["FROM_ACC", "10 VESTS", true ], "id": 1}' -X POST CLI_WALLET_URL

Example output:

{
   "id":1,
   "result":{
      "ref_block_num":10199,
      "ref_block_prefix":2603750878,
      "expiration":"2018-08-20T11:19:51",
      "operations":[
         [
            "withdraw_vesting",
            {
               "fee":"0.000000 SPHTX",
               "account":"FROM_ACC",
               "vesting_shares":"10.000000 VESTS"
            }
         ]
      ],
      "extensions":[

      ],
      "signatures":[
         "1f6c185ca033443982cbacde61e9d0bcdb0bb393f15aec6a7f00fb0d3e3a48b9774f62824823c3aca1574940b1b822c9e4b15bc72728b639179cdcdc55b8dcf517"
      ],
      "transaction_id":"9139206e779cf35901de7b8104b225c529408b24",
      "block_num":141272,
      "transaction_num":0
   }
}