Skip to main content

Background

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:
  1. Batch SPG function calls: Use SPG’s built-in multicall function.
  2. Batch function calls beyond SPG: Use the Multicall3 Contract.

1. Batch SPG Function Calls via Built-in multicall Function

SPG includes a multicall function that allows you to combine multiple read or write operations into a single transaction.

Function Definition

The multicall function accepts an array of encoded call data and returns an array of encoded results corresponding to each function call:
Solidity

Example Usage

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:
Solidity
To batch call mintAndRegisterIpAndMakeDerivative using the multicall function:
JavaScript

2. Batch Function Calls via Multicall3 Contract

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.

Aeneid Testnet Multicall3 Deployment Info

(Same address across all EVM chains)

Main Functions

To batch multiple function calls, you can use the following functions:
  1. aggregate3: Batches calls using the Call3 struct.
  2. aggregate3Value: Similar to aggregate3, but also allows attaching a value to each call.
Solidity

Struct Definitions

  • Call3: Used in aggregate3.
  • Call3Value: Used in aggregate3Value.
Solidity

Return Type

  • Result: Struct returned by both aggregate3 and aggregate3Value.
Solidity
For detailed examples in Solidity, TypeScript, and Python, see the Multicall3 repository.

Limitations

For a list of limitations when using Multicall3, refer to the Multicall3 README.

Additional Resources

Full Multicall3 Interface

Solidity