Skip to main content

Go Smart Contracts Development Kit (GSCDK)

PyPi Version PyPi Downloads

Overview

The Go Smart Contracts Development Kit (GSCDK) provides a comprehensive toolkit for creating, building, and debugging Go-based smart contracts.

Example of a Go Smart Contract

Here is an example of what a Go Smart Contract looks like using GSCDK:

package main

import (
	"github.com/uuosio/chain"
)

//table mytable
type MyData struct {
	primary uint64 //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
	payer := c.Receiver
	mydb := NewMyDataDB(code)
	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)
	}
}

Quick Start

Jump right into building your first smart contract with our Quick Start Guide.

Installation

To install GSCDK, run the following command:

For Unix-based platforms (like Linux or macOS):

python3 -m pip install gscdk

For Windows:

python -m pip install gscdk

Upgrading GSCDK

If you've previously installed GSCDK and want to upgrade to the latest version, use the following command:

For Unix-based platforms:

python3 -m pip install --upgrade gscdk

For Windows:

python -m pip install --upgrade gscdk

Building Go Smart Contracts Compiler

To build the tinygo command that supports building Go Smart Contracts, follow the instructions in Building. Once built, add the tinygo command to your PATH:

export PATH=$(pwd)/compiler/build:$PATH

Using go-contract

go-contract is a powerful tool for managing your smart contract projects. Learn more about its features below:

Initializing a Project

Use the "init" command to initialize a project with a specific contract name:

go-contract init mycontract
cd mycontract

Generating ABI and Extra Code

Use the "gencode" command to generate ABI and extra code for smart contracts:

go-contract gencode

Note: Code generation is also the default option for the "build" command.

Building Your Project

To compile the source code of your project, use the "build" command:

go-contract build

To disable code generation during the build process, use the -gen-code=false flag:

go-contract build -gen-code=false

To disable code optimization, use the -d or --debug option:

go-contract build -d

Debugging

Before debugging, install ipyeos:

python3 -m pip install ipyeos

To update to a new version, use the following command:

python3 -m pip install -U ipyeos

Then run the debugging server:

eosdebugger

On Windows, use a Docker image to run a debugging server.

First, pull ipyeos docker image:

docker pull ghcr.io/uuosio/ipyeos:latest

then start a debugging server from docker:

docker run -it --rm -p 9090:9090 -p 9092:9092 -t ghcr.io/uuosio/ipyeos

Here's a sneak peek of the debugger in action:

Debugging

Code Coverage Analysis

To generate a code coverage report in HTML, follow these steps:

  1. Build your project:
go-contract build
  1. Generate a coverage report:
TEST_COVERAGE=1 go test -coverprofile=coverage.out
  1. Create an HTML report from the coverage data:
go tool cover -html=coverage.out

Here's an example of what the code coverage report looks like:

Code Coverage

Metadata

Release files for gscdk 0.7.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gscdk 0.7.10
File Size Uploaded Provenance
gscdk-0.7.10.tar.gz 77.8 MB Without provenance Details

Built distributions (wheels)

Table of built distributions (wheels) for gscdk 0.7.10
File Interpreter ABI Platform
gscdk-0.7.10-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details
gscdk-0.7.10-py3-none-manylinux1_x86_64.whl Python 3 none Linux glibc 2.5+ x86-64 Details
gscdk-0.7.10-py3-none-macosx_10_15_x86_64.whl Python 3 none macOS 10.15+ x86-64 Details

Total release size: 299.5 MB

Release files / gscdk-0.7.10.tar.gz

Download URL gscdk-0.7.10.tar.gz
Size 77.8 MB
Tags Source
SHA-256 checksum
How to use checksums
66a1bb47c370bf1fa9175b0f906b0cac0d50c5da7ab347ab1cb1a6ab26a0df70
BLAKE2b-256 checksum
How to use checksums
7f6df5ae0884e70d2ae70149585213d9e8bd0785666618a0e5cf91f0ff085603
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.3

Release files / gscdk-0.7.10-py3-none-win_amd64.whl

Download URL gscdk-0.7.10-py3-none-win_amd64.whl
Size 72.4 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
67e2c3e149edb551d58f7a232f8553d6084c222919ebd62ef307aba1a7c7740e
BLAKE2b-256 checksum
How to use checksums
3b9b3709af908a2f8790bc3c933145cee6b57d5ed9732c719a4fcd24c239f6a9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.3

Release files / gscdk-0.7.10-py3-none-manylinux1_x86_64.whl

Download URL gscdk-0.7.10-py3-none-manylinux1_x86_64.whl
Size 83.2 MB
Tags Linux glibc 2.5+ x86-64 Python 3
SHA-256 checksum
How to use checksums
1722cd5eccd1d8b6e7fce879bbdca59c05ab1504bfb5128a59cbf72e17eea29b
BLAKE2b-256 checksum
How to use checksums
c7730dc2450c31fd1b3eec647c9d781cffab5582492924fcc734ab8e5d54313b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.3

Release files / gscdk-0.7.10-py3-none-macosx_10_15_x86_64.whl

Download URL gscdk-0.7.10-py3-none-macosx_10_15_x86_64.whl
Size 66.0 MB
Tags Python 3 macOS 10.15+ x86-64
SHA-256 checksum
How to use checksums
7866803b5149069c10272d708f2a242721acf86bdc3e5867e315be70cecf7d49
BLAKE2b-256 checksum
How to use checksums
073ce8dcd36db851c5978985aa5e39371f89ceb949d7017357d618228c4ebc00
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.3

Security for gscdk 0.7.10

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.7.10 This release

4 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page