Giter VIP home page Giter VIP logo

aelf-sdk.cs-1's Introduction

AElf-Client

Introduction

This is a C# client library, used to communicate with the AElf API.

Getting Started

You should build the "AElf.Client" project first to get files defined in protos, which will be generated in the directory named "Protobuf/Generated".

Basic usage

private const string BaseUrl = "Http://127.0.0.1:8100";

// get client instance
AElfClient aelfClient = new AElfClient(BaseUrl);
var height = await aelfClient.GetBlockHeightAsync();

Interface

Interface methods can be easily available by the instance "aelfClient" shown in basic usage. The following is a list of input parameters and output for each method. Check out the Web api reference for detailed Interface description.

IBlockAppService

 Task<long> GetBlockHeightAsync();

 Task<BlockDto> GetBlockByHashAsync(string blockHash, bool includeTransactions = false);

 Task<BlockDto> GetBlockByHeightAsync(long blockHeight, bool includeTransactions = false);

IChainAppService

 Task<ChainStatusDto> GetChainStatusAsync();

 Task<byte[]> GetContractFileDescriptorSetAsync(string address);

 Task<RoundDto> GetCurrentRoundInformationAsync();

 Task<List<TaskQueueInfoDto>> GetTaskQueueStatusAsync();

 Task<int> GetChainIdAsync();

INetAppService

 Task<bool> AddPeerAsync(string address);

 Task<bool> RemovePeerAsync(string address);

 Task<List<PeerDto>> GetPeersAsync(bool withMetrics);

 Task<NetworkInfoOutput> GetNetworkInfoAsync();

ITransactionAppService

Task<TransactionPoolStatusOutput> GetTransactionPoolStatusAsync();

Task<string> ExecuteTransactionAsync(ExecuteTransactionDto input);

Task<string> ExecuteRawTransactionAsync(ExecuteRawTransactionDto input);

Task<CreateRawTransactionOutput> CreateRawTransactionAsync(CreateRawTransactionInput input);

Task<SendRawTransactionOutput> SendRawTransactionAsync(SendRawTransactionInput input);

Task<SendTransactionOutput> SendTransactionAsync(SendTransactionInput input);

Task<string[]> SendTransactionsAsync(SendTransactionsInput input);

Task<TransactionResultDto> GetTransactionResultAsync(string transactionId);

Task<List<TransactionResultDto>> GetTransactionResultsAsync(string blockHash, int offset = 0,int limit = 10);

Task<MerklePathDto> GetMerklePathByTransactionIdAsync(string transactionId);

IClientService

 Task<bool> IsConnected();

 Task<string> GetFormattedAddress(Address address);

 Task<string> GetAddressFromPubKey(string pubKey);

 Task<string> GetGenesisContractAddressAsync();

 Task<Address> GetContractAddressByName(Hash contractNameHash);

Test

This module contains tests for all services provided by AElfClient. You can see how to properly use services provided by AElfClient here.

You need to firstly set necessary parameters to make sure tests can run successfully.

  1. Set baseUrl to your target url.

    private const string BaseUrl = "Http://127.0.0.1:8001";
  2. Give a valid privateKey of a node.

    private const string PrivateKey = "09da44778f8db2e602fb484334f37df19e221c84c4582ce5b7770ccfbc3ddbef";

Note

You need to run a local or remote AElf node to run the unit test successfully. If you're not familiar with how to run a node or multiple nodes, please see Running a node / Running multiple nodes for more information.

aelf-sdk.cs-1's People

Contributors

rosona avatar wudameinv avatar xiangxingxing avatar zhxymh 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.