Go Smart Contract Development Kit
Project description
Go Smart Contracts Development Kit
What a Go Smart Contract looks like?
Here is an example
package main
import (
"github.com/uuosio/chain"
)
//table mytable
type MyData struct {
primary uint64 //primary
name string
}
//contract mycontract
type MyContract struct {
Receiver chain.Name
FirstReceiver chain.Name
Action chain.Name
}
func NewContract(receiver, firstReceiver, action chain.Name) *MyContract {
return &MyContract{receiver, firstReceiver, action}
}
//action sayhello
func (c *MyContract) SayHello(name string) {
code := c.Receiver
scope := code
payer := c.Receiver
mydb := NewMyDataDB(code, scope)
primary := uint64(111)
if it, data := mydb.GetByKey(primary); it.IsOk() {
if data.name != name {
chain.Println("Welcome new friend:", name)
} else {
chain.Println("Welcome old friend", name)
}
data.name = name
mydb.Update(it, data, payer)
} else {
chain.Println("Welcome new friend", name)
data := &MyData{primary, name}
mydb.Store(data, payer)
}
}
Quick Start
Installation
python3 -m pip install gscdk
For Windows platform:
python -m pip install gscdk
Upgrade From an Old Version
python3 -m pip install --upgrade gscdk
For Windows platform:
python -m pip install --upgrade gscdk
Installing gscdk in Docker
Building docker image for gscdk
docker build https://github.com/uuosio/gscdk-docker#main -t gscdk/test
Running
docker run -w /root/dev -it --rm -v "$(pwd)":/root/dev -t gscdk/test /bin/bash
Building Go Smart Contracts Compiler
Follow the steps in Building
That will build tinygo command in compiler/build directory that support for building Go Smart Contracts.
export PATH=$(pwd)/compiler/build:$PATH
eosio-go
Initializing a project with "init" subcommand
"init" command initialize a project with contract name
eosio-go init mycontract
cd mycontract
Generating ABI and Extra Code for Smart Contracts
eosio-go gencode -o generated.go .
Code generation is also the default option for "build" command
Building Go Smart Contracts Project
Compiling the Source Code
eosio-go build -o mycontract.wasm .
Disable Code Generation during Building
eosio-go build -gen-code=false -o mycontract .
Disable Code Optimization
Specifying -d
or --debug
option to disable wasm optimization.
eosio-go build -d -o mycontract.wasm .
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
gscdk-0.6.3.tar.gz
(68.7 MB
view hashes)
Built Distributions
Close
Hashes for gscdk-0.6.3-py3-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5fcb8d540138f9283f3711ef20e51ae5fd2921754f77a11cf91706f0dc094265 |
|
MD5 | 61a6ce2f2ed2562b7f18116236df6be2 |
|
BLAKE2b-256 | b5e5de7b0d90ae8de19115ec23eea1574c42147e2d472d386bfe552d460bb7f1 |
Close
Hashes for gscdk-0.6.3-py3-none-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 86e1990d11f13641091c80f1c628d0b6446e4f2e1f48baa61d87548a62eee105 |
|
MD5 | 7c090dbf2b58583be1b1d3347c55893d |
|
BLAKE2b-256 | 2e4ad19db69981a2ac1eddedbbee92095e1be5b6ce223f314b68a99fc592bdf1 |
Close
Hashes for gscdk-0.6.3-py3-none-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5712d17054e81793f23c24b163afaf7decc795398e167a56e6611abee3803f55 |
|
MD5 | 4f896b4a6915cf8f6c2b05b03520d3c9 |
|
BLAKE2b-256 | 08b5ff93700b892fc5e947e23eeb9aeb2aa14869f069e35a937fdec2ded25899 |