Super App Testing on Mainnet Forks

Learn how to test Super Apps on Hardhat mainnet forks

This section is based off the work of omnifient, a valued community member rπŸš€

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 πŸ‘‡

    ISuperfluid host,
    string memory registrationKey
) {

    uint256 configWord = SuperAppDefinitions.APP_LEVEL_FINAL |
        SuperAppDefinitions.BEFORE_AGREEMENT_CREATED_NOOP |
        SuperAppDefinitions.BEFORE_AGREEMENT_UPDATED_NOOP |

    if (bytes(registrationKey).length > 0) {
        // works on MAINNET
        host.registerAppWithKey(configWord, registrationKey);
    } else {
        // works on TESTNET

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

const HOST_ABI = ["function getGovernance() external view returns (address)"];
const HOST_ADDR = "0x3E14dC1b13c488a8d5D310918780c983bD5982E7";

const hostInstance = new ethers.Contract(HOST_ADDR, HOST_ABI, <<providerOrSigner>>);

Next, let's get an instance of the Superfluid Governance contract and its owner's address.

const GOV_ABI = [
  "function setConfig(address host, address superToken, bytes32 key, uint256 value) external",
  "function setAppRegistrationKey(address host, address deployer, string memory registrationKey, uint256 expirationTs) external",
  "function getConfigAsUint256(address host, address superToken, bytes32 key) external view returns (uint256 value)",
  "function verifyAppRegistrationKey(address host, address deployer, string memory registrationKey) external view returns (bool validNow, uint256 expirationTs)",
  "function owner() public view returns (address)",

const govInstance = new ethers.Contract(
  await hostInstance.getGovernance(),

const govOwnerAddr = await govInstance.owner();

Now, impersonate the governance owner!

// impersonate the governance owner
await network.provider.request({
  method: "hardhat_impersonateAccount",
  params: [govOwnerAddr],

// give it a lot of ETH (or MATIC because we're on Polygon!)
await network.provider.send("hardhat_setBalance", [

const govOwnerSigner = await ethers.getSigner(govOwnerAddr);

Time to make your registration key

// Set your registration key string
const registrationKey = `GM-${}`;

// Get a configuration key
const configKey = ethers.utils.keccak256(
    ["string", "address", "string"],
      <<account that will deploy the Super App>>,

// Set it in Governance - now your registrationKey is good to go!
let tx = await govInstance.setConfig(
  Math.floor( / 1000) + 3600 * 24 * 180 // 180 day expiration for key
await tx.wait();

Finally, deploy the Super App with the registrationKey you've permissioned!

const superAppFactory = await hre.ethers.getContractFactory(<<SuperAppContractName>>);
const mySuperApp = await factory.deploy(HOST_ADDR, registrationKey);

await mySuperApp.deployed();

Last updated