Arduino IDE
Last updated
Last updated
This documentation portal is currently undergoing updates to align with the IoTeX 2.0 Whitepaper release. Information provided here may be incomplete, or out-of-date. Please use this portal for preliminary reference only, and check out the official IoTeX 2.0 Whitepaper for updated information.
.2024 | IoTeX
In Arduino IDE, go to Tools
->Manage libraries...
In the Library Manager dialog, search for IoTeX-blockchain-client
and click install
Using the Arduino IDE built-in Library Manager, also install the following libraries:
WiFiNINA : used for WiFi functionality in Nano 33 IoT
FlashStorage : used for EEPROM storage emulation in Nano 33 IoT
Go to Sketch->Include library and select IoTeX-blockchain-client.
Alternatively, paste the following code at the
beginning of your sketch:
#include "IoTeX-blockchain-client.h"
Create the Connection
object, passing the connection details:
Now you are ready to call any of the API methods.
You can find examples of most of the API methods under the examples directory.
Debug log level is set to NONE by default. The log level can be changed at runtime or at compile time.
Logs are printed to the Serial
serial port by default. You need to initialize the serial port in your sketch by calling Serial.begin(<baud rate>).
The log level can be set per module, and also globally. A log statement is printed if it's level is higher than the log level configured for it's module, and higher than the global log level.
The log level can be set at run time using the IotexHelpers
global object:
You can set the log level for a specific module. The existent log modules are:
"GENERAL"
"HTTP"
"CONTRACT"
Simply call the following method on the IotexHelpers
global object:
void setModuleLogLevel(const std::string& module, IotexLogLevel level)
Eg. This will set the HTTP log level to DEBUG
:
IotexHelpers.setModuleLogLevel("HTTP", IotexLogLevel::DEBUG);
You can also set the log level globally for all modules.
Simply call the following method on the IotexHelpers
global object:
void setGlobalLogLevel(IotexLogLevel level)
Eg. This will set the log level globally to DEBUG
:
IotexHelpers.setGlobalLogLevel(IotexLogLevel::DEBUG);