Getting Started
Infratic is a lightweight C++ blockchain transaction library designed for microcontrollers, specifically ESP32, to interact directly with the Solana blockchain and Anchor framework smart contracts.
⨠Featuresā
- šŖ Send SOL or SPL token transactions from your microcontroller.
- š§ Build and sign Anchor-compatible instructions to interact with smart contracts.
- š Perform Ed25519 signing using pure C/C++ with no external tools required.
- š” Full compatibility with the Solana JSON RPC API.
- š§© Includes essential utilities like base58 encoding/decoding and memo program support.
- š”ļø Generate and verify basic Zero-Knowledge Proofs (Commitments, Merkle Proofs, Range Proofs) to enhance data privacy.
āļø PlatformIO Setupā
To use the Infratic library in your project, add the following configuration to your platformio.ini file. This setup includes the Infratic library itself and its required dependencies.
[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
monitor_speed = 115200
lib_deps =
; Infratic Library
[email protected]
; Required Dependencies
ArduinoJson@^6.21.5
[https://github.com/rweather/arduinolibs.git](https://github.com/rweather/arduinolibs.git)
[https://github.com/kmackay/micro-ecc.git](https://github.com/kmackay/micro-ecc.git)
lib_extra_dirs = lib
build_flags =
-std=gnu++17
-w
; Disable Bluetooth to save memory
-UCONFIG_BT_ENABLED
-UCONFIG_BLUEDROID_ENABLED
-DCONFIG_BT_ENABLED=0
-DCONFIG_BLUEDROID_ENABLED=0
; Required for cryptographic functions
-DCONFIG_HEAP_POISONING_COMPREHENSIVE
-DARDUINO_ARCH_ESP32
-DED25519_TEST
-DED25519_NO_SEED
š¦ Folder Structureā
A typical project structure using the Infratic library in PlatformIO might look like this:
MyInfraticProject/
āāā platformio.ini
āāā src/
ā āāā main.cpp
āāā lib/
ā āāā Infratic/
ā ā āāā src/
ā ā ā āāā Infratic-lib.h / .cpp
ā ā ā āāā base58.h / .cpp
ā ā ā āāā ā¦
ā ā āāā examples/
ā ā āāā library.json
ā āāā ArduinoJson/
ā āāā Crypto/
ā āāā micro-ecc/
āāā .pio/
š A Note on Code Examplesā
The code examples provided throughout this documentation focus on the Infratic library functions themselves. For brevity, they do not include boilerplate code for establishing an internet connection (e.g., WiFi setup).
For any example that communicates with the Solana network to work correctly, you must add your own code to connect your ESP32 to the internet.
Here is a basic WiFi connection snippet you can use in your setup() function:
#include <WiFi.h>
const char* WIFI_SSID = "YOUR_WIFI_SSID";
const char* WIFI_PASSWORD = "YOUR_WIFI_PASSWORD";
void setup() {
Serial.begin(115200);
delay(1000);
// Connect to WiFi
Serial.print("Connecting to WiFi...");
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("\nā
WiFi connected!");
// ... your Infratic code follows
}