Skip to content

Latest commit

 

History

History
56 lines (48 loc) · 1.93 KB

README.md

File metadata and controls

56 lines (48 loc) · 1.93 KB

Cosmcs

A C# client library for Cosmos SDK blockchains for netstandard2.1 with Unity support This is modeled after cosmrs

Build

git submodule sync
./gen_proto.sh
dotnet build

Usage

With EasyClient

Cosmcs.Client.EasyClient is an easy to use client object

var rpcUrl = "http://localhost:9090";
var chainId = "mychain1";
var prefix = "cosmos";
byte[] privateKey = new byte[32]
{
    176, 139, 111, 219, 136, 19, 183,
    176, 135, 218, 199, 231, 70, 249,
    129, 238, 212, 167, 207, 147, 217,
    51, 43, 217, 82, 136, 182, 245,
    189, 104, 186, 17
};  // Place byte privateKey here
var ec = new EasyClient(rpcUrl, chainId, privateKey, "cosmos");
// Using pregenerated routes
var authzTxClient = new Cosmos.Authz.V1beta1.MsgClient(ec);
// Using pregenerated queries
var authzQueryClient = new Cosmos.Authz.V1beta1.Query.QueryClient(ec.Channel);

Unity

Due to Unity's lack of support for HTTP/2.0 and the fact that gRPC exclusively utilizes HTTP/2.0, specific options must be provided when initializing EasyClient. This adjustment allows the internal gRPC channel to utilize gRPC-Web, which is compatible with HTTP/1.x. Cosmos blockchains start a grpc server on port 9090 and a grpc-web server on port 9091.

// ...
var rpcUrl = "http://localhost:9091";
var options = new EasyClientOptions{
    GrpcChannelOptions = new GrpcChannelOptions{
        HttpHandler = new GrpcWebHandler(GrpcWebMode.GrpcWeb, new HttpClientHandler())
    }
};
var ec = new EasyClient(rpcUrl, chainId, privateKey, "cosmos", options);
// ...

Examples

For a fully working example with codegeneration see CardchainCs.

License and Development

This is licensed under the GPL-v3 License, part of the DecentralCardgame project and developed by lxgr-linux.