@@ -11,21 +11,22 @@ This package is still under development. This page will get more content as it e
11
11
[[ toc]]
12
12
13
13
## Platforms
14
- * [ Arduino] ( #Arduino )
15
- * [ Linux >= 16.04] ( #OS )
16
- * [ macOS >= 10.10] ( #OS )
17
- * [ Windows >= 7] ( #OS )
14
+
15
+ - [ Arduino] ( #Arduino )
16
+ - [ Linux >= 16.04] ( #OS )
17
+ - [ macOS >= 10.10] ( #OS )
18
+ - [ Windows >= 7] ( #OS )
18
19
19
20
## Usage
20
21
21
- The Cpp Client is meant to be used for creating request to an API endpoint.
22
- For cryptography related functionality, such as generating addresses or creating transactions,
22
+ The Cpp Client is meant to be used for creating request to an API endpoint.
23
+ For cryptography related functionality, such as generating addresses or creating transactions,
23
24
please see the [ Cpp Crypto] ( https://github.com/ArkEcosystem/cpp-crypto ) repository.
24
25
25
26
### Connection
26
27
27
- Before making a request, you should create a ` Connection ` .
28
- A ` Connection ` expects a ` host ` , which is an url on which the API can be reached.
28
+ Before making a request, you should create a ` Connection ` .
29
+ A ` Connection ` expects a ` host ` , which is an url on which the API can be reached.
29
30
An example ` Connection ` , that interfaces with the API of an Ark Node, would be created as follows:
30
31
31
32
``` cpp
@@ -38,10 +39,9 @@ Ark::Client::Connection<Ark::Client::Api> connection("167.114.29.54", 4003);
38
39
The below example shows how you can perform a request.
39
40
40
41
```cpp
41
- // Check the API Version
42
- auto apiVersion = connection.api.version();
43
-
44
42
// Perform an API call using the connection to access endpoint
43
+ const auto blockchainResponse = connection.api.blockchain.get();
44
+
45
45
const auto blockResponse = connection.api.blocks.get("13114381566690093367")
46
46
47
47
const auto delegateResponse = connection.api.delegates.get("boldninja");
@@ -56,19 +56,23 @@ const auto vote = connection.api.votes.get("d202acbfa947acac53ada2ac8a0eb662c9f7
56
56
57
57
const auto walletsSearch = connection.api.wallets.search({"username", "baldninja"});
58
58
```
59
- > * note: All API response are of the type ` std::string `
60
59
61
- #
60
+ > \* note: All API response are of the type ` std::string `
61
+
62
+ #
62
63
63
64
### Getting an API Path
64
65
65
- There are instances when a client may use a gateway or bridge to do http get/post;
66
- for this we have provided an interface for obtaining a properly formatted API Path for a given API Endpoint.
66
+ There are instances when a client may use a gateway or bridge to do http get/post;
67
+ for this we have provided an interface for obtaining a properly formatted API Path for a given API Endpoint.
67
68
Below are examples of how to access the Path interface:
68
69
69
70
``` cpp
70
71
Ark::Client::Host dummyHost ("0.0.0.0:4003");
71
72
73
+ std::string blockchainGetPath = Ark::Client::API::Paths::Blockschain::get(dummyHost);
74
+ // blockchainGetPath will be the string "0.0.0.0:4003/api/blockchain"
75
+
72
76
std::string blocksAllPath = Ark::Client::API::Paths::Blocks::all(dummyHost, 5 /* limit * /, 1 /* page * /);
73
77
// blocksAllPath will be the string "0.0.0.0:4003/api/v2/blocks?limit=5&page=1"
74
78
@@ -100,14 +104,15 @@ std::pair<std::string, std::string> walletsSearchPath = Ark::Client::API::Paths:
100
104
```
101
105
102
106
# Arduino
103
- **Arduino IDE:**
104
- Download and install the Arduino IDE (>=1.8.5) from the following link:
105
- ```https://www.arduino.cc/en/Main/Software```
106
107
107
- Using the Arduino IDE's built in Library Manager,
108
- install the following Libraries:
109
- ```ArduinoJson v6.10.1```
110
- ```AUnit```
108
+ **Arduino IDE:**
109
+ Download and install the Arduino IDE (>=1.8.5) from the following link:
110
+ `https://www.arduino.cc/en/Main/Software`
111
+
112
+ Using the Arduino IDE's built in Library Manager,
113
+ install the following Libraries:
114
+ `ArduinoJson v6.10.1`
115
+ `AUnit`
111
116
112
117
#### Arduino Example using the Adafruit Feather ESP8266
113
118
@@ -129,15 +134,17 @@ void setup() {
129
134
130
135
Ark::Client::Connection<Ark::Client::Api> connection("167.114.29.54", 4003);
131
136
137
+ Serial.println(arkClient.blockchain.get().c_str());
138
+
132
139
auto allBlocks = arkClient.blocks.all();
133
140
Serial.println(allBlocks.c_str());
134
141
135
142
auto allDelegates = arkClient.delegates.all();
136
143
Serial.println(allDelegates.c_str());
137
-
144
+
138
145
auto delegatesCount = arkClient.delegates.count();
139
146
Serial.println(delegatesCount.c_str());
140
-
147
+
141
148
auto allPeers = arkClient.peers.all();
142
149
Serial.println(allPeers.c_str());
143
150
@@ -148,15 +155,17 @@ void setup() {
148
155
void loop() {}
149
156
```
150
157
151
- ** PlatformIO IDE:**
158
+ ** PlatformIO IDE:**
159
+
160
+ #### Python:
152
161
153
- #### Python:
154
- Use an installer package from the following link or use your preferred method to install Python:
155
- ``` https://www.python.org/downloads/ ```
162
+ Use an installer package from the following link or use your preferred method to install Python:
163
+ ` https://www.python.org/downloads/ `
156
164
157
165
Install PlatformIO:
158
166
159
167
pip install -U platformio
168
+
160
169
or
161
170
162
171
python -c "$(curl -fsSL https://raw.githubusercontent.com/platformio/platformio/develop/scripts/get-platformio.py)"
@@ -165,49 +174,54 @@ Install ArduinoJson@6.10.1 AUnit (2778)
165
174
166
175
platformio lib -g install 64@6.10.1 2778
167
176
168
- #### Provide your WiFi info for your board to access the internet
177
+ #### Provide your WiFi info for your board to access the internet
178
+
179
+ Open the following file in your preferred code editor:
169
180
170
- Open the following file in your preferred code editor:
171
- > "* .../cpp-client/test/IoT/test_main.cpp* "
181
+ > "_ .../cpp-client/test/IoT/test_main.cpp_ "
182
+
183
+ lines 19 & 20:
172
184
173
- lines 19 & 20:
174
185
```
175
186
char ssid[] = "your_ssid"; // your network SSID (name)
176
187
const char password[] = "your_password"; // your network password
177
188
```
178
189
179
190
#### running the tests on an Arduino board
180
191
181
- cd Cpp-Client
192
+ cd Cpp-Client
182
193
cd test
183
194
184
- #### execute the following command to upload test to your board
195
+ #### execute the following command to upload test to your board
185
196
186
- > | board | command |
187
- > | :-- | : -- |
188
- > | ESP8266 | ``` pio run -e esp8266 -t upload `` ` |
189
- > | ESP32 | ``` pio run -e esp32 -t upload ``` |
197
+ > | board | command |
198
+ > | :------ | :--------------------------- -- |
199
+ > | ESP8266 | ` pio run -e esp8266 -t upload ` |
200
+ > | ESP32 | ` pio run -e esp32 -t upload ` |
190
201
191
202
#
192
203
193
204
# OS
205
+
194
206
## Linux, macOS and Windows
195
207
196
- ** CMake:**
208
+ ** CMake:**
197
209
198
- Use an installer package from the following link, Homebrew, or use your preferred method:
199
- ``` https://www.cmake.org/download/ `` `
210
+ Use an installer package from the following link, Homebrew, or use your preferred method:
211
+ ` https://www.cmake.org/download/ `
200
212
201
213
using
202
- ** Homebrew:**
214
+ ** Homebrew:**
203
215
204
216
brew install cmake
205
217
206
218
> note: all other dependencies will be automatically installed via git submodule and CMake.
207
219
208
220
### make and build
209
- cd cpp-client/
221
+
222
+ cd cpp-client/
210
223
cmake . && cmake --build .
211
224
212
225
### run tests
226
+
213
227
./bin/Ark-Cpp-Client-tests
0 commit comments