-
Notifications
You must be signed in to change notification settings - Fork 258
Framework Deployment Guide
Prerequisites: you need nodejs v16 and npm installed.
Then follow this instructions:
- Create an empty folder and start from there
mkdir superfluid-deployment && cd superfluid-deployment
- Create a new npm project (this is not strictly necessary, but makes sure npm installs packages in this folder)
npm init -y
- Install necessary dependencies
npm install @superfluid-finance/ethereum-contracts
npm install truffle
npm install @truffle/hdwallet-provider
npm install dotenv
- 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
- 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.
Additionally, you also need to set the following environment variables in your shell:
export RELEASE_VERSION=v1
- Prepare and test the contract binaries:
cp -a node_modules/@superfluid-finance/ethereum-contracts/build .
Now you are 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-print-contract-addresses.js : >(cat)
This should print the protocol v1 contract addresses of the Superfluid deployment on Polygon.
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.
- Deploy superfluid framework (replace with the name of the network you want to deploy to, e.g. with optimism-kovan or arbitrum-one or avalanche-C):
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.
(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!
- 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.
- 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 not yet known the the framework
# export NATIVE_TOKEN_SYMBOL="XYZ"
npx truffle --network <network> exec node_modules/@superfluid-finance/ethereum-contracts/scripts/deploy-super-token.js : 0x0000000000000000000000000000000000000000
- 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 --network <network> exec node_modules/@superfluid-finance/ethereum-contracts/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!
- Governance Overview
- For Contributors
- Development Process
- Protocol EVMv1 Operations
- Protocol EVMv1 Technical Notes
- Protocol EVMv1 Core Subgraph