neo-go/examples
Anna Shaleva 0948d53244 examples: add documentation
And provide the wallet for examples `my_wallet.json` with the owner
address inside.
2021-03-23 16:46:15 +03:00
..
engine compiler: check emitted event names 2020-11-26 13:49:58 +03:00
events compiler: save both VM and smartcontract types 2020-12-09 22:35:22 +03:00
iterator core: add flags to Storage.Find 2021-01-15 21:12:08 +03:00
runtime examples: update owner address 2021-03-22 18:12:56 +03:00
storage core: add flags to Storage.Find 2021-01-15 21:12:08 +03:00
timer examples: update owner address 2021-03-22 18:12:56 +03:00
token examples: update owner address 2021-03-22 18:12:56 +03:00
token-sale examples: update owner address 2021-03-22 18:12:56 +03:00
my_wallet.json examples: add documentation 2021-03-23 16:46:15 +03:00
README.md examples: add documentation 2021-03-23 16:46:15 +03:00

NEO-GO smart contract examples

examples directory contains smart contract examples written in Go. These examples are aimed to demonstrate the basic usage of Go programming language to write NEO smart contracts as far as to provide a brief introduction to the NEO-specific interop package application.

Examples structure

Each example represents a separate folder with the smart contract content inside. The content is presented by the smart contract code written in Go and the smart contract configuration file with .yml extension.

Some contracts have a contract owner, which is needed for witness checking and represented by the owner string constant inside the smart contract code. The owner account address is taken from the my_wallet.json. The wallet is located under the examples directory, has a single account inside with the my_account label which can be decrypted with the qwerty password. You can use my_wallet.json to deploy example contracts.

See the table below for the detailed examples description.

Example Description
engine This contract demonstrates how to use runtime interop package which implements an API for System.Runtime.* NEO system calls. Please, refer to the runtime package documentation for details.
events The contract shows how execution notifications with the different arguments types can be sent with the help of runtime.Notify function of the runtime interop package. Please, refer to the runtime.Notify function documentation for details.
iterator This example describes a way to work with NEO iterators. Please, refer to the iterator package documentation for details.
runtime This contract demonstrates how to use special _initialize and _deploy methods. See the compiler documentation for methods details. It also shows the pattern for checking owner witness inside the contract with the help of runtime.CheckWitness interop function.
storage The contract implements API for basic operations with a contract storage. It shows hos to use storage interop package. See the storage package documentation.
timer The idea of the contract is to count tick method invocations and destroy itself after the third invocation. It shows how to use contract.Call interop function to call, update (migrate) and destroy the contract. Please, refer to the contract.Call function documentation
token This contract implements NEP17 token standard (like NEO and GAS tokens) with all required methods and operations. See the NEP17 token standard specification for details.
token-sale The contract represents a token with allowance. It means that the token owner should approve token withdrawing before the transfer. The contract demonstrates how interop packages can be combined to work together.

Compile

Please, refer to the neo-go smart contract compiler documentation to compile example smart contracts.

Deploy

You can set up neo-go private network to deploy the example contracts. Please, refer to the consensus documentation to start your own privnet with neo-go nodes.

To deploy smart contracts, refer to the Deploying section of the compiler documentation.

Where to start

Feel free to explore neo-go smart contract development workshop to get the basic concepts of how to develop, compile, debug and deploy NEO smart contracts written in go.