This is a technical account on how to integrate Sablier into your own application. If you have questions, please join the #development channel in the Sablier Discord server; our team, and members of the community, look forward to helping you.
What we will cover:
Smart contract architecture and ABI
Networks and typical gas costs
How to create, withdraw from and cancel streams
How to create, withdraw from and cancel "compounding" streams
If you're looking for a high-level overview, you may want to read the FAQ first.
The Sablier protocol codebase is hosted on GitHub and the source code for each contract is verified on Etherscan.
We designed the protocol with simplicity in mind: one monolith smart contract that adheres to the ERC-1620 standard. In our web interfaces, we rely on a few other proxies, but we will not cover those here.
Depending on what web3 library you're using, you may need to get hold of the Sablier ABI (Application Binary Interface). The ABI acts as an interface between two program modules, one of which is the smart contract and the other the machine code.
There are two ways to obtain it:
Copy Sablier.json
from sablierhq/sablier-abis
Clone sablierhq/sablier and compile the contract yourself
Here's an example for how to do step 2 with yarn and truffle:
$ git clone git@github.com/sablierhq/sablier.git$ cd ./sablier$ yarn run bootstrap$ cd ./packages/protocol$ truffle compile
The Sablier.json
artifact should be in the relative build/contracts
folder.
Depending on what Ethereum network you want to use Sablier with, you will need a specific contract address.
Network | Address |
Mainnet | 0xA4fc358455Febe425536fd1878bE67FfDBDEC59a |
Goerli | 0x590b3974533141a44a89033deEcf932F52fcFDea |
Kovan | 0xc04Ad234E01327b24a831e3718DBFcbE245904CC |
Rinkeby | 0xc04Ad234E01327b24a831e3718DBFcbE245904CC |
Ropsten | 0xc04Ad234E01327b24a831e3718DBFcbE245904CC |
If you want to use the Sablier Interface on a testnet, you need to get some Testnet DAI first. Read these instructions on Twitter for how to get some.
The gas usage of the Sablier protocol is not deterministic and varies by user. Calls to third-party contracts, such as ERC-20 tokens, may use an arbitrary amount of gas. We provide the table below for guidance:
Action | Typical Gas Cost |
Create Stream | <250K |
Withdraw from Stream | <90K |
Cancel Stream | <120K |
Create "Compounding" Stream | <475K |
Withdraw from "Compounding" Stream | <280K |
Cancel "Compounding" Stream | <200K |
Our blockchain data can be accessed via our subgraphs, which require you to use a GraphQL client. We recommend Apollo.
If you want to see some example queries, see sablierhq/sablier-subgraph.
Network | Link |
Mainnet | |
Goerli | |
Kovan | |
Rinkeby | |
Ropsten |