Go Smart Contract Development Kit
Project description
Go Smart Contracts Development Kit
Quick Start
Quick Start
What the Go Smart Contracts look like?
Here is an example
package main
import (
"github.com/uuosio/chain"
"github.com/uuosio/chain/logger"
)
//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 {
logger.Println("Welcome new friend:", name)
} else {
logger.Println("Welcome old friend", name)
}
data.name = name
mydb.Update(it, data, payer)
} else {
logger.Println("Welcome new friend", name)
data := &MyData{primary, name}
mydb.Store(data, payer)
}
}
Installation
pip install gscdk
Build 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.
Set PATH
export PATH=$(pwd)/compiler/build:$PATH
Install from Pre-built Binary
First download binary file from releases
For tar.gz file
tar -C /usr/local -xzf uuosio.gscdk-linux-0.1.0.tar.gz
export PATH=/usr/local/uuosio.gscdk/bin:$PATH
Install through a Python wheel package
python3 -m pip install https://github.com/uuosio/uuosio.gscdk/releases/download/v0.1.2/gscdk-0.1.0-py3-none-manylinux1_x86_64.whl
Change the wheel package download url as you need.
Install debian package directly on Ubuntu platform
sudo apt install ./uuosio.gscdk-linux-0.1.0.deb
eosio-go Command
Init Command
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
Build Command
Compile 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.2.0.tar.gz
(4.5 kB
view hashes)
Built Distributions
Close
Hashes for gscdk-0.2.0-py3-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 421d8736608e6fcac2b9b651638883b7876437fc19a977ee6402f7665301d3e8 |
|
MD5 | f7901b65112c3405611b65bb661dfbbf |
|
BLAKE2b-256 | f21f2860a132e703f0bb09757d6c3a471ff05e63ba829fa88f6b8e6068fbc5ee |
Close
Hashes for gscdk-0.2.0-py3-none-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 105e241c3e67280e692e6b6802005522279427c1c2f8bf49b737f0948d84d510 |
|
MD5 | 209b1c20431cce480942db0c7ffe4bc5 |
|
BLAKE2b-256 | d14ce7a210d3a3ac47e7759437cc489727453ade3d3ec58f78abdd9763115320 |
Close
Hashes for gscdk-0.2.0-py3-none-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 236b8539b193f83d1b84c50445cdef0e80c1ebfa730e7caab243107b2cb39864 |
|
MD5 | 69db837848bcfca60ac406a930364794 |
|
BLAKE2b-256 | 3a8786f75618fc052c35527ebb1de93dd8c22424abc5239fe30326f8805f80a7 |