Go Smart Contract Development Kit
Project description
Go Smart Contracts Development Kit
What the Go Smart Contracts look like?
Here is an example
package main
import (
"github.com/uuosio/chain"
)
//table mytable
type MyData struct {
primary uint64 //primary: t.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.Get(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 github.com/learnforpractice/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
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 Striping WASM File after Building
eosio-go build -strip=false -o mycontract .
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.4.2.tar.gz
(64.7 MB
view hashes)
Built Distributions
Close
Hashes for gscdk-0.4.2-py3-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 11339a8c5c74c14ff5a60fa2e6071e931ba1e2d0987ca5f0eacaab4bb520fdc5 |
|
MD5 | 28ce73d88ec5775304ee4d989954885e |
|
BLAKE2b-256 | e9f41dcec7e589511e28dbd6e9dc3c507fcf16a845354adb2fc18d9cae4b225e |
Close
Hashes for gscdk-0.4.2-py3-none-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2d70138925b8526331d09e4819e5c8062341317fb26f3e7326055203d84e1c27 |
|
MD5 | 7f05188965edae38c076e96a3ee0f016 |
|
BLAKE2b-256 | 8df18191f4c0987e6308d5777758b7e8d8ed79c9e018d3dd01c23ee8cf85eddf |
Close
Hashes for gscdk-0.4.2-py3-none-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4fa76d3f23c8ca1b0d3a135c961c769bdd9a86f0e1b61a1ec35513192f487f2c |
|
MD5 | a48e773f70d1e8ee6ce55a0257a7b769 |
|
BLAKE2b-256 | 630a6f55c0b4a436b6441303ee396a2560dc0054776dab0c6033c9e86044eeb3 |