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.4.1.tar.gz
(64.7 MB
view hashes)
Built Distributions
Close
Hashes for gscdk-0.4.1-py3-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 65fba36aa86eebe48408e246ba8d6a5a155148487150d27b86f7dc729608af01 |
|
MD5 | 15c92a726214c294ce954299a2e0fa44 |
|
BLAKE2b-256 | 664049c3a8ce0cd198e9e598a3e4a119d2363004df6a7e53564f7ba48ac0baef |
Close
Hashes for gscdk-0.4.1-py3-none-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4fb7ada5e45cb0a2a709f6bc2183d012d8a6507f92695ab36714f2f0dff89538 |
|
MD5 | e27cdde46e3d07988453c119ad37c2c6 |
|
BLAKE2b-256 | 21f6bd8129b206090990800ae30b13246e683fac9859affee84f076d61ed242f |
Close
Hashes for gscdk-0.4.1-py3-none-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5cbfbd9b0bf5ecb8492333c7d6f2def5ef93b64bcbf53ceeb110b7103152cf83 |
|
MD5 | f06e6576fc38f514c1742d013b5c4d68 |
|
BLAKE2b-256 | d992aabd72d1a362c4971e3693eea46773eb3d6281602ca5bd9d9a68cd7277a0 |