- Slides
- Links, Infos and Resources <-- this document has a lot of information and links, be sure to take a look!
- Workshop Agenda
If you have any issues or ideas for improvements, please leave your feedback on the GitHub repository and on the NEO Discord.
- Setup neo-python and neo-privatenet-docker
- First smart contract using
print
,Runtime.Log
andRuntime.Notify
: 1-print.py- Learn using neo-python's
build
command with thetest
argument - Test differences between Log and Notify
- Learn using neo-python's
- Basic smart contract using storage: 2-storage.py
- Storage is one of the key components of most smart contracts
- Everything is handled as bytes
- A domain registration smart contract: 3-domain.py
- users can query, register, transfer and delete domains
- important concept: checking of ownership
- NEX ICO template: https://github.com/neonexchange/neo-ico-template
Linux or Mac is recommended, and you need Python 3.5 at the moment. If you are using Windows, either setup a VM or use the Linux Subsystem (see also here for more infos).
Clone neo-python and setup everything as described in the README. Then create a symlink of this workshop folder to neo-python/sc
, which makes it easier to import, build and execute the smart contracts in this workshop.
# These two are just examples for playing around and experimenting:
def Main():
def Main(operation):
# This is how most real smart contracts look like:
def Main(operation, args):
See also: parameter & return value types
from boa.blockchain.vm.Neo.Runtime import Log, Notify
from boa.blockchain.vm.Neo.Runtime import GetTrigger, CheckWitness
from boa.blockchain.vm.Neo.TriggerType import Application, Verification
from boa.blockchain.vm.Neo.Storage import GetContext, Get, Put, Delete
from boa.code.builtins import concat
neo> build sc/1-print.py test 07 05 True False main
neo> build sc/2-storage.py test 07 05 True False main
neo> build sc/3-domain.py test 0710 05 True False query ["test.com"]
- neo-boa examples
- https://github.com/neonexchange/neo-ico-template
- Storage helper: nex-ico-template/nex/common/storage.py
- Get info about attached NEO or GAS: nex-ico-template/nex/common/tx_io.py
- https://github.com/CityOfZion/neo-boa/blob/master/boa/tests/src/OpCallTest.py
- https://github.com/neo-project/neo/wiki/Network-Protocol
You can get the last block timestamp from the blockchain with this code.
def now():
height = GetHeight()
current_block = GetHeader(height)
return current_block.Timestamp
Might not work with neo-boa 0.2.2, downgrade to 0.2.1 (see also CityOfZion/neo-boa#35).
See https://medium.com/proof-of-working/coz-first-dapps-competition-dapp-review-3a6b284afaef#414c