From 57c7df4dff299c8e3896efc4ff62feeb84a69017 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Thu, 15 Aug 2019 19:51:07 +0300 Subject: [PATCH] *: remove remaining references to neo-storm, update README README update partially reverts c8d7671d268be1c17befbd8d57761b5b6da41d6f and updates it with current commands and sample output. --- README.md | 52 ++++++++++++++++++++++++++++- cli/smartcontract/smart_contract.go | 12 +++---- docs/runtime.md | 2 +- 3 files changed, 58 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index d6b06371d..38f245873 100644 --- a/README.md +++ b/README.md @@ -126,7 +126,57 @@ ApplicationConfiguration: ``` ## Writing smart contracts in Go -Golang's development is been moved to a separate repository which you can find here [neo-storm](https://github.com/CityOfZion/neo-storm) +In depth documentation about the **neo-go** compiler and smart contract examples can be found inside the [compiler package](https://github.com/CityOfZion/neo-go/tree/master/pkg/vm/compiler). + +### Compile a smart contract + +``` +./bin/neo-go contract compile -i mycontract.go +``` + +By default the filename will be the name of your `.go` file with the `.avm` extension, the file will be located in the same directory where you called the command from. If you want another location for your compiled contract: + +``` +./bin/neo-go contract compile -i mycontract.go --out /Users/foo/bar/contract.avm +``` + +### Debugging your smart contract +You can dump the opcodes generated by the compiler with the following command: + +``` +./bin/neo-go contract inspect -i mycontract.go +``` + +This will result in something like this: + +``` +INDEX OPCODE DESC +0 0x54 PUSH4 +1 0xc5 NEWARRAY +2 0x6b TOALTSTACK +3 0x5a PUSH10 +4 0x6a DUPFROMALTSTACK +5 0x0 PUSH0 +6 0x52 PUSH2 +7 0x7a ROLL +8 0xc4 SETITEM +9 0x6a DUPFROMALTSTACK +10 0x0 PUSH0 +11 0xc3 PICKITEM +12 0x5a PUSH10 +13 0xa2 GTE +14 0x64 JMPIFNOT +15 0x7 7 +15 0x0 0 +17 0x51 PUSH1 +18 0x6c FROMALTSTACK +19 0x75 DROP +20 0x66 RET +21 0x0 PUSH0 +22 0x6c FROMALTSTACK +23 0x75 DROP +24 0x66 RET +``` # Contributing diff --git a/cli/smartcontract/smart_contract.go b/cli/smartcontract/smart_contract.go index 5bfe32c14..333aa01c1 100644 --- a/cli/smartcontract/smart_contract.go +++ b/cli/smartcontract/smart_contract.go @@ -121,11 +121,11 @@ func initSmartContract(ctx *cli.Context) error { return cli.NewExitError(err, 1) } - // Ask contract information and write a storm.yml file unless the -skip-details flag is set. - // TODO: Fix the missing storm.yml file with the `init` command when the package manager is in place. + // Ask contract information and write a neo-go.yml file unless the -skip-details flag is set. + // TODO: Fix the missing neo-go.yml file with the `init` command when the package manager is in place. if !ctx.Bool("skip-details") { details := parseContractDetails() - if err := ioutil.WriteFile(filepath.Join(basePath, "storm.yml"), details.toStormFile(), 0644); err != nil { + if err := ioutil.WriteFile(filepath.Join(basePath, "neo-go.yml"), details.toStormFile(), 0644); err != nil { return cli.NewExitError(err, 1) } } @@ -205,8 +205,8 @@ type ContractDetails struct { func (d ContractDetails) toStormFile() []byte { buf := new(bytes.Buffer) - buf.WriteString("# Storm specific configuration. Do not modify this unless you know what you are doing!\n") - buf.WriteString("storm:\n") + buf.WriteString("# NEO-GO specific configuration. Do not modify this unless you know what you are doing!\n") + buf.WriteString("neo-go:\n") buf.WriteString(" version: 1.0\n") buf.WriteString("\n") @@ -222,7 +222,7 @@ func (d ContractDetails) toStormFile() []byte { buf.WriteString("\n") buf.WriteString("# Module section contains a list of imported modules\n") - buf.WriteString("# This will be automatically managed by the neo-storm package manager\n") + buf.WriteString("# This will be automatically managed by the neo-go package manager\n") buf.WriteString("modules: \n") return buf.Bytes() } diff --git a/docs/runtime.md b/docs/runtime.md index 92ed485d0..e98b3af20 100644 --- a/docs/runtime.md +++ b/docs/runtime.md @@ -1,5 +1,5 @@ # Runtime -A brief overview of NEO smart contract API's that can be used in the neo-storm framework. +A brief overview of NEO smart contract API's that can be used in the neo-go framework. # Overview 1. [Account]()