Giter VIP home page Giter VIP logo

web3-arduino's Introduction

unmaintained

Sorry but I cannot take time to maintain the library now...

web3-arduino

img

  • What is this library?

    • This is an Arduino (or ESP32) library to use web3 on Ethereum platform.
  • What is Arduino?

  • What is ESP32?

  • What is web3?

  • What is Ethereum?

    • Ethereum is a decentralized platform for applications that run exactly as programmed without any chance of fraud, censorship or third-party interference.
    • https://www.ethereum.org/

Environment

Installation

  1. download the zip file from Clone or download button on Github.
  2. launch Arduino IDE.
  3. Sketch -> Include Library -> Add .ZIP file -> select downloaded zip file.
  4. Then you can use this from Arduino IDE.

Example

Please refer examples directory.

setup

#define INFURA_HOST "rinkeby.infura.io"
#define INFURA_PATH "/<YOUR_INFURA_ID>"

Web3 web3(INFURA_HOST, INFURA_PATH);

call web3 methods

char result[128];

web3.Web3ClientVersion(result);
USE_SERIAL.println(result);

web3.Web3Sha3("0x68656c6c6f20776f726c64", result);
USE_SERIAL.println(result);

call to Contract

Contract contract(&web3, CONTRACT_ADDRESS);
strcpy(contract.options.from, MY_ADDRESS);
strcpy(contract.options.gasPrice,"2000000000000");
contract.options.gas = 5000000;
contract.SetupContractData(result, "get()");
contract.Call(result);
USE_SERIAL.println(result);

sendTransaction to Contract

Contract contract(&web3, CONTRACT_ADDRESS);
contract.SetPrivateKey((uint8_t*)PRIVATE_KEY);
uint32_t nonceVal = (uint32_t)web3.EthGetTransactionCount((char *)MY_ADDRESS);

uint32_t gasPriceVal = 141006540;
uint32_t  gasLimitVal = 3000000;
uint8_t toStr[] = CONTRACT_ADDRESS;
uint8_t valueStr[] = "0x00";
uint8_t dataStr[100];
memset(dataStr, 0, 100);
contract.SetupContractData((char*)dataStr, "set(uint256)", 123);
contract.SendTransaction((uint8_t *) result,
                         nonceVal, gasPriceVal, gasLimitVal, toStr, valueStr, dataStr);

USE_SERIAL.println(result);

Dependency

web3-arduino's People

Contributors

kopanitsa avatar okada-bcgdv avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.