Inspiration

Many dapps rely on many many requrests to an infura node to get the ethereum state. eg for token balances, smart contract environment variables, user account information, etc. It's not unusual to issue 200+ requests to infura in the first 5 seconds of a dapp loading (!)

What it does

A user can specify what values she wants to see and what address they're located at, and all values specified will be fetched in one call to infura (or any node). The values need not conform to any rigid schema. The js interface looks a little something like:

const { blockNum, tokenBalance, vote } = await calls([
  {
    to: '0x0',
    method: 'balanceOf(address)',
    args: ['0x0'],
    returns: [['tokenBalance', 'uint256']]
  },
  {
    to: '0x0',
    method: 'voteCast()',
    returns: [['vote', 'bytes32']]
  },
  … // etc, many more values possible w/ this requiest
]); // all these calls happen w/ one fetch

How we built it

We wrote a solidity contract in assembly that parses a byte array into values it can use to call functions at specific addresses and stores their return values into another byte array that's returned in the main function. At the same time we wrote an accessible javascript library to create the byte array to pass in, and parse the result.

Challenges we ran into

Finding a byte array schema that could give us the javascript api we wanted while still being easy to parse in assembly.

Accomplishments that we're proud of

Getting a working implementation on mainnet with a javacript library that can be useful to dapp devs today!

What we learned

The nitty gritty of calldata formatting and abi value encoding/ decoding

What's next for Read A Lot

Refine the javascript api, write a more thorough test suite, and get it in the hands of dev.

Built With

Share this project:

Updates