https://github.com/aelfproject/aelf-sdk.cs
AElf dotnet SDK
https://github.com/aelfproject/aelf-sdk.cs
Last synced: 8 months ago
JSON representation
AElf dotnet SDK
- Host: GitHub
- URL: https://github.com/aelfproject/aelf-sdk.cs
- Owner: AElfProject
- Created: 2019-11-29T04:15:54.000Z (over 6 years ago)
- Default Branch: dev
- Last Pushed: 2024-09-18T02:17:04.000Z (over 1 year ago)
- Last Synced: 2024-09-18T05:56:09.785Z (over 1 year ago)
- Language: C#
- Homepage:
- Size: 353 KB
- Stars: 1
- Watchers: 9
- Forks: 10
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# AElf-Client
## Introduction
This is a C# client library, used to communicate with the [AElf](https://github.com/AElfProject/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
``` c#
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](https://docs.aelf.io/v/dev/reference) for detailed Interface description.
#### IBlockAppService
```c#
Task GetBlockHeightAsync();
Task GetBlockByHashAsync(string blockHash, bool includeTransactions = false);
Task GetBlockByHeightAsync(long blockHeight, bool includeTransactions = false);
```
#### IChainAppService
```c#
Task GetChainStatusAsync();
Task GetContractFileDescriptorSetAsync(string address);
Task GetCurrentRoundInformationAsync();
Task> GetTaskQueueStatusAsync();
Task GetChainIdAsync();
```
#### INetAppService
```c#
Task AddPeerAsync(string address);
Task RemovePeerAsync(string address);
Task> GetPeersAsync(bool withMetrics);
Task GetNetworkInfoAsync();
```
#### ITransactionAppService
```c#
Task GetTransactionPoolStatusAsync();
Task ExecuteTransactionAsync(ExecuteTransactionDto input);
Task ExecuteRawTransactionAsync(ExecuteRawTransactionDto input);
Task CreateRawTransactionAsync(CreateRawTransactionInput input);
Task SendRawTransactionAsync(SendRawTransactionInput input);
Task SendTransactionAsync(SendTransactionInput input);
Task SendTransactionsAsync(SendTransactionsInput input);
Task GetTransactionResultAsync(string transactionId);
Task> GetTransactionResultsAsync(string blockHash, int offset = 0,int limit = 10);
Task GetMerklePathByTransactionIdAsync(string transactionId);
```
#### IClientService
```c#
Task IsConnected();
Task GetFormattedAddress(Address address);
Task GetAddressFromPubKey(string pubKey);
Task GetGenesisContractAddressAsync();
Task
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.
```c#
private const string BaseUrl = "Http://127.0.0.1:8001";
```
2. Give a valid privateKey of a node.
```c#
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](https://docs.aelf.io/v/dev/main/main/run-node) / [Running multiple nodes](https://docs.aelf.io/v/dev/main/main/multi-nodes) for more information.