Skip to content

Framework Deployment Guide

Miao ZhiCheng edited this page Jan 27, 2022 · 12 revisions

Deploy the Superfluid Protocol

Prerequisites: you need nodejs v14 and npm installed.

Then follow this instructions:

  1. Create an empty folder and start from there
mkdir superfluid-deployment && cd superfluid-deployment
  1. Create a new npm project (this is not strictly necessary, but makes sure npm installs packages in this folder)
npm init -y
  1. Install necessary dependencies
npm install @superfluid-finance/ethereum-contracts
npm install truffle
npm install @truffle/hdwallet-provider
npm install dotenv
  1. Create a file truffle-config.js with the configuration you want.
    You may use a copy from the protocol repository:
wget https://raw.githubusercontent.com/superfluid-finance/protocol-monorepo/dev/packages/ethereum-contracts/truffle-config.js
  1. Set the needed parameters for web3 provider (rpc) and account.
    If using the provided truffle-config.js, you can do so by creating a file .env with the relevant variables set. For reference, see this template.

  2. Additionally, set the following environment variables in your shell:

export RELEASE_VERSION=v1
cp -a node_modules/@superfluid-finance/ethereum-contracts/build .

Now you should be ready to go!
You may want to do a sanity check by inspecting a protocol already deployed, e.g. for Polygon mainnet:

POLYGON_MAINNET_PROVIDER_URL=https://polygon-rpc.com npx truffle --network polygon-mainnet exec node_modules/@superfluid-finance/ethereum-contracts/scripts/info-show-protocol.js

This should print the configuration (protocol contract addresses) of the Superfluid deployment on Polygon and a list of related Super Tokens.

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 may not be comparable for all EVM chains, e.g. on Arbitrum the gas pricing differs considerably and values are typically more than an order of magnitude larger.)
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 optimism-kovan)
CREATE_NEW_RESOLVER=1 npx truffle --network <network> exec node_modules/@superfluid-finance/ethereum-contracts/scripts/deploy-framework.js

This will take a few minutes, depending on the speed of the network.
If the process succeeds, you should get output like this at the end:

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

Congratulations, you successfully deployed the framework!

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

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.

After deployment, the protocol governance initially belongs to the deployer contract.

  1. In order to hand governance privileges over to a different account, do
npx truffle --network <network> exec node_modules/@superfluid-finance/ethereum-contracts/scripts/gov-transfer-framework-ownership.js : <new gov owner> <new resolver admin>

needs to be replaced with the account address you want governance to hand over to.
_ needs to be replaced with the account address you want to make the new resolver admin.

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

Thank you!

Clone this wiki locally