The emission infrastructure is a system designed to allow users to emit any type of asset (ERC20 and ERC1155) with configurable parameters including the amount, frequency, and duration of the emission. The primary use case of this system is to emit assets to partner games or players automatically in a pre-defined frequency/duration.
The emission infrastructure has the following features:
- 1.Multi-Asset Support: The system supports multiple types of assets, including ERC20 and ERC1155.
- 2.Configurable Emission Parameters: Users can set parameters such as the total amount of assets to be emitted, the frequency of emission, and the duration of emission.
- 3.Time-based Emission Rate: Emission rates can be tied to a unit of time, ensuring a consistent flow of assets over a period.
- 4.Reliability and Accuracy: The system ensures that the correct amount of assets is emitted according to the configured parameters.
Here's how to integrate with the emission infrastructure:
Create an EmissionInstance: This can be achieved using the
createEmittingInstancefunction. Here, you can set the initial parameters defining the EmissionInstance. For detailed and current information about each parameter, refer to IEmitter.sol.
Suppose you want to continuously send 10 $EXAMPLE tokens to an address. You'd like this to happen daily, at the end of each day.
(10 ether) / 1 days, // Amount per second
block.timestamp, // Start immediately
0, // Indefinite
EmittingRateChangeBehavior.CLAIM_PARTIAL, // See EmittingRateChangeBehavior for more details
0, // No tokenId for ERC20
IExampleToken.mint.selector // The function that actually mints the token
You can authorize one or more addresses to claim from the emission using the
changeEmittingInstanceCanClaimmethod. Remember, you need to call
changeEmittingInstanceCanClaimseparately for each address.
CAN_CLAIM // true to allow ADDRESS to claim. False to revoke claiming privelages
You can accomplish this using the
changeEmittingInstanceApprovalmethod. The owner of a contract must approve any call from an external contract via the game development suite to prevent malicious activity.
Note: If your token's contract mint method has permissions, you must enable the game development suite to call this method.
claimfunction from an approved address to retrieve any accumulated tokens.