Giter VIP home page Giter VIP logo

sablier-sandbox's Introduction

Sablier V2 Sandbox

Sablier V2 Sandbox

Front-end sandbox development environments for Sablier V2.

Background

Sablier is a smart contract protocol that enables trustless streaming of ERC-20 assets, which means the ability to make payments by the second.

There are two types of streaming models in Sablier:

  • LockupLinear, abbreviated as LL, which creates streams with linear streaming functions
  • LockupDynamic, abbreviated as LD, which creates streams with dynamic streaming functions (examples: exponentials, logarithms, step functions)

For more information, please refer to our documentation.

It is worth noting that you can charge a service fee when creating a stream. This fee is a percentage of the stream's total value and is paid to your designated broker address. Check out the "broker" references in the code to see how this works, as well as this guide from our docs.

Environments and Examples

Sablier V2 Sandbox

Ethers V6

An integration of the Sablier V2 Core contracts into a frontend environment that uses Ethers V6. It's a small app that runs on the Goerli testnet and provides a wallet connection out of the box (Injected / Metamask).

Lockup Linear (Form) Lockup Dynamic (Form) Headless
LL LD H

Features

  • Create a LL stream with Durations using the UI Form
  • Create a LD stream with Deltas using the UI Form
  • Create a LL stream with Durations in headless mode (tweak durations in code)
  • Create a LL stream with Range in headless mode (tweak dates/ranges in code)
  • Create a LD stream with Deltas in headless mode (tweak deltas in code)
  • Create a LD stream with Milestones in headless mode (tweak milestones in code)
  • Mint testnet DAI tokens
  • Approve spending DAI tokens for both the LL and LD contracts

Most of the transaction magic happens in models/Transaction.ts. Have a look to understand how parameters are formatted (strings to Big Int, padding numbers with decimals, etc.) and sent to the contracts.

For the headless mode, see constants/data.ts. Here, you'll be able to tweak the parameters to create streams of different values or shapes (segments).

Next steps

In the UI Forms, you may find Prefill form buttons. Clicking on them will add pre-configured data into the fields as an example of what the data should look like.

After you create a test stream, make sure to connect to our main app.sablier.com interface with your "sender" wallet to see what the stream actually looks like.

Payload (LD with two segments) Shape
E E

Sablier V2 Sandbox

wagmi / viem

The official Sablier interface uses wagmi and viem. Both libraries offer top-notch support (check the docs and their github) and integrate nicely with things like RainbowKit.

Features

Same as the ones implemented in the Ethers V6 sandbox.

Opinionated Sandbox

This current sandbox uses wagmi's react context and configuration to set up the wallet connection (through an Injected Provider / Metamask). It then makes use of wagmi's core actions to bundle contract interactions under the Transaction model.

While this helps keep things similar to the way they're implemented in the Ethers V6 Sandbox, keep in mind that you can always choose to implement them differently. For example, using:

  • Viem, the Typescript library. It's pretty much a 1:1 replacement for ethers (see migration guide here). The aforementioned wagmi/actions (core actions) are more or less a wrapper around viem's utilities, with the additional benefit that the wallet and public clients are automatically sourced behind the scenes (you don't have to pass them manually).
  • Wagmi's hooks, for a more effect oriented React application

Work In Progress

The feat/permit2 branch includes an example of a create linear stream flow using:

  • Permit2 signatures
  • The PRB Proxy
  • A dedicated Sablier V2 Proxy Target

sablier-sandbox's People

Contributors

paulrberg avatar razgraf avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.