Giter Site home page Giter Site logo

xippix1 / netezos Goto Github PK

View Code? Open in Web Editor NEW

This project forked from baking-bad/netezos

0.0 0.0 0.0 2.01 MB

Netezos is a cross-platform Tezos SDK for .NET developers, simplifying the access and interaction with the Tezos blockchain

Home Page: https://netezos.dev

License: MIT License

C# 99.98% Makefile 0.02%

netezos's Introduction

Netezos

License: MIT

The first version of the library has been moved to the v1 branch for historical purposes.

Netezos is a cross-platform Tezos SDK for .NET developers, simplifying the access and interaction with the Tezos blockchain.

The following features have been implemented so far:

Namespace Description Status
Netezos.Contracts Interaction with Tezos smart contracts Ready to use. Dynamic wrapper: in progress...
Netezos.Forge Forging (encoding) operation bytes Ready to use
Netezos.Keys Working with keys, signing, verifying signature, etc. Ready to use. HD keys: in progress...
Netezos.Ledger Interaction with Tezos Ledger App Ready to use (separate package)
Netezos.Rpc Tezos RPC wrapper Ready to use

For full documentation and API Reference, please refer to the Netezos website

Contribution

Netezos is an open development project so any contribution is highly appreciated, starting from documentation improvements, writing examples of usage, etc. and ending with adding new features (as long as these features do not break existing API or are only intended for one person and for very specific use case).

Do not hesitate to use GitHub issue tracker to report bugs or request features.

Support

Feel free to join our Discord: https://discord.gg/aG8XKuwsQd, Telegram chat: https://t.me/baking_bad_chat, or find us in Slack: https://tezos-dev.slack.com #baking-bad. We will be glad to hear any feedback and feature requests and will try to help you with general use cases of the Netezos library.

Getting started

Let's consider the most common use case - sending a transaction.

Installation

PM> Install-Package Netezos

Create private key

// generate new key
var key = new Key();

// or use existing one
var key = Key.FromBase58("edsk4ZkGeBwDyFVjZLL2neV5FUeWNN4NJntFNWmWyEBNbRwa2u3jh1");

// use this address to receive some tez
var address = key.PubKey.Address; // tz1SauKgPRsTSuQRWzJA262QR8cKdw1d9pyK

Get some data from RPC

using var rpc = new TezosRpc("https://mainnet-tezos.giganode.io/");

// get a head block
var head = await rpc.Blocks.Head.Hash.GetAsync<string>();

// get account's counter
var counter = await rpc.Blocks.Head.Context.Contracts[address].Counter.GetAsync<int>();

Forge an operation

Since our address has just been created, we need to reveal its public key before sending any operation, so that everyone can validate our signatures. Therefore, we need to send actually two operations: a reveal and then a transaction.

Netezos allows you to pack multiple operations into a group and forge/send it as a single batch.

var content = new ManagerOperationContent[]
{
    new RevealContent
    {
        Source = address,
        Counter = ++counter,
        PublicKey = key.PubKey.GetBase58(),
        GasLimit = 1500,
        Fee = 1000 // 0.001 tez
    },
    new TransactionContent
    {
        Source = address,
        Counter = ++counter,
        Amount = 1000000, // 1 tez
        Destination = "tz1KhnTgwoRRALBX6vRHRnydDGSBFsWtcJxc",
        GasLimit = 1500,
        Fee = 1000 // 0.001 tez
    }
};

var bytes = await new LocalForge().ForgeOperationGroupAsync(head, content);

Sign and send

// sign the operation bytes
byte[] signature = key.SignOperation(bytes);

// inject the operation and get its id (operation hash)
var result = await rpc.Inject.Operation.PostAsync(bytes.Concat(signature));

That is it. We have successfully injected our first operation into the Tezos blockchain.

Useful links

netezos's People

Contributors

groxan avatar dmirgaleev avatar m-kus avatar mscappini avatar alex-cpppydeveloper avatar

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.