@kleros/multicall-relayer
v0.1.0
Published
Multicall3 typescript bindings and transaction relayer logic
Downloads
5
Readme
MulticallRelayer
Adds multiple calldatas to a batch and calls Multicall3 contract's aggregate3
function.
Installing
$ yarn add @kleros/multicall-relayer
Using it
Create MultiCaller
import MultiCaller from "@kleros/multicall-relayer"
const multicaller = new MultiCaller({
rpcUrl,
privateKey,
multicall3Address,
gasPriceCeilingWei, // optional
logtailSourceToken, // optional
amqp: { url, exchange } // optional
})
Add call to be batched
multicaller.add({
allowFailure: false,
target: poh.address,
callData: pohI.encodeFunctionData(
"withdrawFeesAndRewards",
[beneficiary, humanityId, requestId, challengeId, round]
)
})
// Or multiple calls...
multicaller.add(...calls)
Send the transaction!
const tx = await multicaller.send()
Constructor arguments
rpcUrl
- url of the rpc to be used.privateKey
- private key of wallet to execute the transaction.multicall3Address
- Multicall3 contract address on the chain corresponding to the given rpc.gasPriceCeilingWei
(optional) - gas price ceiling in wei.logtailSourceToken
(optional) - Logtail token to send logs to. If missing,console.log
is used.amqp
(optional) - AMQP to be notified once the transaction is sent to the blockchain. Requires 2 parameters:url
- url of the provider.exchange
- name of the exchange.