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.3.5.tar.gz
(59.3 MB
view hashes)
Built Distributions
Close
Hashes for gscdk-0.3.5-py3-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8035334ff9faf24c24a9b3967ee05e40a80fbacbed710e82e0beb57ef8244620 |
|
MD5 | 6cf6a4291d58be48404cbe999a7bbb68 |
|
BLAKE2b-256 | afa9604a4acec1c61488b61e0367b37931e0a255384bf41e80d5c3a9611ec055 |
Close
Hashes for gscdk-0.3.5-py3-none-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 29c2879583f271aa3787e180afebcad08eb01cf4f4f8e864a527f08e70c383a5 |
|
MD5 | 4707f48a24dea8a063c519eff83aa95d |
|
BLAKE2b-256 | 79374acc62b05dd54973ce157c6b629df5ec9aaa2b2fba0f2fe43ea8679083a2 |
Close
Hashes for gscdk-0.3.5-py3-none-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f4910739b28ca7f227c4b61c50a2dc7574aedc5aaab05613451e8d0bc8ee779b |
|
MD5 | 58cbc9f7844b85e66162a7602303fbd0 |
|
BLAKE2b-256 | ad286a2d5c84b3741839db7e78d2659e60a905337c4e0858e7205bb35ce35d31 |