Development
The Graph
Integrate
To integrate the Sablier subgraphs or indexers into your project, start from the official @sablier/subgraphs
repository. We recommend using:
- GraphQL Code Generator to create types from your GraphQL fragments and queries.
- TanStack Query to fetch results from the exposed endpoints.
Contribute
To contribute to the V2 subgraphs or deploy your own, head over to the GitHub
subgraphs
repository. Get started by reviewing the apps/lockup
directory.
To bootstrap a subgraph project, run the following commands. They will install the requisite dependencies and generate the code for a Sepolia deployment.
cd ./apps/lockup
yarn install
yarn setup:sepolia
To deploy a new subgraph on Sepolia:
- Create a new item using The Graph's hosted network
- Add its name/endpoint under the
deploy:sepolia
script inpackage.json
- Add your own Sablier contract addresses in
../constants/chains/sepolia.ts
- Make sure you're authenticated on your local machine
- Run
yarn deploy:sepolia
You can read more about how the The Graph works in their official docs.
To publish on the hosted service:
-
Authenticate with the hosted service credentials
graph auth --product hosted-service <ACCESS_TOKEN>
-
Generate configuration
Run
yarn deploy:<chain_name>
to generate imports, configurations and deploy in the same script.
Envio
Integrate
To integrate the Sablier indexers into your own product, start from the official @sablier/subgraphs
repository. We
recommend using:
- GraphQL Code Generator to create types from your GraphQL fragments and queries
- TanStack Query to fetch results from the exposed endpoints.
If you're integrated the Sablier subgraphs, we recommend using request and response wrappers/middleware to format results coming from Envio's indexer in the same shape as those from The Graph. Suggestions:
- Write queries in both systems (based on the querying language specifics) using the
same
operationName
and swap query strings between vendors based on it - Write response middleware that converts results into similar shapes (see these important notes)
Test
To ensure Envio indexers deliver the same data as The Graph's subgraphs, we've written differential tests for our indexer configurations.
Check them out inside the apps/[...]/test/
folders.
Run
The differentials tests are powered by Jest. Inside test/setup/constants.ts
, you will find the full configuration for
these tests. This is where you'll also be able to toggle between using the local endpoint (see
development to bootstrap a project locally) and the hosted-service one, using the REMOTE
flag.
pnpm run test
As the set of streams or campaigns grows, the final tests (full coverage over the entire list of elements) may time out. We suggest either splitting them in chunks or setting a manual limit to the number of iterations the loop can cover at once. Alternatively, you could also try increasing the timeout of the tests.
Contribute
To contribute to the V2 indexers (Envio x Sablier) or deploy your own, head over to the GitHub
subgraphs
repository. Get started by reviewing the apps/lockup-envio
directory.
To bootstrap an indexer project, run the following commands. They will install the requisite dependencies and generate the code for a multi-chain deployment.
cd ./apps/lockup-envio
pnpm install
pnpm run setup
# OR
pnpm dev
A local Hasura process will be started at http://localhost:8080
,which will also include a GraphQL
endpoint to query
locally. To deploy without hosting yourself, have a look at the Envio
Hosted Service docs.
Prior to starting the Envio
process (pnpm dev
) please make sure your Docker app is running. For installation see the
official docs at https://docs.envio.dev/.
Sablier SDK: Merkle API
Integrate
To integrate the Sablier Merkle API into your own product, start from the official @sablier/merkle-api
repository. We
recommend using:
Contribute
To contribute to the V2 Merkle API or deploy your own, head over to the GitHub
merkle-api
repository. Get started by reviewing the controllers
directory.
Run an instance
Locally
In order to make the API work properly, you will need to create a .env
file by following the .env.example
file:
PINATA_ACCESS_TOKEN=
PINATA_API_KEY=
PINATA_API_SERVER=
PINATA_SECRET_API_KEY=
IPFS_GATEWAY=
After a campaign is created via the API, we use Pinata to upload and pin the file to IPFS. In order to obtain the
PINATA_API_KEY
, PINATA_SECRET_API_KEY
and PINATA_ACCESS_TOKEN
, follow these steps:
- Sign up or log in on https://app.pinata.cloud/
- Select the API Keys tab
- Select New Key
- The key should have the permissions
pinFileToIPFS
andpinJSONToIPFS
- Set a name for the key
- Click Create Key
- From the popup, take the API Key and the API Secret and put them in the
.env
file. TheIPFS_GATEWAY
variable can be any IPFS gateway but we recommend using a private one (Pinata offers this as well). For more details about the interactions with IPFS, checksrc/services/ipfs.rs
. - Select the "Access Controls" tab
- Click on the "Request Token" button
- Copy the token and put in th
.env
file in thePINATA_ACCESS_TOKEN
variable
Simulate the cloud environment by finally running:
cargo run --bin sablier_merkle_api
This command will run a standard web API and expose it on port 3000 on localhost.
Vercel
We use Vercel for hosting, and this is why we have separate binaries for each endpoint. For local development, use this command:
vercel dev
This command will run a standard web API and expose it on port 3000 on localhost.
If you wish to deploy your backend to vercel, check the official
Github Actions workflow
for deploying. Rust is supported through Vercel's rust runtime
.