Sablier V2 Core: A Comprehensive Guide to Token Distribution Protocols

Nov 26, 2022 | Blockchain

Welcome to our deep dive into Sablier V2 Core! If you are interested in token distribution technology, payroll, and innovative ways to manage assets within decentralized organizations, you’ve landed in the right place. This guide will help you understand what Sablier V2 Core is, how to install it, and how to make the most of its functionalities.

What is Sablier V2?

Sablier V2 is a powerful token distribution protocol designed for use by Decentralized Autonomous Organizations (DAOs) and businesses. It enables functionalities such as vesting, payroll systems, and airdrops. At its core, Sablier boasts a unique model known as the linear stream, which allows assets to be distributed continuously, by the second, making transactions smooth and efficient.

How Does It Work?

To visualize how Sablier V2 functions, think of it as a continuous water fountain running in a park. Here’s how it works:

  • The fountain’s reservoir represents the pile of ERC-20 tokens deposited into a contract.
  • The water flow symbolizes the gradual distribution of tokens to the recipient. Just as visitors can refill their cups with water as it flows out, users can access their allocated tokens over time.
  • The fountain’s tap (payment rate) can be adjusted—much like changing water flow, depending on the start and end times or the total amount deposited.

Installation: How to Get Started

To start using Sablier V2 Core, you can choose from two installation methods. The recommended way is using Node.js:

Using Node.js

  • Run the following command to install Sablier V2 Core with your favorite package manager (e.g., Bun):
  • bun add @sablierv2-core
  • If you’re utilizing Foundry, be sure to update your remappings.txt file:
  • text@sablierv2-core=node_modules/@sablierv2-core
    @openzeppelincontracts=node_modules/@openzeppelincontracts
    @prbmath=node_modules/@prbmath

Git Submodules (Less Recommended)

If you prefer using Git submodules, follow these steps:

  • Install the submodule using Forge:
  • forge install --no-commit sablier-labsv2-core
  • Next, install project dependencies:
  • forge install --no-commit OpenZeppelin/openzeppelin-contracts@v5.0.2 PaulRBerg/prb-math@v4.0.3
  • Don’t forget to update your remappings.txt file with the following:
  • text@sablierv2-core=lib/v2-core
    @openzeppelincontracts=lib/openzeppelin-contracts/contracts
    @prbmath=lib/prb-math

Usage

To utilize Sablier V2 Core in your contract, here’s a brief example:

import ISablierV2LockupLinear from "@sablierv2-core/src/interfaces/ISablierV2LockupLinear.sol";
contract MyContract ISablierV2LockupLinear sablier;
// Function to build something with Sablier
function buildSomethingWithSablier() external
    ...

Architecture Insights

Sablier V2 employs a singleton-style architecture, which simplifies the management of streams using LockupLinear, LockupDynamic, and LockupTranched contracts. Instead of deploying a new contract for each stream, it consolidates all streams into one, which enhances gas efficiency and maintainability. It’s akin to a single main highway that multiple cars (streams) use, reducing the need for individual paths.

Troubleshooting Tips

If you encounter issues during installation or usage, consider the following:

  • Ensure you have the correct version of Node.js or Commits if you’re using Foundry.
  • Double-check that your remappings.txt file is correctly configured to point to the appropriate directories.
  • Refer to the documentation for in-depth guidance and troubleshooting steps.
  • If you continue facing difficulties, feel free to join our Discord server for community support.

For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.

Security and Audits

The Sablier V2 Core code has undergone thorough reviews by independent security experts, ensuring a robust security framework. If you have security-related concerns, please reference the SECURITY policy available in the repository.

License

Sablier V2 Core operates under the Business Source License 1.1, with additional licensing for specific files as detailed in the repository.

At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.

Stay Informed with the Newest F(x) Insights and Blogs

Tech News and Blog Highlights, Straight to Your Inbox