{"id":21684014,"url":"https://github.com/tordwessman/r2web3","last_synced_at":"2026-05-05T06:40:01.840Z","repository":{"id":196281263,"uuid":"695117369","full_name":"TordWessman/r2web3","owner":"TordWessman","description":"A Web3 library inteded to be used for microcontrollers","archived":false,"fork":false,"pushed_at":"2024-04-12T08:15:51.000Z","size":352,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-20T11:29:19.165Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TordWessman.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-09-22T11:49:42.000Z","updated_at":"2024-01-31T22:35:46.000Z","dependencies_parsed_at":"2023-12-22T10:24:14.444Z","dependency_job_id":"b96509dc-3e98-4683-8b9e-d5d028af7aa4","html_url":"https://github.com/TordWessman/r2web3","commit_stats":null,"previous_names":["tordwessman/r2web3"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/TordWessman/r2web3","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TordWessman%2Fr2web3","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TordWessman%2Fr2web3/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TordWessman%2Fr2web3/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TordWessman%2Fr2web3/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TordWessman","download_url":"https://codeload.github.com/TordWessman/r2web3/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TordWessman%2Fr2web3/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273051831,"owners_count":25037073,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-31T02:00:09.071Z","response_time":79,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-25T16:14:19.008Z","updated_at":"2026-05-05T06:39:56.821Z","avatar_url":"https://github.com/TordWessman.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# r2web3\nA Web3 library written in C++ intended to be used for microcontrollers, but should work on any platform. \nHas at this point only been tested in Linux (g++) and ESP8266 and ESP32 boards (Arduino IDE).\n\nThis project is under development. Here's a list of a few thing that's on the roadmap:\n * Unit tests\n * ABI encoding (existing, but incomplete)\n * ABI decoding (existing, but incomplete)\n * EIP-155 support\n\n## Installation\n```\n$ cd ~/Arduino/libraries\n$ git clone https://github.com/TordWessman/r2web3.git\n```\nRemember to restart Arduino IDE\n\n## Examples\nHere's a blob of example code.\n\n```\n#ifdef ESP8266\n#include \u003cESP8266WiFi.h\u003e\n#endif\n#ifdef ESP32\n#include \u003cWiFi.h\u003e\n#endif\n#include \u003cr2web3.h\u003e\n\nusing namespace blockchain;\n\n#define SSID \"\u003cssid\u003e\"\n#define WIFI_PASSWORD \"\u003cpassword\u003e\"\n#define PRIVATE_KEY \"\u003cprivate key\u003e\" // Account private key\n#define CONTRACT_ADDRESS \"\u003ccontract address\u003e\" // Address to a deployed contract\n\n// Use CA Certificate for https.\n// The one below is valid for json-rpc.evm.testnet.shimmer.network.\n// Use root certificate unless accessing a local endpoint (e.g. Ganache)\nconst char cert [] PROGMEM = R\"CERT(\n-----BEGIN CERTIFICATE-----\nMIIDzTCCArWgAwIBAgIQCjeHZF5ftIwiTv0b7RQMPDANBgkqhkiG9w0BAQsFADBa\nMQswCQYDVQQGEwJJRTESMBAGA1UEChMJQmFsdGltb3JlMRMwEQYDVQQLEwpDeWJl\nclRydXN0MSIwIAYDVQQDExlCYWx0aW1vcmUgQ3liZXJUcnVzdCBSb290MB4XDTIw\nMDEyNzEyNDgwOFoXDTI0MTIzMTIzNTk1OVowSjELMAkGA1UEBhMCVVMxGTAXBgNV\nBAoTEENsb3VkZmxhcmUsIEluYy4xIDAeBgNVBAMTF0Nsb3VkZmxhcmUgSW5jIEVD\nQyBDQS0zMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEua1NZpkUC0bsH4HRKlAe\nnQMVLzQSfS2WuIg4m4Vfj7+7Te9hRsTJc9QkT+DuHM5ss1FxL2ruTAUJd9NyYqSb\n16OCAWgwggFkMB0GA1UdDgQWBBSlzjfq67B1DpRniLRF+tkkEIeWHzAfBgNVHSME\nGDAWgBTlnVkwgkdYzKz6CFQ2hns6tQRN8DAOBgNVHQ8BAf8EBAMCAYYwHQYDVR0l\nBBYwFAYIKwYBBQUHAwEGCCsGAQUFBwMCMBIGA1UdEwEB/wQIMAYBAf8CAQAwNAYI\nKwYBBQUHAQEEKDAmMCQGCCsGAQUFBzABhhhodHRwOi8vb2NzcC5kaWdpY2VydC5j\nb20wOgYDVR0fBDMwMTAvoC2gK4YpaHR0cDovL2NybDMuZGlnaWNlcnQuY29tL09t\nbmlyb290MjAyNS5jcmwwbQYDVR0gBGYwZDA3BglghkgBhv1sAQEwKjAoBggrBgEF\nBQcCARYcaHR0cHM6Ly93d3cuZGlnaWNlcnQuY29tL0NQUzALBglghkgBhv1sAQIw\nCAYGZ4EMAQIBMAgGBmeBDAECAjAIBgZngQwBAgMwDQYJKoZIhvcNAQELBQADggEB\nAAUkHd0bsCrrmNaF4zlNXmtXnYJX/OvoMaJXkGUFvhZEOFp3ArnPEELG4ZKk40Un\n+ABHLGioVplTVI+tnkDB0A+21w0LOEhsUCxJkAZbZB2LzEgwLt4I4ptJIsCSDBFe\nlpKU1fwg3FZs5ZKTv3ocwDfjhUkV+ivhdDkYD7fa86JXWGBPzI6UAPxGezQxPk1H\ngoE6y/SJXQ7vTQ1unBuCJN0yJV0ReFEQPaA1IwQvZW+cwdFD19Ae8zFnWSfda9J1\nCZMRJCQUzym+5iPDuI9yP+kHyCREU3qzuWFloUwOxkgAyXVjBYdwRVKD05WdRerw\n6DEdfgkfCv4+3ao8XnTSrLE=\n-----END CERTIFICATE-----\n)CERT\";\n\nAccount account(PRIVATE_KEY);\nAddress contractAddress(CONTRACT_ADDRESS);\nESPNetwork networkFacade(cert); // Use the ESP network stack.\nChain chain(\"https://json-rpc.evm.testnet.shimmer.network\", \u0026networkFacade); // Use ShimmerEVM testnet.\n\nvoid setup() {\n\n  Serial.begin(9600);\n  WiFi.mode(WIFI_STA);\n\n  WiFi.begin(SSID, WIFI_PASSWORD);\n\n  int connectionAttempts = 0;\n  while (WiFi.status() != WL_CONNECTED) {\n    delay(500);\n    Serial.print(\".\");\n  }\n  \n  Serial.println(\"Connecting to blockchain...\");\n  if(chain.Start()) {\n    Serial.println(\"...done\");\n  } else {\n    Serial.println(\"...failed\");\n  }\n}\n\n/// Example of a transfer to a specific address\nvoid makeTransfer() {\n  Address sendToAddress(\"\u003crecipient address\u003e\");\n  BigNumber sendAmount = BigNumber(random(1000,10000));\n  uint32_t gasLimit = 6721975;\n  chain.Send(\u0026account, sendToAddress, sendAmount, gasLimit);\n}\n\n/// Check balance\nvoid getBalance() {\n\n  Result\u003cBigNumber\u003e balanceResult = chain.GetBalance(account.GetAddress());\n\n  if (balanceResult.HasValue()) {\n\n    // Retrieve tha balance and convert it into a human-friendly decimal string.\n    char *balanceDecimalString = balanceResult.Value().GenerateDecimalString();\n    Serial.print(\"Balance: \"); Serial.println(balanceDecimalString);\n    delete []balanceDecimalString;\n  }\n\n  // Retrieve the balance of an ERC-20 contract\n  Result\u003cBigNumber\u003e contractBalanceResult = chain.GetBalance(account.GetAddress(), contractAddress);\n}\n\n/// View call\nvoid viewCall() {\n  ContractCall call(\"add\", {ENC(10u, \"uint32\"), ENC({ENC(20u), ENC(30u)}, \"uint32[]\")}); // Equivalent to method signature 'add(uint32,uint32[])'\n  \n  Result\u003cTransactionResponse\u003e result = chain.ViewCall(account.GetAddress(), contractAddress, \u0026call);\n  \n  if (result.HasValue()) {\n    Serial.print(\"Result: \"); Serial.println(result.Value().Result());\n  } else {\n    Serial.print(\"Failure: \"); Serial.println(result.ErrorCode());\n  }\n}\n\n/// (State changing) contract call\nvoid mutateCall() {\n    ContractCall contractCall(\"setFoo\", {ENC((uint32_t)random(1000,10000))}); // Equivalent to method signature 'setFoo(uint256y)'\n    BigNumber gasPrice(1234567); // chain.EstimateGas could be used instead.\n    BigNumber sendAmount = BigNumber(0u);\n    uint32_t gasLimit = 6721975;\n    Result\u003cTransactionResponse\u003e contractCallResponse = chain.Send(\u0026account, contractAddress, sendAmount, 6721975, \u0026gasPrice, \u0026contractCall);\n}\n\nvoid loop() {\n    makeTransfer();\n    viewCall();\n    mutateCall();\n    getBalance();\n    delay(1000 * 60 * 60);\n}\n```\n\n## Secure connection (HTTPS)\nWhen accessing a HTTP over TLS, one must specify the root certificate for the endpoint when instantiating the `ESPNetwork`. No certificates are provided and developers has to provide these for the RPC-URL:s they intend to use.\n\nPlease note that `Restart()` method must be called once the WiFi connection has been established and _if_ the device clock has lost synchronization (e g after hybernation).\n\nThere are several ways to retrieve the certificate, and here's one:\n```\n$ openssl s_client -showcerts -verify 5 -connect \u003cendpoint\u003e:443 \u003c /dev/null\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftordwessman%2Fr2web3","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftordwessman%2Fr2web3","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftordwessman%2Fr2web3/lists"}