LogoLogo
  • 🌊Superfluid
  • Protocol Overview
    • 💡What is Superfluid?
    • 📄In-Depth Overview
      • Super Tokens
      • Super Agreements
        • 🚰Money Streaming (CFA)
        • ✳️Distributions (IDA)
        • 🌊Streaming Distributions
      • Super Apps
      • Superfluid Host
    • 🧠Use Cases
      • Recurring Payments
      • DeFi
      • Social & Community
      • Gaming
    • 📔Glossary of Terms
  • Developers
    • 🏃Quickstart
    • 🪙Super Tokens
      • Super Tokens - Solidity
      • Super Tokens - SDK Core
      • Super Tokens - Frontend Examples
      • Types of Super Tokens
      • Deploy a Super Token
        • Deploying a Wrapper Super Token
        • Deploying a Self Governed Super Token
        • Deploying a Pure Super Token
      • In-Depth
        • Tracking Super Token Balances
        • ERC777 in Super Tokens
      • Test Super Token Faucet
    • 🌊Money Streaming (CFA)
      • Solidity
        • Read Methods
          • getFlowInfo
          • getFlowRate
          • getNetFlowRate
        • Write Methods
          • createFlow
          • updateFlow
          • deleteFlow
          • With User Data
          • With Context
      • SDK Core
        • Read Methods
          • getFlow
          • getNetFlow
          • getAccountFlowInfo
        • Write Methods
          • createFlow
          • updateFlow
          • deleteFlow
      • Access Control List (ACL)
        • Solidity
          • createFlowFrom
          • updateFlowFrom
          • deleteFlowFrom
          • setFlowPermissions
          • setMaxFlowPermissions
          • revokeFlowPermissions
          • increaseFlowRateAllowanceWithPermissions
          • decreaseFlowRateAllowanceWithPermissions
          • getFlowPermissions
        • SDK Core
          • createFlowByOperator
          • updateFlowByOperator
          • deleteFlowByOperator
          • updateFlowOperatorPermissions
          • revokeFlowOperatorPermissions
          • increaseFlowRateAllowanceWithPermissions
          • getFlowOperatorData
      • Frontend Examples
      • More...
        • Flow Rate Time Frames
        • Building Batched Streams in Safe
        • Flow NFTs
    • ✳️Distributions (IDA)
      • IDA - Solidity
      • IDA - SDK Core
      • IDA - Frontend Examples
    • 🤖Super Apps
      • Super Apps in Depth
      • Super App Callbacks
        • Calling Agreements In Super Apps
      • User Data
        • NFT Billboard Example
      • SuperAppBaseFlow
      • Super App Examples
      • Super App Deployment Guide
    • 🧺Batch Calls
      • Batch Calls - SDK Core
      • Batch Calls - Frontend Examples
    • ⚙️Automations
      • Auto-Wrap
        • Dev Guide
      • Stream Scheduler
        • Dev Guide
      • Vesting Scheduler
        • Dev Guide
      • Stream Accounting API
        • Dev Guide
      • Automation Subgraphs
        • Stream Scheduler Subgraph
        • Vesting Scheduler Subgraph
        • Auto Wrap Subgraph
    • 🏗️Integration Guides
      • For Your Integration: The Basics
        • Supporting Super Tokens
        • Supporting Money Streams
        • Supporting Instant Distributions
      • Gating with Superfluid Subscriptions & Guild.xyz
      • Displaying Token Balances
      • Useful Queries for Your Integration
        • Instant Distribution Events
        • Money Streaming Events
        • Super Token Events
        • Other Helpful Queries
      • Constructing Links to The Superfluid Dashboard
    • 🔁Superfluid Subscriptions
      • Superfluid Checkout Widget
      • Implementing Subscriptions in your App
    • SDK Core General
      • Initialization
      • Functionality
      • Getting Data
      • Resolver
      • Reference Docs
    • Solidity General
      • Calling Super Agreements
      • Libraries
      • Resolver
    • Testing Guide
      • Hardhat Testing
      • Foundry Testing
      • In-Depth
        • Hardhat Mainnet Fork Testing
        • Super App Testing on Mainnet Forks
    • Subgraph
    • Reference
      • Deploying The Framework
      • EVM Contracts
      • SDK Redux
      • Superfluid Console
      • Superfluid Protocol Addresses
    • Contract Addresses
  • Sentinels
    • 🥅Liquidations & TOGA
    • 🤖Running a Sentinel
    • 🗺️Solvency Dashboard
  • Resources
    • 🌊Superfluid Wave Pool
    • 📜Superfluid on Ethereum Mainnet
    • 💰Bounty Program
    • 🛡️Security & Bug Bounties
    • 💡Project Ideas
    • 🗳️Token Dashboard Submission
    • 🎥Videos
    • Superfluid Deployment Guide
    • Learn about Ethereum
    • Code of Conduct
Powered by GitBook
On this page

Was this helpful?

  1. Developers
  2. SDK Core General

Resolver

This helper contract makes it easy to find the contract addresses for the protocol

PreviousGetting DataNextSolidity General

Last updated 2 years ago

Was this helpful?

The Resolver is a helper contract which allows you to quickly find all the contract addresses for the Superfluid Framework. You can think of it as on-chain Superfluid directory.

The resolver is always deployed when the protocol is deployed. You've probably used it already and didn't know it, as this is what the @superfluid-finance/sdk-core uses each time you call Framework.create().

If you’re using the SDK Core, it’s unlikely that you need the resolver, because the SDK exposes various methods which call the resolver behind the scenes to access specific contract addresses. For example, if you need to access a Super Token, you can do so by symbol using:

await sf.loadSuperToken(”USDCx”);

Similarly, if you need the address of any specific agreement, you can access these addresses from the Framework object itself. For example, if the Framework object is instantiated for the Goerli network like so:

const sf = await Framework.create({
    networkName: "goerli",
    provider
});

You can access the address of the host contract using the Framework object:

sf.settings.config.hostAddress

And the addresses of the constant flow agreement or instant distribution agreement contracts like so:

sf.settings.config.cfaV1Address
sf.settings.config.idaV1Address

These addresses are also accessible in the and with the .

Accessing Contracts In Solidity with the Host and Resolver

Accessing these contracts in solidity is a bit different. However, it can be just as easy if you know how to use the Superfluid Resolver and/or the Superfluid Host contract to get these addresses. In the below contract, you’ll see 3 sample functions which demonstrate how to access the addresses of already deployed contracts:

pragma solidity 0.8.13;

import { IResolver } from "@superfluid-finance/ethereum-contracts/contracts/interfaces/utils/IResolver.sol";
import { ISuperfluid } from "@superfluid-finance/ethereum-contracts/contracts/interfaces/superfluid/ISuperfluid.sol";

contract ResolverExample {
    IResolver public resolver;
    ISuperfluid public host;

    constructor(IResolver _resolver, ISuperfluid _host) {
        resolver = _resolver;
        host = _host;
    }

    function getContractFromResolver(string calldata name) external view returns (address) {
        address addr = resolver.get(name);
        return addr;
    }

    function getCFAContract() external view returns (address) {
        bytes32 agreement;
        agreement = keccak256("org.superfluid-finance.agreements.ConstantFlowAgreement.v1");

        address agreementAddress = address(host.getAgreementClass(agreement));
        return agreementAddress;
    }

    function getIDAContract() external view returns (address) {
        bytes32 agreement;
        agreement = keccak256("org.superfluid-finance.agreements.InstantDistributionAgreement.v1");

        address aggrementAddress = address(host.getAgreementClass(agreement));
        return agreementAddress;
    }
}

To get the address of a Superfluid agreement like the Constant Flow Agreement or Instant Distribution agreement, you can use the Superfluid Host contract’s getAgreementClass method. You can see this being done in both the getCFAContract() and getIDAContract() examples in the above contract. You need to hash the following string:

`org.superfluid-finance.agreements.${agreementName}.v1`

Then pass it as an argument to the host.getAgreementClass method. From here, you need to get the address of the returned contract using the same syntax seen in the above contract on lines 24 and 32.

In the case of other contracts, you can use the Resolver. If you look deep into the Superfluid SDK Core, you’ll see that the resolver makes use of the Superfluid Loader contract to load in the entire Framework.

To get a specific token address using the Resolver, you can use the resolver.get() method as seen in the above contract with the following schema:

//for Super Tokens
resolver.get(`supertokens.${protocolReleaseVersion}.superTokenSymbol`);

//example
resolver.get('supertokens.v1.DAIx');
//for ERC20 tokens listed with the protocol
resolver.get(`tokens.tokensymbol`);

//example
resolver.get('tokens.DAI');

If you'd like, you can also use the Resolver to get the entirety of the framework with the Superfluid Loader. You need to pass in the following argument to the resolver.get() function to make this happen:

resolver.get('SuperfluidLoader-v1');

The above line of code will return the address of the Superfluid Loader contract on your current network. This method will return an array which contains 4 of the key addresses used within the protocol: the host, super token factory, CFA, and IDA contract. The function needed to do this is the loadFramework function, with the current protocol version passed in as a lone string parameter:

superfluidLoader.loadFramework("v1");
Network Directory
Superfluid Console