MultiCall
A React + Redux library for fetching, batching, and caching chain state via the MultiCall contract.
Setup
yarn add @moraswap/redux-multicall
or npm install @moraswap/redux-multicall
Usage
The usage of this library is similar to RTK Query.
export const multicall = createMulticall({ reducerPath: 'multicall' })
export const rootReducer = combineReducers({
[multicall.reducerPath]: multicall.reducer
})
To use the updater, you'll need an instance of the Moraswap Multicall2 contract:
import { abi as MulticallABI } from '@moraswap/v3-core/artifacts/contracts/lens/MoraswapInterfaceMulticall.sol/MoraswapInterfaceMulticall.json'
import { Contract } from '@ethersproject/contracts'
import { MoraswapInterfaceMulticall } from './abi/types'
const multicall2Contract = new Contract(address, MulticallABI, provider) as MoraswapInterfaceMulticall
For a more detailed example, see basic example app in ./integration-tests
Alpha software
The latest version of the SDK is used in production in the Moraswap Interface,
but it is considered Alpha software and may contain bugs or change significantly between patch versions.
If you have questions about how to use the SDK, please reach out in the #dev-chat
channel of the Discord.
Pull requests welcome!