Skip to content

Framework Deployment Guide

Didi edited this page Jul 18, 2023 · 8 revisions

Deploy the Superfluid Protocol

Prerequisites: you need nodejs v16 and npm installed.

Then follow this instructions:

  1. Clone the monorepo:
git clone https://github.com/superfluid-finance/protocol-monorepo.git
cd protocol-monorepo
  1. Install dependencies and build:
yarn install && yarn build-for-contracts-dev

This will take a few minutes.

  1. Navigate to ethereum-contracts package:
cd packages/ethereum-contracts
  1. Set the release version:
export RELEASE_VERSION=v1
  1. Provide env vars for web3 provider (RPC) and deployer account (mnemonic).
    You can do so by copying and then modifying the template .env file:
cp .env.template .env
editor .env
  1. Check your setup
    Before going on with the actual deployment, make sure the deployer account has enough funds for the transaction fees.
    The deployment of the whole framework involves approximately 20 transactions of varying size. To get an idea: on a typical EVM chain, the overall gas consumed for a protocol deployment is currently approximately 20M gas. (Note that this value can differ for EVM implementations with different gas accounting.)
    If you multiply that number with the gas price typical for your network of choice, you get an idea for the amount of native coins the deployer account needs to have. E.g. with a gas price of 10 Gwei, deployment would incur approximately 20e6*10e9=2e17 wei in native coins (= 0.2 units).

Also make sure you're using an RPC node without tight rate limits. Public RPC nodes may start rejecting requests halfway through the deployment, making it fail.

  1. Deploy superfluid framework (replace with the name of the network you want to deploy to, e.g. with arbitrum-one or avalanche-c):
CREATE_NEW_RESOLVER=1 npx truffle exec --network <network> ops-scripts/deploy-framework.js

This will take a few minutes, depending on the speed of the chain and RPC.
(Note: If the process is interrupted, e.g. due to an RPC timeout, you should be able to resume by running the same command again, but with the flag CREATE_NEW_RESOLVER=1 not set and an env var RESOLVER_ADDRESS=0x... set instead, the value being the newly deployed resolver address logged during the previous run. If the process failed before that step, meaning no resolver was deployed yet, run the initial command again.)

If the process succeeds, you should get output like this at the end:

======== Superfluid framework deployed ========
=============== TEST ENVIRONMENT RESOLVER ======================
export RESOLVER_ADDRESS=0x...

Congratulations, you successfully deployed the framework!

  1. Next you need to set the new resolver address in your environment (replace 0x... with the actual address shown in your deployment log) and do
export RESOLVER_ADDRESS=0x...

You need to always have this env variable set for further interaction with the newly deployed protocol - as long as this deployment isn't included in a distribution of the Superfluid SDK.

  1. Deploy Native-Asset Super Token

In order to use the protocol, we need Super Tokens.
Any ERC20 token on the network can be wrapped into a Super Token (see Super Token Classification, deployment instructions) anytime later.

The native asset of the chain (e.g. ETH on Ethereum and its L2's) requires a different Super Token contract. In order to deploy it, do

# optional: provide native token symbol via ENV var if it is not "ETH" and not yet configured in the metadata package
# export NATIVE_TOKEN_SYMBOL="XYZ"
npx truffle exec --network <network> ops-scripts/deploy-super-token.js : 0x0000000000000000000000000000000000000000
  1. (Optional): deploy more SuperTokens

If there's ERC20 tokens you'd like to create SuperToken wrappers for (e.g. popular stablecoins), you can do so with:

npx truffle exec --network <network> ops-scripts/deploy-super-token.js : <ERC20_ADRRESS>
  1. Hand over protocol governance to the community

After deployment, the protocol governance initially belongs to the deployer contract. In order to hand it over, do

npx truffle exec --network <network> ops-scripts/gov-transfer-framework-ownership.js : 0xCcA090FD60d405a10b786559933daEEc4e2053Af 0xCcA090FD60d405a10b786559933daEEc4e2053Af

This transfers admin privileges for protocol governance and the resolver contract to a handover account which will then forward them to network specific accounts managed by the community.

That’s it, the protocol is deployed and ready to be used.

Thank you!

Clone this wiki locally