makerdao / multicall.js

Multicall.js: A JavaScript blockchain state management library for dapps
MIT License
421 stars 97 forks source link

Aggregate usage example #27

Open shmuel-web opened 3 years ago

shmuel-web commented 3 years ago

Hi

thanks for open-sourcing this project

could you add a short and simple example of using "aggregate" to batch calls

thanks

shmuel-web commented 3 years ago

maybe something like this but with more explainers

async function start(){
  try{
    const res = await aggregate([{
      target: '0xbbf289d846208c16edc8474705c748aff07732db',
      method: 'what()',
      returns: [['foo']],
      returnTypes: ['uint256']
    }], config)
    console.log({res})
  } catch (err){
    console.error(err)
  }
}

start()