Go Smart Contract Development Kit
Project description
Go Smart Contracts Development Kit
What a Go Smart Contract looks 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.GetByKey(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 -o generated.go .
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.6.1.tar.gz
(66.6 MB
view hashes)
Built Distributions
Close
Hashes for gscdk-0.6.1-py3-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 215dc29f5b9d75f327c9dedb3718ffbeeef20f25ad40c56885277c74cde03952 |
|
MD5 | 7bf1614dbc44d1cdeacb1bf54ecae931 |
|
BLAKE2b-256 | 1d732593ea3c76220c6ad9c61aefaf9ef9ab8a2eb5b7888a155f7192be4af5e4 |
Close
Hashes for gscdk-0.6.1-py3-none-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8df75f057b61cfc9ab6ceb57d1dd12d35ea43d73b3a1ab50e5c6371b0012362e |
|
MD5 | 77ad370567fe5327bd0e37262efed011 |
|
BLAKE2b-256 | 5a866af744d90c9a03185e24fbd20251e154cccbef1d1d1f70025d3cc9ab053c |
Close
Hashes for gscdk-0.6.1-py3-none-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d970baa802af2715588ed5117fa7236a8b28cedb7ab39c2e323a5790a23abe97 |
|
MD5 | 59c09d45744dbd77f1bbb7e5a35194eb |
|
BLAKE2b-256 | 48009e46a98ce7e81da660d304770e7bfa3dc94b8a1b9986fe10f4e19aad7291 |