!Amt error occurs when attempting to execute the
escrowPackContents function which is called in the
createPack function in the Pack contract. This error is triggered when the total number of reward units available for distribution is not divisible by the number of rewards in each pack to be distributed, resulting in a remainder. In other words, the contract expects the distribution of reward units to be balanced and evenly divisible, and any deviation from this requirement leads to the
Explanation of Reward Units in Pack Contract:
In the Pack contract, a reward unit represents the contents that a user receives when opening a pack. It can be a combination of ERC20, ERC721, or ERC1155 tokens. For instance, a reward unit could be something like "2 BoredApe NFTs" or "50 USDC."
The contract allows specifying two things for each pack:
- The composition of the reward unit, which determines what the user will receive when opening a pack.
- The number of reward units to distribute to the opener when they open a pack.
For successful execution of the
escrowPackContents function, it is essential to ensure that the total number of reward units is a multiple of the number of reward units per pack open. Any deviation from this requirement will trigger the
!Amt error, indicating that the contract cannot perform the distribution due to the presence of a remainder.
To resolve the "!Amt" error and enable the smooth functioning of the
escrowPackContents function, follow these steps:
- Validate Total Reward Units:
Ensure that the total number of reward units available for distribution (sumOfRewardUnits) is divisible by the number of reward units per pack open (amountPerOpen). This means there should be no remainder when dividing
- Check Reward Units Composition:
Verify that each reward unit defined in the
_contentsarray has a valid composition and totalAmount value. Make sure that the totalAmount is not zero, and if the token type is ERC721, the totalAmount is equal to 1 (representing one unique NFT).
- Handling Non-Divisible Reward Units: If you encounter situations where the total number of reward units cannot be evenly divided among the number of reward units per pack open, consider either adjusting the total reward units or the number of reward units per pack to make them divisible.
By following these steps and ensuring that the reward units are properly balanced and divisible, you should be able to resolve the "!Amt" error and allow users to open packs successfully without any issues.
If you need further assistance or encounter any other issues, please feel free to reach out to our support team.