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.0.tar.gz
(64.2 MB
view hashes)
Built Distributions
Close
Hashes for gscdk-0.4.0-py3-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e0ad2ed1c22e584b5bbe336eb4da8f5bb44500b07a857d682abfde681ac6b6ec |
|
MD5 | 23cd70662fa0dc08e95c447ea3833163 |
|
BLAKE2b-256 | 601e167726afe82eac3aa22f00f550d36b1d9f2896e35cae97ea2102962b75c0 |
Close
Hashes for gscdk-0.4.0-py3-none-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cd2e19ef7f656bd3eed362080b85ec1b48242afcaa26c75189a91cd526ac9d96 |
|
MD5 | dd9f1bf5d8568e6dd7dd93b8d03ed0ae |
|
BLAKE2b-256 | 63f99f542479502b4eedc308156d48f1d19eee5cab12b5e60c42cb124df588a7 |
Close
Hashes for gscdk-0.4.0-py3-none-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 72189199f4ddd1274b752b97cb97739effba0c3d96fb571dd1a890dd30bc4d3b |
|
MD5 | 7a8cc09a69fa5e78d71cb1871f107d8e |
|
BLAKE2b-256 | 10512f772cae4b04e7ce2c5c643c554bbe1e186493f91b4f8dd4516d7d8b8f28 |