GithubHelp home page GithubHelp logo

cosmcs's Introduction

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.

cosmcs's People

Contributors

lxgr-linux avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

cosmcs's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.