Common Diamond Errors
1. A state variable in AppStorage has the wrong value
A state variable in AppStorage has the wrong value or the value 0 when it should not. This is caused by declaring state variables outside AppStorage and Diamond Storage which causes a misalignment of data. This error is commonly caused by a facet inheriting a contract that declares state variables outside AppStorage and Diamond Storage.
The solution is to remove any declarations of state variables outside AppStorage or Diamond Storage and put them in AppStorage or Diamond Storage.
2. Can't add function that already exists
This error is caused by trying to add a function to a diamond that already exists.
You can see what functions are in a diamond by using the ABI of the diamond with the loupe functions. The `diamondCut` function allows a function to be replaced if it already exists but does not allow a function to be added if it already exists.
3. ProviderError: VM Exception while processing transaction: revert
This error can happen when calling the diamondCut function to add many functions and not enough gas is used. This can be solved by increasing the amount of gas for the transaction. If using ethersjs then checkout the āgasLimitā override.
Create your profile
Only paid subscribers can comment on this post
Check your email
For your security, we need to re-authenticate you.
Click the link we sent to , or click here to sign in.