ethereum-multicall icon indicating copy to clipboard operation
ethereum-multicall copied to clipboard

Map reference as contract address

Open stychu opened this issue 4 years ago • 1 comments

Hello. Is it possible to map a reference from 1 contract call to be passed as a value to another contract call?

So I would like to get a PAIR of a token-BnB and then use that pair address to call getReserves

[
    {
      reference: 'factory',
      contractAddress: factoryAddress,
      abi: factoryABI,
      calls: [
        { reference: 'tokenPair', methodName: 'getPair', methodParameters: [tokenAddress, bnbAddress] },
      ]
    },
    {
      reference: 'liquidity',
      contractAddress: tokenPair,   <-----------------------------------------------------------
      abi: [
        {
          'constant': true,
          'inputs': [],
          'name': 'getReserves',
          'outputs': [
            { 'internalType': 'uint112', 'name': '_reserve0', 'type': 'uint112' },
            { 'internalType': 'uint112', 'name': '_reserve1', 'type': 'uint112' },
            { 'internalType': 'uint32', 'name': '_blockTimestampLast', 'type': 'uint32' }
          ],
          'payable': false,
          'stateMutability': 'view',
          'type': 'function'
        }
      ],
      calls: [
        { methodName: 'getReserves' },
      ]
    }
  ]

stychu avatar Jun 07 '21 00:06 stychu

Hey this is a great thing to suggest. Right now this does not support this logic. This would be contract changes for now out of scope to put in this library. Will keep this open and when I get some time investigate further. For now that will have to be 2 separate calls. Thanks for the feature request!

joshstevens19 avatar Jun 07 '21 20:06 joshstevens19