kopanitsa / web3-arduino

an Arduino (or ESP32) library to use web3 on Ethereum platform.
MIT License
105 stars 45 forks source link

forbidden access to infura #20

Closed toutou8148 closed 3 years ago

toutou8148 commented 3 years ago

Hi,

I am trying to get access to infura, however I get the following error:

Starting connection to server... Connected to server! HTTP/1.1 403 Forbidden Date: Tue, 15 Dec 2020 13:48:18 GMT Content-Type: application/json Content-Length: 163 Connection: close Vary: Origin {"jsonrpc":"2.0","id":0,"error":{"code":-32600,"message":"project ID is required","data":{"reason":"project ID not provided","see":"https://infura.io/dashboard"}}}

This is my code:

include

include

define ENV_SSID "**"

define ENV_WIFI_KEY "***"

string INFURA_HOST = new string("mainnet.infura.io"); string INFURA_PATH = new string("/PROECT_ID"); Web3 web3(INFURA_HOST, INFURA_PATH);

void web3_example();

void setup() { Serial.begin(115200); for(uint8_t t = 4; t > 0; t--) { Serial.printf("[SETUP] WAIT %d...\n", t); Serial.flush(); delay(1000); }

WiFi.begin(ENV_SSID, ENV_WIFI_KEY);

// attempt to connect to Wifi network:
while (WiFi.status() != WL_CONNECTED) {
    Serial.print(".");
    // wait 1 second for re-trying
    delay(1000);
}

Serial.println("Connected to WiFi");

net_example();

} void loop() { // put your main code here, to run repeatedly: }

void web3_example() { string result = web3.Web3ClientVersion(); Serial.println("web3_ClientVersion"); Serial.println(result.c_str()); }

toutou8148 commented 3 years ago

I have fixed the error by making this modification:

string* INFURA_PATH = new string("/v3/PROJECT_ID");