Giter VIP home page Giter VIP logo

vottunerc20api.net's Introduction

VottunERC20API.NET

This SDK for .NET 8 implements Vottun ERC20 API, and allows querying all API methods within a .NET 8 application. It provides wrapped classes for of all json requests and responses, as provided in Vottun ERC20 API(https://docs.vottun.io/api/erc20)

Implemented API methods:

Ready as a nugget package published in nuget.org, just search for VottunERC20API.NET.1.0.5.

Using VottunERC20API.NET SDK is very easy:

  1. In your project or solution, add reference to package VottunERC20API.NET available in nuget.org package repository:

image

  1. Declare your API and AUTH keys:

image

  1. Create a client using the provided factory in VottunApiClientFactory, passing your API keys.

image

  1. Build your request objetc, call the available API methods and get the response, that's all!

Example of use:

using VottumERC20API.NET;

//set your api and authorization key
var apiKey = "<your api key>";
var authorizationKey = "<your auth key>";

//instance a client by calling the provided factory
var client = VottunApiClientFactory.Create( apiKey, authorizationKey);


//examples of SDK usage
//1. Allowance
var allowanceRequest = new AllowanceRequest
{
    contractAddress = "0xBe0CD9c4C636373eB1c5e1d581b1269E9E40c517",
    network = 80001,
    owner = "0x7590a8ff8a4b8e2831db16a02f03c7acd65aca26",
    spender = "0x7590a8fF8A4B8E2831dB16A02f03c7AcD65aca26"
};
var allowance = await client.AllowanceAsync(  allowanceRequest , CancellationToken.None);

Console.WriteLine($"Allowance: {allowance.allowance}");

//2. Name
var nameRequest = new NameRequest
{
   contractAddress= "0xBe0CD9c4C636373eB1c5e1d581b1269E9E40c517",
   network=80001
};
var name = await client.NameAsync(nameRequest, CancellationToken.None);

Console.WriteLine($"Name: {name.name}");

//3. Symbol

var SymbolRequest = new SymbolRequest
{
    contractAddress = "0xBe0CD9c4C636373eB1c5e1d581b1269E9E40c517",
    network = 80001
};

var symbolResponse = await client.SymbolAsync(SymbolRequest, CancellationToken.None);
Console.WriteLine($"Symbol: {symbolResponse.symbol}");


//4. TotalSupply

var totalSupplyRequest = new TotalSupplyRequest
{
    contractAddress = "0xBe0CD9c4C636373eB1c5e1d581b1269E9E40c517",
    network = 80001
};

var totalSupplyResponse = await client.TotalSupplyAsync(totalSupplyRequest, CancellationToken.None);
Console.WriteLine($"TotalSupply: {totalSupplyResponse.totalSupply}");

//5. Decimals

var decimalsRequest = new DecimalsRequest
{
    contractAddress = "0xBe0CD9c4C636373eB1c5e1d581b1269E9E40c517",
    network = 80001
};

var decimalsResponse = await client.DecimalsAsync(decimalsRequest, CancellationToken.None);
Console.WriteLine($"Decimals: {decimalsResponse.decimals}");

//6. BalanceOf

var balanceOfRequest = new BalanceOfRequest
{
    contractAddress = "0xBe0CD9c4C636373eB1c5e1d581b1269E9E40c517",
    network = 80001,
    address = "0x7590a8ff8a4b8e2831db16a02f03c7acd65aca26"
};

var balanceOfResponse = await client.BalanceOfAsync(balanceOfRequest, CancellationToken.None);
Console.WriteLine($"BalanceOf: {balanceOfResponse.balance}");

//7. Deploy
var deployRequest = new DeployRequest
{
    name = "VottunToken",
    symbol = "VOT",
    alias  = "Vottun token ERC20 test",
    initialSupply = 21000000,
    network = 80001
};

var deployResponse = await client.DeployAsync(deployRequest, CancellationToken.None);
Console.WriteLine($"Deployed ContractAddress: {deployResponse.contractAddress}");


//8. Transfer
var transferRequest = new TransferRequest
{
    contractAddress = "0x5FbE0944D3d2df2C7D2B55c0ED2C9085bcD8971A",
    recipient = "0x7590a8ff8a4b8e2831db16a02f03c7acd65aca26",
    amount = 100,
    network = 80001
};

var transferResponse = await client.TransferAsync(transferRequest, CancellationToken.None);
Console.WriteLine($"Transfer TxnHash: {transferResponse.txHash}");


//9. TransferFrom
var transferFromRequest = new TransferFromRequest
{
    contractAddress = "0x5FbE0944D3d2df2C7D2B55c0ED2C9085bcD8971A",
    sender = "0x7590a8ff8a4b8e2831db16a02f03c7acd65aca26",
    recipient = "0x5770bf37D6617eec99744DD6Ee03a3DA12b681eE",
    amount = 100,
    network = 80001
};

var transferFromResponse = await client.TransferFromAsync(transferFromRequest, CancellationToken.None);
Console.WriteLine($"TransferFrom TxnHash: {transferFromResponse.txHash}");

//10. IncreaseAllowance
var increaseAllowanceRequest = new IncreaseAllowanceRequest
{
    contractAddress = "0x5FbE0944D3d2df2C7D2B55c0ED2C9085bcD8971A",
    spender = "0x5770bf37D6617eec99744DD6Ee03a3DA12b681eE",
    addedValue = 100,
    network = 80001
};

var increaseAllowanceResponse = await client.IncreaseAllowanceAsync(increaseAllowanceRequest, CancellationToken.None);
Console.WriteLine($"IncreaseAllowance TxnHash: {increaseAllowanceResponse.txHash}");


//11. DecreaseAllowance

var decreaseAllowanceRequest = new DecreaseAllowanceRequest
{
    contractAddress = "0x5FbE0944D3d2df2C7D2B55c0ED2C9085bcD8971A",
    spender = "0x5770bf37D6617eec99744DD6Ee03a3DA12b681eE",
    substractedValue = 100,
    network = 80001
};

var decreaseAllowanceResponse = await client.DecreaseAllowanceAsync(decreaseAllowanceRequest, CancellationToken.None);
Console.WriteLine($"DecreaseAllowance TxnHash: {decreaseAllowanceResponse.txHash}");

version changelog

  • 1.0.0:
    • first version
  • 1.0.5:
    • changed initialSupply attribute from string to int type and other minor changes

TO DO list

  • Extend to other vottun APIS
  • Include more examples

vottunerc20api.net's People

Contributors

jzafrap avatar

Stargazers

Vottun SL avatar Alex Lopez avatar

Watchers

 avatar

Forkers

vottunio

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.