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.2.tar.gz
(59.3 MB
view hashes)
Built Distributions
Close
Hashes for gscdk-0.3.2-py3-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 945181c0f0e87e9aa423f8b6fd5913d640a41e8e8b3c99a72bdb323c55bbc4fa |
|
MD5 | ab218703ba7aef4cc9527cb9651aeee5 |
|
BLAKE2b-256 | 576e3bb09cba1880af98dcf1dd870867e2ceaa3f1956b88d3ae7cd289039c6c9 |
Close
Hashes for gscdk-0.3.2-py3-none-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5b19693d712aae7ea745a09c9a1e7b547a12024af0662e8bb1deec69060c87af |
|
MD5 | 5090d87fb8b7200bfe8240098ad6678d |
|
BLAKE2b-256 | 62d4b86fd222688b1857f19b7f9e970cd20de2f5c95b0694d44d68b51c7b6a8f |
Close
Hashes for gscdk-0.3.2-py3-none-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 21aaed6cfc562f2e0d70f11c90fb3ce759a708d1439206c73ea278d8e6d68b65 |
|
MD5 | bfeb45b640b2c4600cb5f93e8a910874 |
|
BLAKE2b-256 | be16c01d0cbca22af3e2db46ce7d4bea88ac7677d0110de09217bb5003504d69 |