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.6.tar.gz
(4.1 kB
view hashes)
Built Distributions
Close
Hashes for gscdk-0.1.6-py3-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d425fdbf1e349f18e36af6b3ef6c0b991412defbd45be7394e823e9a876826ab |
|
MD5 | d7e3de960f542dbf6474c8ef2ca80c79 |
|
BLAKE2b-256 | 34a69de685396fbdbf9eea5e91a3d51a090eabbdc9a1c1a2ac0185d25d77737e |
Close
Hashes for gscdk-0.1.6-py3-none-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 63c5efb4ae16bc78facf58326dfd2c7a619ca2fcce5d3b6d464ca4e410fd1e34 |
|
MD5 | b33b425ff8ec010f1c5992d7626fa4ca |
|
BLAKE2b-256 | 251d2417748003d77af554837a8cbda132bf4ae28ba2020787c8709d0de2b481 |
Close
Hashes for gscdk-0.1.6-py3-none-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ec90cbfbd2a060a6762390d83539a17a437f3526f24898ee53488def1446f8e1 |
|
MD5 | aee5ba5e6eb648fef2f7cda8f5ddc4fc |
|
BLAKE2b-256 | e3f8b97bba470eda13758500242a0a8bbc3f2c00c9fe74c1ccf61ab043a34e05 |