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)
}
}
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.1.5.tar.gz
(4.1 kB
view hashes)
Built Distributions
Close
Hashes for gscdk-0.1.5-py3-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | af7187920818b19f35316974c37d0fcaa71b90a8907af4e2dfe37e635ee4cf7d |
|
MD5 | ee04638dd95f18298f9ecb0fedca45a2 |
|
BLAKE2b-256 | c96c78f39ceb55c2aa2f64f2ef88e6e1861c8fca9d8b0d0142aedbf48ca719ea |
Close
Hashes for gscdk-0.1.5-py3-none-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1125bdab1d2e747085bfd58bd7d68114209f3cfdfae165f3976b96fa9b614f37 |
|
MD5 | 66e56aaa51475fe91d810f8b192b3bba |
|
BLAKE2b-256 | 41b6e8f61363f0659866a3e6dd2bf6afc309f3424e7a45b4aedf9bdcea67b946 |
Close
Hashes for gscdk-0.1.5-py3-none-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d2b18b46e044edae34f3f1cbe43055e3acf9c49d5745c011eb1d6ab116cf533e |
|
MD5 | c9cb3f1e4b75177a5b5c993a04668492 |
|
BLAKE2b-256 | 692ed8985703e59a99c031a76f2271374add07724b49eb11f8231e3e7f092f6e |