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
eosio-go
Initialize 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
Build 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.2.1.tar.gz
(4.1 kB
view hashes)
Built Distributions
Close
Hashes for gscdk-0.2.1-py3-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | af7dde90417839b70b52dc3930bf06373d0dd496c035f0b34677e7624ca54a88 |
|
MD5 | 7ba4b562869cc439371e8246eacdb14a |
|
BLAKE2b-256 | 5a8bae8a44c1d095e83d634bbe91674179e2f778818dcb5f4538c2e459db6614 |
Close
Hashes for gscdk-0.2.1-py3-none-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b0e2ac7eb6d6506c7334b95175a8c6eb051632483b6be27a51c3d7473a7a1d9 |
|
MD5 | a4a3674c95652cf8b9b50cf2a3dfbf50 |
|
BLAKE2b-256 | 53576d2cd4751f5f65e6b182f1460dba9c866674173e935ef9ac722eaf1ea55e |
Close
Hashes for gscdk-0.2.1-py3-none-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4e8b2f020853871254ea54c116ea9a4f68fc0cc69cf0a1eabf2b4db3556413ae |
|
MD5 | 2862ee323fc94da542fff03779295a77 |
|
BLAKE2b-256 | d4e99f1c580b3acd4639d06cd89c8b68c5245afbe8ceedee7ae51402999fb948 |