Web3E (Ethereum Framework for Microcontrollers) Compilation Environment Guide

ยท

Recently, while working on an IoT blockchain integration solution, I found that Raspberry Pi-based setups were relatively straightforward due to native Web3j support. However, microcontrollers presented significant challenges. After some research, I discovered two projects: Web3-Arduino (2018) and Web3E (2020), both of which have been inactive for over a year. This guide serves as a compilation environment explanation - likely the third publicly available article about Ethereum frameworks for microcontrollers.

Hardware Requirements

  1. ESP32 Development Board: Purchase an affordable model (ยฅ20-30)
  2. USB Cable: For connection to your computer
  3. Computer: For development and programming
  4. Test Programs: Request these from your vendor to verify hardware functionality

Installation Process

Step 1: Visual Studio Code

Install VS Code through standard installation procedures.

Step 2: PlatformIO

Step 3: Project Setup

  1. Navigate to Quick Access โ†’ Projects & Configuration
  2. Select Create New Project
  3. Critical configuration:

    • Identify your ESP32 architecture
    • Select appropriate board
  4. Note: The finalization process may take considerable time

Required Modifications

  1. platformio.ini:

    lib_deps = Web3E
  2. Main Function:

    • Incorporate example code from Web3E Examples
    • Recommended: Query Token Balance (checks ERC20/ERC875 token balances)

Compilation and Execution

  1. Click the alien icon in VS Code's bottom-left corner
  2. Select Project Tasks โ†’ Upload and Monitor
  3. The system will:

    • Automatically compile
    • Download to device
    • Monitor via serial output

Code Explanations

Core Structure

Configuration Code

const char *ssid = "<YOUR SSID>";
const char *password = "<YOUR WiFi PASSWORD>";
const char *INFURA_HOST = "kovan.infura.io";
const char *INFURA_PATH = "/v3/<your Infura token>";
#define NATIVE_ETH_TOKENS "Kovan ETH"
#define ERC875CONTRACT "0x0b70dd9f8ada11eee393c8ab0dd0d3df6a172876"
#define ERC20CONTRACT "0xb06d72a24df50d4e2cac133b320c5e7de3ef94cb"
#define USERACCOUNT "0x835bb27deec61e1cd81b3a2feec9fbd76b15971d"

Setup Function

void setup() {
  Serial.begin(115200);
  setup_wifi();
  string userAddress = USERACCOUNT;
  queryERC20Balance(ERC20CONTRACT, USERACCOUNT);
  queryERC875Balance(ERC875CONTRACT, USERACCOUNT);
}

Current Challenges and Future Plans

  1. Existing Issues:

    • Frequent errors due to network restrictions
    • Lack of updates for Web3E
    • Limited example implementations
    • Hardware compatibility constraints
  2. Development Roadmap:

    • Create more versatile Ethereum interface library
    • Support STM32, ESP32, and ESP8266 platforms
    • Develop solutions without network restrictions
    • Implement universal IoT blockchain integration framework

๐Ÿ‘‰ Essential Tools for Blockchain Development

FAQ Section

Q1: What microcontrollers support Web3E?

A: Primarily ESP32, with potential for STM32 and ESP8266 through custom implementations.

Q2: How to resolve PlatformIO installation errors?

A: Ensure stable internet connection and use VPN if necessary for complete package downloads.

Q3: Where can I find updated Web3E examples?

A: Check the AlphaWallet GitHub repository for the latest versions.

Q4: Can I use this framework without Infura?

A: Yes, but requires configuring alternative Ethereum node connections.

Q5: What's the minimum hardware requirement?

A: ESP32 with 4MB+ flash memory and stable WiFi connectivity.

๐Ÿ‘‰ Complete ESP32 Development Kit

Q6: How to test ERC20/ERC875 balances?

A: Use the provided example code with your contract addresses and Infura endpoint.