Skip to Content
Foundations of Blockchain
book

Foundations of Blockchain

by Koshik Raj
January 2019
Beginner to intermediate
372 pages
11h 17m
English
Packt Publishing
Content preview from Foundations of Blockchain

Basic smart contract

First, we will create a simple Python script that returns a concatenated string to greet the user:

from boa.builtins import concat 
 
def main(name): 
  return concat("Hello ", name) 

The contract script uses the concat method provided by boa to concatenate two strings. Every smart contract should have a function called main, which will be the entry point. The smart contract needs to be compiled into byte code, which can be executed in the NeoVM. The contract can be compiled by the neo-python shell using the neo-boa compiler as follows:

build hello.py test 07 07 False False Alice 

The build command is supplied with a test argument to test the sample outcome. The code immediately after the test flag represents the data ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Blockchain Basics

Blockchain Basics

Daniel Drescher
What Is Blockchain?

What Is Blockchain?

Sir John Hargrave, Evan Karnoupakis
Mastering Blockchain

Mastering Blockchain

Lorne Lantz, Daniel Cawrey

Publisher Resources

ISBN: 9781789139396Supplemental Content