makerdao / multicall

Multicall: Aggregate multiple constant function call results into one
MIT License
851 stars 451 forks source link

Can not call the function Aggregate - Multicall2.sol on BSC testnet #23

Closed vietjovi closed 3 years ago

vietjovi commented 3 years ago

Hello there,

I already deployed the multicall2.sol smart contract on BSC Testnet https://testnet.bscscan.com/address/0x8F3273Fb89B075b1645095ABaC6ed17B2d4Bc576#code then call the contract by using the following typescript code:

  try {
    const multi = getMulticallContract(options.web3 || web3NoAccount)
    const itf = new Interface(abi)

    const calldata = calls.map((call) => [call.address.toLowerCase(), itf.encodeFunctionData(call.name, call.params)])
    const { returnData } = await multi.methods.aggregate(calldata).call(undefined, options.blockNumber)
    const res = returnData.map((call, i) => itf.decodeFunctionResult(calls[i].name, call))

    return res
  } catch (error) {
    throw new Error(error)
  }
}

I got the error

Uncaught (in promise) Error: Error: Returned error: execution reverted: Multicall aggregate: call failed

It's weird. Because the function works properly on Mainnet. Can anyone help me?

vietjovi commented 3 years ago

Here is the input data that I used 0: Array [ "0xa35062141fa33bca92ce69fed37d0e8908868aae", "0x70a082310000000000000000000000003ed8936cafdf85cfdba29fbe5940a5b0524824f4" ] ​ 1: Array [ "0xae13d989dac2f0debff460ac112a837c89baa7cd", "0x70a082310000000000000000000000003ed8936cafdf85cfdba29fbe5940a5b0524824f4" ] ​ 2: Array [ "0x3ed8936cafdf85cfdba29fbe5940a5b0524824f4", "0x70a082310000000000000000000000001d32c2945c8fdcbc7156c553b7cea4325a17f4f9" ] ​ 3: Array [ "0x3ed8936cafdf85cfdba29fbe5940a5b0524824f4", "0x18160ddd" ] ​ 4: Array [ "0xa35062141fa33bca92ce69fed37d0e8908868aae", "0x313ce567" ] ​ 5: Array [ "0xae13d989dac2f0debff460ac112a837c89baa7cd", "0x313ce567" ]