6

I want to sign a transaction to use it with the rpc endpoint v1/chain/push_transaction.

Until nodeos v.1.1 its was explained in the docs on how to use nodeos (probably keosd indirectly) to do wallet operations like signing. Now it seems like this is gone. starting a local node still logs:

keosd [...] add api url: /v1/wallet/sign_transaction

But if I try to use this endpoint it gives me a 404 error. Is there any other way of signing the transaction using python?

Edit: My request looks like this

[{
        "expiration": "2018-10-26T15:30:32.000",
        "ref_block_num": 21149807,
        "ref_block_prefix": 3590041248,
        "context_free_actions": [],
        "actions": [{
            "account": "eosio.token",
            "name": "transfer",
            "authorization": [{
                "actor": "testertimohe",
                "permission": "active"
            }],
            "data": "0000000000ea305500000000487a2b9d102700000000000004454f53000000001163726561746564206279206e6f70726f6d"
        }],
        "signatures": []
    },
    ["EOS6gXwNz2SKUNAZcyjzVvg6KdNgA1bSuVzCr8c5yWkGij52JKx8V"], ""
]
r = requests.post(
    f'http://localhost:8888/v1/wallet/sign_transaction', json=data)
response = json.loads(r.text)

I am getting the ref_block_num and ref_block_predix from /get_block and /get_info and the data from /abi_json_to_bin

What I see in the nodeos logs:

nodeosd_1 | debug 2018-10-25T08:29:34.909 thread-0 http_plugin.cpp:296 handle_http_request ] 404 - not found: /v1/wallet/sign_transaction

Generally my understanding is that because you don't send the private key but the public key it probably looks in your keos wallet if this public key exists and then takes the private key from there to sign, is that right?

3
+50

What you are missing here is the chain ID of the network.

Mainnet: aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906

Jungle Testnet: e70aaab8997e1dfce58fbfac80cbbb8fecec7b99cf982a9444273cbc64c41473

It has to be added in the " " field just after the key.

Your request for Jungle Testnet should be:

[{
        "expiration": "2018-10-26T15:30:32.000",
        "ref_block_num": 21149807,
        "ref_block_prefix": 3590041248,
        "context_free_actions": [],
        "actions": [{
            "account": "eosio.token",
            "name": "transfer",
            "authorization": [{
                "actor": "testertimohe",
                "permission": "active"
            }],
            "data": "0000000000ea305500000000487a2b9d102700000000000004454f53000000001163726561746564206279206e6f70726f6d"
        }],
        "signatures": []
    },
    ["EOS6gXwNz2SKUNAZcyjzVvg6KdNgA1bSuVzCr8c5yWkGij52JKx8V"], "e70aaab8997e1dfce58fbfac80cbbb8fecec7b99cf982a9444273cbc64c41473"
]
r = requests.post(
    f'http://localhost:8888/v1/wallet/sign_transaction', json=data)
response = json.loads(r.text)

Also, make sure that keosd is running at the port 8888. And the private key is imported into the wallet and wallet is unlocked.

Good luck..!

3

The api '/v1/wallet' is from the server keosd, not the nodeosd. You may change the port that keosd served.

  • I am not able to connect to keos directly: requests.exceptions.ConnectionError: HTTPConnectionPool(host='127.0.0.1', port=8900): Max retries exceeded with url: /v1/wallet/create (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x10eed2da0>: Failed to establish a new connection: [Errno 61] Connection refused',)) Also in the docks they use port 8888 which would be nodeos not keosd directly: developers.eos.io/keosd/v1.3.0/reference#create can you give me an example of a call which works for you? – solaire Oct 26 '18 at 10:32
  • I can somewhat call keos on port 9876 but I am getting this response requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response',)) and on nodeos it says "incoming message length unexpected" – solaire Oct 26 '18 at 10:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.