Developing smart-contracts with neo-python — what we learned

Nuno Silva
Blocksmith
Published in
2 min readMar 8, 2018

During one of our hackathons a group of us decided to try out neo-python as the SDK for a simple smart-contract. This is what we learned from that experience.

One operation per line

This one toke us awhile to figure it out, definity _one of those_ things that makes us want to pull out our hair.

Don’t:

current_data = store.deserialize_bytearray(data)
current_data.append(concat(sender, content))

Do:

new_entry = concat(sender, content)
current_data = store.deserialize_bytearray(data)
current_data.append(new_entry)

The interpreter and compiler are still very rudimentary, so “complex” instructions like the former one are still not possible.

Serialization is done only via the utils

We expected to have better support for serialization of data to be inserted in the Storage, but sadly it’s still a work in progress.

Meanwhile we’ve found this handly snippet that does the job just good enough.

No support for complex data structures

This like dict are not available. The most complex data structure is the list. Also, be sure to look at the builtins.

Getting the contract invoker hash

Use GetCallingScriptHashfromboa.blockchain.vm.System.ExecutionEngine to know the address of the caller/sender.

Resources to keep close by:

Note

This was relevant for the most up-to-date neo-python SDK as of Feb 24th, 2018.
We are aware that development is very much on the way and many things are changing.

We hope this can help anyone hacking away in such preliminary SDKs as we do! It was a bit of a frustrating experience since it limited us a bit on time, but nevertheless we learned a lot from it.

We’re more aware of the current status of the python SDK and how we can contribute to make it more powerful and ease developers life.

--

--

Nuno Silva
Blocksmith

Rubyist, web developer in general. Computer graphics and parallel computing advocate.