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)
}
}
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.2.tar.gz
(66.6 MB
view hashes)
Built Distributions
Close
Hashes for gscdk-0.6.2-py3-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 82cb81e62eb6b35a48dd7b4c56401247997b396e8e7837051cae944aeeffbf57 |
|
MD5 | 843d0a9820fed77c005e848825921dd4 |
|
BLAKE2b-256 | 0d8e5823948eca7e6a75ffff5252146b5daff52aa65f67ae6cd781fb72276187 |
Close
Hashes for gscdk-0.6.2-py3-none-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 825f2ff0b00a95ec752e82d3c6f25394dd3c2a08c722a4dcd7b684d8a3985485 |
|
MD5 | 64b6a22ee78b2194adf71132d3d91e33 |
|
BLAKE2b-256 | 189bf4cb139492c413b602ec8c16ca6b1115749ea57f2589de4904238a8fe519 |
Close
Hashes for gscdk-0.6.2-py3-none-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7d9eaf43cc88221a3f0e5ab343b21c7bbc5412cd5e525ff6a9eaf175c62eae43 |
|
MD5 | d616f7b6723dc2f975deb6400e9573d1 |
|
BLAKE2b-256 | bb66fb2b8c395805fc2e33ddb62b653f1e358459eb88b0adee50f9de336c8748 |