package
2.0.0-beta.4+incompatible
Repository: https://github.com/scrtlabs/secretnetwork.git
Documentation: pkg.go.dev

# README

Go-CosmWasm

This provides go bindings to the CosmWasm smart contract framework. In particular, it allows you to easily compile, initialize, and execute these contracts from Go.

As of the 0.7.0 release, we support CosmWasm 0.7.0 and any compatible smart contracts.

Structure

This repo contains both Rust and Go code. The rust code is compiled into a dll/so to be linked via cgo and wrapped with a pleasant Go API. The full build step involves compiling rust -> C library, and linking that library to the Go code. For ergonomics of the user, we will include pre-compiled libraries to easily link with, and Go developers should just be able to import this directly.

Supported Platforms

Since this package includes a rust prebuilt dll, you cannot just import the go code, but need to be on a system that works with an existing dll. Currently this is Linux (tested on Ubuntu, Debian, and CentOS7) and MacOS. We have a build system for Windows, but it is not supported by the wasmer singlepass backend which we rely upon for gas metering.

Note: CentOS support is currently disabled due to work on CD tooling. We require Linux with glibc 2.18+

Note: Windows is not supported currently

Note: We only currently support i686/amd64 architectures, although AMD support is an open issue

Design

Please read the Documentation to understand both the general Architecture, as well as the more detailed Specification of the parameters and entry points.

Development

There are two halfs to this code - go and rust. The first step is to ensure that there is a proper dll built for your platform. This should be api/libgo_cosmwasm.X, where X is:

  • so for Linux systems
  • dylib for MacOS
  • dll for Windows - Not currently supported due to upstream dependency

If this is present, then make test will run the Go test suite and you can import this code freely. If it is not present you will have to build it for your system, and ideally add it to this repo with a PR (on your fork). We will set up a proper CI system for building these binaries, but we are not there yet.

To build the rust side, try make build-rust and wait for it to compile. This depends on cargo being installed with rustc version 1.39+. Generally, you can just use rustup to install all this with no problems.

Toolchain

The Rust toolchain is pinned in the file rust-toolchain. It must be in sync with Dockerfile.cross and Dockerfile.centos7. When choosing a version, please use version with clippy, rustfmt and rls available to make Simon happy.

# Packages

No description provided by the author
No description provided by the author
No description provided by the author

# Functions

No description provided by the author
NewWasmer creates a new binding, with the given dataDir where it can store raw wasm and the pre-compile cache.

# Structs

This struct helps us to distinguish between v0.10 contract response and v1 contract response.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Wasmer is the main entry point to this library.

# Type aliases

CodeHash represents an ID for a given wasm code blob, must be generated from this library.
GasMeter is a read-only version of the sdk gas meter.
GoAPI is a reference to some "precompiles", go callbacks.
KVStore is a reference to some sub-kvstore that is valid for one instance of a code.
Querier lets us make read-only queries on other modules.
WasmCode is an alias for raw bytes of the wasm compiled code.