eospyo Tutorial

What are the other options and how do they compare

  • pyeoskit :
    They have a great project. It used to be heavily based on UUOSKit, so I’ll focus on just one of them.
  • UUOSKit:
    It seems they found a clever way to use libuuoskit binaries using cython.
    That is a good idea since we need to maintain only one codebase and they may get the benefits from a pre-compiled code.
    But we are quite concerned by the use of an external wallet (in this case, a file on the disk) that would behave like a global state. Also, it is a problem if you're to use non-resilient or read-only file systems (like some containers or function-as-a-service computing).
  • eospy:
    Their project is similar to ours, but seems to have slowed development significantly.
  • µEOSIO:
    We can’t state how thankful we are for this project and the contributors as EOSPYO is based on this and we use some of this code in EOSPYO.
  • Our api, however, is very different. Also we’re using nodeos rpc calls to serialize the data.

Summary, why eospyo is different

Getting Started

Requirements

  1. Python 3.8+ For simplicity, this tutorial is assuming you’ve already gotten Python 3.8+ installed and running. If not, please follow this link
  2. Pip or Poetry is encouraged To install Pip follow this link. To install Poetry follow this link.
  3. Either docker or keys for an eosio testnet
    This link includes various containerized docker instances Alternatively, EOS testnet connections can be found here WAX testnet connections and account creation can be found here Note: if you want to contribute to eospyo development, you will have to setup docker to run tests through pytest.
  4. A contract to interact with ? The contracts relevant to the examples will be linked. However, basic system contracts such as eosio.token are available on all testnets referenced in this document.

Installation

Core concepts and ideology

Additional useful tools

Block explorers

EOSIO tooling

EOSIO Reading

Examples with explanations

WAX System Token Transfer Example

Requirements

  1. Create two accounts here Save your keys for both accounts as you will require them to complete the exercises EOSIO Naming conventions for account creation can be found here An abbreviated (and sufficient for purposes of this tutorial) are inline with the linked tool.
  2. Add tokens to appropriate accounts at the same location or there are instructions for making this a RESTful call if you have the desire/need to automate the said process for automated testing.

Example break down line by line

"""Transfer some WAX to a receiver account."""
import eospyo
data = [
eospyo.Data(name="from", value=eospyo.types.Name("me.wam")),
eospyo.Data(name="to", value=eospyo.types.Name("receiver")),
eospyo.Data(
name="quantity",
value=eospyo.types.Asset("55.00000000 WAX"),
),
eospyo.Data(
name="memo",
value=eospyo.types.String("Trying Eospyo"),
),
]
  • Name is an account name (string) has to follow the EOSIO account naming specifications (listed in the Data types section).
  • Asset is the type of token as defined in the chain appropriate eosio.token contract.
  • String is a classic UTF8 compliant string. However, we currently do not support multi-byte UTF8 characters (such as special characters, emojis, etc) due to unpredictable serialization, this is in the pipeline for future fixes.
auth = eospyo.Authorization(actor="me.wam", permission="active")
action = eospyo.Action(
account="eosio.token",
name="transfer",
data=data,
authorization=[auth],
)
raw_transaction = eospyo.Transaction(actions=[action])
net = eospyo.WaxTestnet()
linked_transaction = raw_transaction.link(net=net)
key = "a_very_secret_key"
signed_transaction = linked_transaction.sign(key=key)
resp = signed_transaction.send()

Complete examples

Appendix

Network Names and URLs as defined

Data types

EOSPYO Classes and Methods

Exceptions

ConnectionError

ValidationError

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Detroit Ledger Technologies

Detroit Ledger Technologies

179 Followers

A benevolent block producer crew based in Detroit, MI building value on blockchain networks. Planting new seeds of economic opportunity.