3

How can I transfer Tez using pytezos ? I found how to originate contracts and manipulate them, but I can't figure out how to make a simple transfer.

3

As far as I can see from the available code, docs and tests, there is no "convenient" way of doing this. Instead, you have to manually forge and inject the transfer token operation. Pytezos is basically a wrapper around the node RPC. You could try inspecting the RPCs necessary by running performing a transfer with tezos-client -l, which output the RPCs involved. And then replicate them using pytezos. The pytezos README contains an example of forging an endorsement operation (https://github.com/murbard/pytezos#rpc-query-builder-and-a-little-bit-more). You can base your code on this example. I also think this question merits a stack exchange post and an update to the pytezos documentation.

1

Like that:

from pytezos import pytezos
from decimal import Decimal

pytezos.using(key='edsk...', shell='babylonnet') \
    .transaction(destination='tz1...', amount=Decimal('123.456')) \
    .autofill().sign().inject()

Note, that you can also check what's going on during each step if using an interactive notebook, i.e.:

>>> pytezos.transaction(...)
<<< # shows you unsigned content and list of available helpers

Here is a sample notebook with a step-by-step tutorial you can play online: https://colab.research.google.com/drive/1em03Tfzr2D3LqOcLkc9Qm7E-jzrdfTEh

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.