This is a C# client library, used to communicate with the AElf API.
You should build the "AElf.Client" project first to get files defined in protos, which will be generated in the directory named "Protobuf/Generated".
private const string BaseUrl = "Http://127.0.0.1:8100";
// get client instance
AElfClient aelfClient = new AElfClient(BaseUrl);
var height = await aelfClient.GetBlockHeightAsync();
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.
Task<long> GetBlockHeightAsync();
Task<BlockDto> GetBlockByHashAsync(string blockHash, bool includeTransactions = false);
Task<BlockDto> GetBlockByHeightAsync(long blockHeight, bool includeTransactions = false);
Task<ChainStatusDto> GetChainStatusAsync();
Task<byte[]> GetContractFileDescriptorSetAsync(string address);
Task<RoundDto> GetCurrentRoundInformationAsync();
Task<List<TaskQueueInfoDto>> GetTaskQueueStatusAsync();
Task<int> GetChainIdAsync();
Task<bool> AddPeerAsync(string address);
Task<bool> RemovePeerAsync(string address);
Task<List<PeerDto>> GetPeersAsync(bool withMetrics);
Task<NetworkInfoOutput> GetNetworkInfoAsync();
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);
Task<bool> IsConnected();
Task<string> GetFormattedAddress(Address address);
Task<string> GetAddressFromPubKey(string pubKey);
Task<string> GetGenesisContractAddressAsync();
Task<Address> GetContractAddressByName(Hash contractNameHash);
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.
-
Set baseUrl to your target url.
private const string BaseUrl = "Http://127.0.0.1:8001";
-
Give a valid privateKey of a node.
private const string PrivateKey = "09da44778f8db2e602fb484334f37df19e221c84c4582ce5b7770ccfbc3ddbef";
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.