Skip to content
This repository has been archived by the owner on Jul 5, 2023. It is now read-only.

bnb-chain/csharp-sdk

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

69 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This repo is out of maintenance and decommissioned. BNB Chain DEX C# SDK

Source code is under MIT License (MIT)

C# SDK is inspired by BNB Chain DEX Java SDK, (used a lot in previous BNB Chain DEX "competition")

Project uses following NuGet packages:

  • NBitcoin
  • Google.Protobuf
  • RestSharp
  • Newtonsoft.Json
  • WebsocketRPC.Standalone

SDK supports:

Wallet

Create wallet with private key string value either for TEST_NET or PROD:

    Wallet wallet = Wallet.FromPrivateKey(
        "6d3cfc67595db1523915219718a31fa5b467d099a51035d8fb82ea9841496f09",
        BinanceDexEnvironment.TEST_NET);

HttpApi

HttpApi objects:

  • Times
  • Infos
  • Validator
  • Peer
  • Account
  • AccountSequence
  • Transaction
  • Token
  • Market
  • FeeData
  • MarketDepth
  • TransactionMetadata
  • KLines
  • OrderList
  • Order
  • TickerStatistics
  • TradePage
  • TxPage

Broadcast objects:

  • CancelOrder
  • MultiTransfer
  • NewOrder
  • TokenFreeze
  • TokenUnfreeze
  • Transfer
  • Vote

Example how to transfer founds:

    HttpApiClient httpApiClient = new HttpApiClient(BinanceDexEnvironment.TEST_NET);
    Wallet wallet = Wallet.FromPrivateKey(
        "6d3cfc67595db1523915219718a31fa5b467d099a51035d8fb82ea9841496f09",
        BinanceDexEnvironment.TEST_NET);

    Transfer transfer = new Transfer
    {
        Coin = "PND-943",
        FromAddress = wallet.Address,
        ToAddress = "tbnb18086qc9yxtk5ufddple8upf0k3072vvagpm2ml",
        Amount = "0.05"
    };

    TransactionRequest assmebler = new TransactionRequest(wallet, TransactionOption.DefaultInstace);
    string body = assmebler.BuildTransfer(transfer);
    List<TransactionMetadata> result = httpApiClient.Broadcast(body);

Web socket streams

Web socket stream objects:

  • OrdersData
  • AccountsData
  • TransfersData
  • TradesData
  • MarketDiff
  • MarketDepth
  • KLine
  • Ticker
  • AllTickersData
  • MiniTicker
  • AllMiniTickersData
  • Blockheight

Example how to listen web socket stream:

    public class Program
    {
        public static void Main(string[] args)
        {
            WebSocketClient client = new WebSocketClient();
            client.Env = BinanceDexEnvironment.TEST_NET;
            client.Topic = ETopic.Blockheight;
            client.StreamData += OnStreamData;
            client.Connect();

            Console.ReadLine();
        }

        private static void OnStreamData(object sender, IStreamData data)
        {
            Blockheight blockheight = (Blockheight)data;
            Console.WriteLine(blockheight.BlockHeight);
        }
    }

Node RPC

Node RPC endpoints and response objects:

  • AbciInfo: ResponseData
  • ConsensusState: ConsensusRoundStateData
  • DumpConsensusState: DumpRoundStateData
  • NetInfo: ResultNetInfo
  • Genesis: ResultGenesis
  • Health: ResultHealth
  • NumUnconfirmedTxs: ResultUnconfirmedTxs
  • Status: ResultStatus
  • AbciQuery: ResultAbciQuery
  • Block: ResultBlock
  • BlockByHash: ResultBlock
  • BlockResults: ResultBlockResults
  • Blockchain: ResultBlockchainInfo
  • Commit: ResultCommit
  • ConsensusParams: ResultConsensusParams
  • Tx: ResultTx
  • TxSearch: ResultTxSearch
  • UnconfirmedTxs: ResultUnconfirmedTxs
  • Validators: ResultValidators
  • BroadcastTxAsync: ResultBroadcastTx
  • BroadcastTxCommit: ResultBroadcastTxCommit
  • BroadcastTxSync: ResultBroadcastTx

Example how to communicate with Node RPC:

    NodeRpcClient nodeRpcClient = new NodeRpcClient("https://data-seed-pre-0-s1.binance.org");
    ResponseData responseData = nodeRpcClient.AbcInfo();

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%