Learn how to batch multiple operations into a single transaction for efficiency
Prior to this point, registering multiple IPs or performing other operations such as minting, attaching licensing terms, and registering derivatives requires separate transactions for each operation. This can be inefficient and costly. To streamline the process, you can batch multiple transactions into a single one. Two solutions are now available for this:
multicall
function.multicall
FunctionSPG includes a multicall
function that allows you to combine multiple read or write operations into a single transaction.
The multicall
function accepts an array of encoded call data and returns an array of encoded results corresponding to each function call:
Suppose you want to mint multiple NFTs, register them as IPs, and link them as derivatives to some parent IPs.
To accomplish this, you can use SPG’s multicall
function to batch the calls to the mintAndRegisterIpAndMakeDerivative
function.
Here’s how you might do it:
To batch call mintAndRegisterIpAndMakeDerivative
using the multicall
function:
The Multicall3 contract is not fully compatible with SPG functions that involve SPGNFT minting due to access control and context changes during Multicall execution. For such operations, use SPG’s built-in multicall function.
The Multicall3 contract allows you to execute multiple calls within a single transaction and aggregate the results. The viem
library provides native support for Multicall3.
(Same address across all EVM chains)
To batch multiple function calls, you can use the following functions:
aggregate3
: Batches calls using the Call3
struct.aggregate3Value
: Similar to aggregate3
, but also allows attaching a value to each call.aggregate3
.aggregate3Value
.aggregate3
and aggregate3Value
.For detailed examples in Solidity, TypeScript, and Python, see the Multicall3 repository.
For a list of limitations when using Multicall3, refer to the Multicall3 README.
Learn how to batch multiple operations into a single transaction for efficiency
Prior to this point, registering multiple IPs or performing other operations such as minting, attaching licensing terms, and registering derivatives requires separate transactions for each operation. This can be inefficient and costly. To streamline the process, you can batch multiple transactions into a single one. Two solutions are now available for this:
multicall
function.multicall
FunctionSPG includes a multicall
function that allows you to combine multiple read or write operations into a single transaction.
The multicall
function accepts an array of encoded call data and returns an array of encoded results corresponding to each function call:
Suppose you want to mint multiple NFTs, register them as IPs, and link them as derivatives to some parent IPs.
To accomplish this, you can use SPG’s multicall
function to batch the calls to the mintAndRegisterIpAndMakeDerivative
function.
Here’s how you might do it:
To batch call mintAndRegisterIpAndMakeDerivative
using the multicall
function:
The Multicall3 contract is not fully compatible with SPG functions that involve SPGNFT minting due to access control and context changes during Multicall execution. For such operations, use SPG’s built-in multicall function.
The Multicall3 contract allows you to execute multiple calls within a single transaction and aggregate the results. The viem
library provides native support for Multicall3.
(Same address across all EVM chains)
To batch multiple function calls, you can use the following functions:
aggregate3
: Batches calls using the Call3
struct.aggregate3Value
: Similar to aggregate3
, but also allows attaching a value to each call.aggregate3
.aggregate3Value
.aggregate3
and aggregate3Value
.For detailed examples in Solidity, TypeScript, and Python, see the Multicall3 repository.
For a list of limitations when using Multicall3, refer to the Multicall3 README.