Published 18 July 2019

Credits Rest Api CSharp Demo

https://github.com/CREDITSCOM/examples

https://github.com/CREDITSCOM/examples/tree/master/API/CreditsRestApiCSharpDemo

A simple demo of HTTP Rest API client is based on Credits Thrift API

Methods:

public WalletBalanceGetResult WalletGetBalance()

public TransactionFlowResult TransferCoins(int integral, long fraction, double fee)

public TransactionFlowResult DeploySmartContract(string smCode)

Controller

[Route("api/[controller]")]

[ApiController]

public class CreditsController : ControllerBase

{

   [HttpGet("{publicKey}")]

   public ActionResult<WalletBalanceGetResult> GetBalance(string publicKey)

   {

       using (var client = new Client("127.0.0.1", 9091, publicKey, "", ""))

       {

           return client.WalletGetBalance();

       }

   }

   [HttpGet("{integral}/{fraction}/{fee}/{publicKey}/{privateKey}/{targetKey}")]

   public ActionResult<TransactionFlowResult> TransferCoins(int integral, long fraction, double fee, string publicKey, string privateKey, string targetKey)

   {

       using (var client = new Client("127.0.0.1", 9091, publicKey, privateKey, targetKey))

       {

           return client.TransferCoins(integral, fraction, fee);

       }

   }

}

Votes 0, average rating 0

Contents