Skip to content

terentev-space/SugarchainApiClient

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SugarchainApiClient

Latest Version Software License NuGet downloads Size

🚧 Attention: the project is currently under development! 🚧


Sugarchain project website: https://sugarchain.org/
Sugarchain API: https://api.sugarchain.org/

Install

PM

Install-Package SugarchainApiClient

.NET CLI

dotnet add package SugarchainApiClient

NuGet

SugarchainApiClient

Usage

Interface ISugarchainClient

ISugarchainClient client = new SugarchainClient();

/* Operation is Abstract */
var operation = client.UseOperation<Operation>();

var @params = GetParams();

/* MethodAsync & Method is nonexistent (example) */
var resultAsync = await operation.MethodAsync(@params);
/* OR */
var result = operation.Method(@params);

SugarchainClient ApiService

SugarchainClient client = new SugarchainClient();

var @params = GetParams();

/* MethodAsync & Method is nonexistent (example) */
var resultAsync = await client.Api.MethodAsync(@params);
/* OR */
var result = client.Api.Method(@params);

Api & Operations & Methods


/info - ...<InfoOperation>().Get(); /* or GetAsync */
/height/{height}
/block/{hash}
/header/{hash}
/range/{height}
/balance/{address} - ...<BalanceOperation>().Get(address); /* or GetAsync */
/mempool/{address}
/unspent/{address} - ...<UnspentOperation>().Get(address, amount); /* or GetAsync */
/history/{address}
/transaction/{hash}
/mempool
/supply - ...<SupplyOperation>().Get(); /* or GetAsync */
/fee - ...<FeeOperation>().Get(); /* or GetAsync */
/decode/{raw}
/broadcast - ...<BroadcastOperation>().Send(raw); /* or SendAsync */

Examples

SugarchainClient client = new SugarchainClient();

🔹 Info

This method return current info about Sugarchain network.

  • Info UseOperation
Response<InfoResult> result = client.UseOperation<InfoOperation>().Get();
  • Info UseOperation Async
Response<InfoResult> result = await client.UseOperation<InfoOperation>().GetAsync();
  • Info Api
Response<InfoResult> result = client.Api.Info();
  • Info Api Async
Response<InfoResult> result = await client.Api.InfoAsync();

🔹 Balance

This method return address balance.

  • Data
string address = "sugar1qmqvkrn5zw2v60tl0syfmxwrkre4kagpak0t9s5";
  • Balance UseOperation
Response<BalanceResult> result = client.UseOperation<BalanceOperation>().Get(address);
  • Balance UseOperation Async
Response<BalanceResult> result = await client.UseOperation<BalanceOperation>().GetAsync(address);
  • Balance Api
Response<BalanceResult> result = client.Api.Balance(address);
  • Balance Api Async
Response<BalanceResult> result = await client.Api.BalanceAsync(address);

🔹 Unspent

This method return address unspent outputs.

  • Data
string address = "sugar1qmqvkrn5zw2v60tl0syfmxwrkre4kagpak0t9s5";
int amount = 0;
  • Unspent UseOperation
Response<UnspentResult> result = client.UseOperation<UnspentOperation>().Get(address, amount);
  • Unspent UseOperation Async
Response<UnspentResult> result = await client.UseOperation<UnspentOperation>().GetAsync(address, amount);
  • Unspent Api
Response<UnspentResult> result = client.Api.Unspent(address, amount);
  • Unspent Api Async
Response<UnspentResult> result = await client.Api.UnspentAsync(address, amount);

🔹 Supply

This method return info about current coins supply.

  • Supply UseOperation
Response<SupplyResult> result = client.UseOperation<SupplyOperation>().Get();
  • Supply UseOperation Async
Response<SupplyResult> result = await client.UseOperation<SupplyOperation>().GetAsync();
  • Supply Api
Response<SupplyResult> result = client.Api.Supply();
  • Supply Api Async
Response<SupplyResult> result = await client.Api.SupplyAsync();

🔹 Fee

This method return recommended transaction fee.

  • Fee UseOperation
Response<FeeResult> result = client.UseOperation<FeeOperation>().Get();
  • Fee UseOperation Async
Response<FeeResult> result = await client.UseOperation<FeeOperation>().GetAsync();
  • Fee Api
Response<FeeResult> result = client.Api.Fee();
  • Fee Api Async
Response<FeeResult> result = await client.Api.FeeAsync();

🔹 Broadcast

This method broadcast raw signed transaction to Sugarchain network.

  • Data
string raw = "020000000001021786bf75007d1d94b4ce3b94e885690c1dfb9299bcd97e92f7f1b0a80526f6000100000000ffffffff5adfd951b1c065a46dddb0bd0df8b652165e492cb6e5857048ddea365261d0840100000000ffffffff0200e1f50500000000160014d81961ce827299a7afef8113b338761e6b6ea03d605af405000000001600145af91e8c58fccd17682b1bc41a5df595181dc4b402483045022100bcc87972c6389c6b610bb5089a549bea2f92c67f01a3c7516223e3731f155c8b022038fa950f872310b2a576206cd0ce2980592a714ca571a4427774af7f2b68035e012102f415fdf94b01db2fa79792c849d862d4b708ca1770ebdeba004ad4f218c8565b0247304402204e9eee008c4fdd9205a3af9eb47c3c393d0ed35f29be8d670ac48edd468647890220583053b7e77e22e631a29360bca44339c5dc6f1aefd0069008097e9a564b8a0f012102f415fdf94b01db2fa79792c849d862d4b708ca1770ebdeba004ad4f218c8565b00000000";
  • Broadcast UseOperation
Response<string> result = client.UseOperation<BroadcastOperation>().Send(raw);
  • Broadcast UseOperation Async
Response<string> result = await client.UseOperation<BroadcastOperation>().SendAsync(raw);
  • Broadcast Api
Response<string> result = client.Api.Broadcast(raw);
  • Broadcast Api Async
Response<string> result = await client.Api.BroadcastAsync(raw);

Credits

License

The Apache 2.0 License (Apache-2.0). Please see License File for more information.

About

Software Development Kit for working with the Sugarchain API

Topics

Resources

License

Stars

Watchers

Forks

Languages