I'm trying to use pytezos with sandboxed tezos server. Pytezos requires the following arguments for connection:

I tried the identity.json created by the sandbox server without success, seems like pytezos really wants a mnemonic:

>>> from pytezos import pytezos
>>> pytezos.using(shell='http://localhost:18731', key='/tmp/tezos-node.TyiwsQkx/identity.json')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/jpic/.local/lib/python3.7/site-packages/pytezos/tools/docstring.py", line 67, in __call__
    return method(self.class_instance, *args, **kwargs)
  File "/home/jpic/.local/lib/python3.7/site-packages/pytezos/interop.py", line 68, in using
    return self._spawn(shell=shell, key=key)
  File "/home/jpic/.local/lib/python3.7/site-packages/pytezos/client.py", line 27, in _spawn
    key=kwargs.get('key', self.key)
  File "/home/jpic/.local/lib/python3.7/site-packages/pytezos/interop.py", line 50, in __init__
    self.key = Key.from_faucet(key)
  File "/home/jpic/.local/lib/python3.7/site-packages/pytezos/crypto.py", line 214, in from_faucet
KeyError: 'mnemonic'
  • identity.json is the key your node uses on the peer to peer network for communication, it's not the key to an implicit account. – Arthur B Nov 4 at 5:48
  • That's what I thought, but I couldn't find any command in the manual to generate a faucet account with the sandboxednet, perhaps that would help ? – jpic Nov 4 at 5:56
  • This might help baking-bad.github.io/pytezos – Arthur B Nov 4 at 6:01

According to https://baking-bad.github.io/pytezos/

It does expect a json file from https://faucet.tzalpha.net

  • Well that's also what I thought, but thanks to your previous comment I figured key also accepts an alias ! As such, I'm looking forward to use key='bootstrap1' ... however, it looks for keys inside ~/.tezos-client/secret_keys, so if only I could find or make such file for the sandboxed tezos then I could contribute a little note about sandboxed mode in pytezos documentation. – jpic Nov 4 at 6:09
  • Apparently I can get the secret key from tezos-init-sandboxed-client.sh and make a secret key file, but that's going to be a bit hacky as such I'll be able to cook an answer but perhaps not a documentable solution. – jpic Nov 4 at 6:12
  • Actually we do have quite some options github.com/baking-bad/pytezos/blob/master/pytezos/… – jpic Nov 4 at 6:14
  • Got it, you can pass the unencrypted key to the key argument ... sorry for the noise, contributing an answer and backlinking in this question. Have a great day ! – jpic Nov 4 at 6:17
  • Sounds like you have a better answer than mine now, you should post it as an answer to your own question – Arthur B Nov 4 at 6:36

Accounts are pre-created in Sandboxed mode, this shows how to find the secret keys:

$ grep SECRET src/bin_client/tezos-init-sandboxed-client.sh
export BOOTSTRAP1_SECRET="unencrypted:edsk3gUfUPyBSfrS9CCgmCiQsTCHGkviBDusMxDJstFtojtc1zcpsh"
export BOOTSTRAP2_SECRET="unencrypted:edsk39qAm1fiMjgmPkw1EgQYkMzkJezLNewd7PLNHTkr6w9XA2zdfo"
export BOOTSTRAP3_SECRET="unencrypted:edsk4ArLQgBTLWG5FJmnGnT689VKoqhXwmDPBuGx3z4cvwU9MmrPZZ"
export BOOTSTRAP4_SECRET="unencrypted:edsk2uqQB9AY4FvioK2YMdfmyMrer5R8mGFyuaLLFfSRo8EoyNdht3"
export BOOTSTRAP5_SECRET="unencrypted:edsk4QLrcijEffxV31gGdN2HU7UpyJjA8drFoNcmnB28n89YjPNRFm"
export ACTIVATOR_SECRET="unencrypted:edsk31vznjHSSpGExDMHYASz45VZqXN4DPxvsa4hAyY8dHM28cZzp6"

Use one of these unencrypted private keys to connect to the sandbox:

>>> from pytezos import pytezos
>>> pytezos.using(shell='http://localhost:18731', key='edsk3gUfUPyBSfrS9CCgmCiQsTCHGkviBDusMxDJstFtojtc1zcpsh')
<pytezos.client.PyTezosClient object at 0x7f2c2d78da10>
.key  # tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx
.shell  # http://localhost:18731 ()

A pull request is currently open to document this so hopefully it should be there soon : https://github.com/baking-bad/pytezos/pull/36 EDIT: merged !

New contributor
jpic is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

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.