Super App Testing on Mainnet Forks
Learn how to test Super Apps on Hardhat mainnet forks
In order for a Super App's callbacks to work, it needs to be registered with the Superfluid host.
On testnets, this is done permissionlessly, but on a mainnet it requires a registration key which is permissioned by Superfluid governance. See the constructor below π
constructor(
ISuperfluid host,
string memory registrationKey
) {
uint256 configWord = SuperAppDefinitions.APP_LEVEL_FINAL |
SuperAppDefinitions.BEFORE_AGREEMENT_CREATED_NOOP |
SuperAppDefinitions.BEFORE_AGREEMENT_UPDATED_NOOP |
SuperAppDefinitions.BEFORE_AGREEMENT_TERMINATED_NOOP;
if (bytes(registrationKey).length > 0) {
// works on MAINNET
host.registerAppWithKey(configWord, registrationKey);
} else {
// works on TESTNET
host.registerApp(configWord);
}
}So, in order to test a Super App on a mainnet fork, you are going to need to be able to simulate the creation of a registration key so that you can provide it to your Super App upon deployment.
Here's how you do it in Hardhat's Node.js-based environment.
Simulating Creation of a Registration Key
First, get an instance of the Superfluid Host. Here, we're just setting up the instance with the only function we'll be using - getGovernance
Next, let's get an instance of the Superfluid Governance contract and its owner's address.
Now, impersonate the governance owner!
Time to make your registration key
Finally, deploy the Super App with the registrationKey you've permissioned!
Last updated
Was this helpful?

