Diff
checker
文本
文本
图像
文档
Excel
文件夹
Legal
Enterprise
桌面版
定价
登录
下载 Diffchecker 桌面版
比较文本
查找两个文本文件之间的差异
工具
历史
实时编辑器
折叠未更改行
关闭换行
视图
拆分
统一
比对精度
智能
单词
字符
语法高亮
选择语法
忽略
文本转换
转到第一个差异
编辑输入
Diffchecker Desktop
运行Diffchecker最安全的方式。获取Diffchecker桌面应用:您的差异永远不会离开您的电脑!
获取桌面版
Lockup vs Flow docs
创建于
去年
差异永不过期
清除
导出
分享
解释
45 删除
行
总计
删除
字符
总计
删除
要继续使用此功能,请升级到
Diff
checker
Pro
查看价格
177 行
全部复制
41 添加
行
总计
添加
字符
总计
添加
要继续使用此功能,请升级到
Diff
checker
Pro
查看价格
175 行
全部复制
---
---
id: "local-environment"
id: "local-environment"
sidebar_position: 1
sidebar_position: 1
title: "Configure Your Local Environment"
title: "Configure Your Local Environment"
---
---
In this guide, we will go through the steps to set up a local development environment for building onchain integrations
In this guide, we will go through the steps to set up a local development environment for building onchain integrations
复制
已复制
复制
已复制
with
Lockup
. We will use Foundry to install
Lockup
as a dependency, and run a few simple tests.
with
Flow
. We will use Foundry to install
Flow
as a dependency, and run a few simple tests.
At the end, you’ll have a development environment set up that you can use to build the rest of the examples under
At the end, you’ll have a development environment set up that you can use to build the rest of the examples under
"Guides", or start your own integration project.
"Guides", or start your own integration project.
## Pre-requisites
## Pre-requisites
You will need the following software on your machine:
You will need the following software on your machine:
- [Git](https://git-scm.com/downloads)
- [Git](https://git-scm.com/downloads)
- [Foundry](https://github.com/foundry-rs/foundry)
- [Foundry](https://github.com/foundry-rs/foundry)
- [Node.js](https://nodejs.org/en/download)
- [Node.js](https://nodejs.org/en/download)
- [Bun](https://bun.sh)
- [Bun](https://bun.sh)
In addition, familiarity with [Ethereum](https://ethereum.org/) and [Solidity](https://soliditylang.org/) is requisite.
In addition, familiarity with [Ethereum](https://ethereum.org/) and [Solidity](https://soliditylang.org/) is requisite.
复制
已复制
复制
已复制
## Set up using
Lockup
integration template
## Set up using
Flow
integration template
We put together a template repository that you can use to get started quickly. This repository features a basic project
We put together a template repository that you can use to get started quickly. This repository features a basic project
复制
已复制
复制
已复制
structure, pre-configured
Lockup
imports, and a selection of sample contracts and tests.
structure, pre-configured
Flow
imports, and a selection of sample contracts and tests.
:::tip
:::tip
Make sure you are using the latest version of Foundry by running `foundryup`.
Make sure you are using the latest version of Foundry by running `foundryup`.
:::
:::
To install the template, simply execute the following commands:
To install the template, simply execute the following commands:
```shell
```shell
复制
已复制
复制
已复制
$ mkdir
lockup
-integration-template
$ mkdir
flow
-integration-template
$ cd
lockup
-integration-template
$ cd
flow
-integration-template
$ forge init --template sablier-labs/
lockup
-integration-template
$ forge init --template sablier-labs/
flow
-integration-template
$ bun install
$ bun install
```
```
复制
已复制
复制
已复制
Then, hop to the [Run a Fork Test](/guides/
lockup
/examples/local-environment#run-a-fork-test) section to complete your
Then, hop to the [Run a Fork Test](/guides/
flow
/examples/local-environment#run-a-fork-test) section to complete your
set
set
up and start developing.
up and start developing.
## Set up using Foundry template
## Set up using Foundry template
Foundry is a popular development toolkit for Ethereum projects, which we have used to build the Sablier Protocols. For
Foundry is a popular development toolkit for Ethereum projects, which we have used to build the Sablier Protocols. For
the purposes of this guide, Foundry will provide us with the tooling needed to compile and test our contracts.
the purposes of this guide, Foundry will provide us with the tooling needed to compile and test our contracts.
Let's use this command to spin up a new Foundry project:
Let's use this command to spin up a new Foundry project:
```shell
```shell
$ forge init my-project
$ forge init my-project
$ cd my-project
$ cd my-project
```
```
:::note
:::note
You might notice that the CLI is `forge` rather than `foundry`. This is because Foundry is a toolkit, and `forge` is
You might notice that the CLI is `forge` rather than `foundry`. This is because Foundry is a toolkit, and `forge` is
just one of the tools that comes with it.
just one of the tools that comes with it.
:::
:::
Once the initialization completes, take a look around at what got set up:
Once the initialization completes, take a look around at what got set up:
```tree
```tree
├── foundry.toml
├── foundry.toml
├── script
├── script
├── src
├── src
└── test
└── test
```
```
The folder structure should be intuitive:
The folder structure should be intuitive:
- `src` is where you'll write Solidity contracts
- `src` is where you'll write Solidity contracts
- `test` is where you'll write tests (also in Solidity)
- `test` is where you'll write tests (also in Solidity)
- `script` is where you'll write scripts to perform actions like deploying contracts (you guessed it, in Solidity)
- `script` is where you'll write scripts to perform actions like deploying contracts (you guessed it, in Solidity)
- `foundry.toml` is where you can configure your Foundry settings, which we will leave as is in this guide
- `foundry.toml` is where you can configure your Foundry settings, which we will leave as is in this guide
复制
已复制
复制
已复制
## Install
Lockup
npm package
s
## Install
Flow
npm package
复制
已复制
复制
已复制
Let's install the
Lockup
Node.js packages using Bun:
Let's install the
Flow
Node.js packages using Bun:
```shell
```shell
复制
已复制
复制
已复制
$ bun add @sablier/
v2-core @sablier/v2-periphery
$ bun add @sablier/
flow
```
```
复制
已复制
复制
已复制
Bun will download the
Lockup
contracts, along with their dependencies, and put them in the `node_modules` directory.
Bun will download the
Flow
contracts, along with their dependencies, and put them in the `node_modules` directory.
Let's remap the package names to point to the installed contracts. This step is required so that the Solidity compiler
Let's remap the package names to point to the installed contracts. This step is required so that the Solidity compiler
复制
已复制
复制
已复制
can find the
Lockup
contracts when you import them:
can find the
Flow
contracts when you import them:
```shell
```shell
复制
已复制
复制
已复制
$ echo "@sablier/
v2-core
=node_modules/@sablier/
v2-core/" >> remappings.txt
$ echo "@sablier/
flow
=node_modules/@sablier/
flow
/" >> remappings.txt
$ echo "@sablier/v2-periphery=node_modules/@sablier/v2-periphery
/" >> remappings.txt
$ echo "@openzeppelin/contracts/=node_modules/@openzeppelin/contracts/" >> remappings.txt
$ echo "@openzeppelin/contracts/=node_modules/@openzeppelin/contracts/" >> remappings.txt
$ echo "@prb/math/=node_modules/@prb/math/" >> remappings.txt
$ echo "@prb/math/=node_modules/@prb/math/" >> remappings.txt
```
```
复制
已复制
复制
已复制
That's it! You should now have a functional development environment to start building onchain
Lockup
integrations. Let's
That's it! You should now have a functional development environment to start building onchain
Flow
integrations. Let's
run a quick test to confirm everything is set up properly.
run a quick test to confirm everything is set up properly.
## Write your first contract
## Write your first contract
复制
已复制
复制
已复制
Delete the `src/Counter.sol` and `test/Counter.t.sol` files generated by Forge, and create
two
new file
s
:
Delete the `src/Counter.sol` and `test/Counter.t.sol` files generated by Forge, and create
a
new file
:
`src/
StreamCreator.
sol` and `test/StreamCreator.t.
sol`.
`src/
Flow
StreamCreator.
sol`.
复制
已复制
复制
已复制
Paste the following code into `src/
StreamCreator.sol`
(a detailed explanation of this contract can be found
Paste the following code into `src/
Flow
StreamCreator.sol`
.
[here](/guides/lockup/examples/create-stream/lockup-linear)):
复制
已复制
复制
已复制
```solidity reference title="
Lockup Linear
Stream Creator"
```solidity reference title="
Flow
Stream Creator"
https://github.com/sablier-labs/
examples
/blob/main/
lockup/core/LockupLinear
StreamCreator.sol
https://github.com/sablier-labs/
flow-integration-template
/blob/main/
src/Flow
StreamCreator.sol
```
```
Let's use Forge to compile this contract:
Let's use Forge to compile this contract:
```shell
```shell
$ forge build
$ forge build
```
```
If the contract was compiled correctly, you should see this message:
If the contract was compiled correctly, you should see this message:
```text
```text
[⠢] Compiling...
[⠢] Compiling...
[⠰] Compiling { number } files with { compiler }
[⠰] Compiling { number } files with { compiler }
[⠒] Solc { compiler } finished in { time }
[⠒] Solc { compiler } finished in { time }
Compiler run successful
Compiler run successful
```
```
:::info
:::info
复制
已复制
复制
已复制
The minimum Solidity version supported by the
Lockup
contracts is v0.8.
13
.
The minimum Solidity version supported by the
Flow
contracts is v0.8.
22
.
:::
:::
## Run a fork test
## Run a fork test
Foundry offers native support for running tests against a fork of Ethereum Mainnet, testnets and L2s, which is useful
Foundry offers native support for running tests against a fork of Ethereum Mainnet, testnets and L2s, which is useful
when building and testing integrations with onchain protocols like Sablier. In practice, this enables you to access all
when building and testing integrations with onchain protocols like Sablier. In practice, this enables you to access all
Sablier contracts deployed on Ethereum, and use them for testing your integration.
Sablier contracts deployed on Ethereum, and use them for testing your integration.
As a prerequisite, you will need an RPC that supports forking. A good solution for this is
As a prerequisite, you will need an RPC that supports forking. A good solution for this is
[Alchemy](https://alchemy.com/), as it includes forking in its free tier plan.
[Alchemy](https://alchemy.com/), as it includes forking in its free tier plan.
Once you have obtained your RPC, you can proceed to run the following test:
Once you have obtained your RPC, you can proceed to run the following test:
```solidity reference title="Stream Creator Test"
```solidity reference title="Stream Creator Test"
复制
已复制
复制
已复制
https://github.com/sablier-labs/
examples
/blob/main/
lockup/core/Lockup
StreamCreator.t.sol
https://github.com/sablier-labs/
flow-integration-template
/blob/main/
test/Flow
StreamCreator.t.sol
```
```
You can run the test using Forge:
You can run the test using Forge:
```shell
```shell
$ forge test
$ forge test
```
```
If the test passed, you should see a message like this:
If the test passed, you should see a message like this:
```text
```text
复制
已复制
复制
已复制
Ran 2 tests for
lockup/core/Lockup
StreamCreator.t.sol:
Lockup
StreamCreatorTest
Ran 2 tests for
test/Flow
StreamCreator.t.sol:
Flow
StreamCreatorTest
[PASS] test_
LockupDynamicStreamCreator
() (gas:
273719
)
[PASS] test_
CreateFlowStream
() (gas:
147915
)
[PASS] test_
LockupLinearStreamCreator
() (gas:
186388
)
[PASS] test_
CreateFlowStreamAndDeposit
() (gas:
224823
)
Suite result: ok. 2 passed; 0 failed; 0 skipped; finished in
6.34s (5.80s
CPU time)
Suite result: ok. 2 passed; 0 failed; 0 skipped; finished in
986.20ms (4.16ms
CPU time)
```
```
## Next steps
## Next steps
Congratulations! Your environment is now configured, and you are prepared to start building. Explore the guides section
Congratulations! Your environment is now configured, and you are prepared to start building. Explore the guides section
复制
已复制
复制
已复制
to discover various
Lockup
features available for integration. Remember to include all contracts (`.sol` files) in
the
to discover various
Flow
features available for integration. Remember to include all contracts (`.sol` files) in
`src` folder and their corresponding tests in the `test` folder.
the
`src` folder and their corresponding tests in the `test` folder.
As far as Foundry is concerned, there is much more to uncover. If you want to learn more about it, check out the
As far as Foundry is concerned, there is much more to uncover. If you want to learn more about it, check out the
[Foundry Book](https://book.getfoundry.sh/), which contains numerous examples and tutorials. A deep understanding of
[Foundry Book](https://book.getfoundry.sh/), which contains numerous examples and tutorials. A deep understanding of
复制
已复制
复制
已复制
Foundry will enable you to create more sophisticated integrations with
Lockup
.
Foundry will enable you to create more sophisticated integrations with
Flow
.
已保存差异
原始文本
打开文件
--- id: "local-environment" sidebar_position: 1 title: "Configure Your Local Environment" --- In this guide, we will go through the steps to set up a local development environment for building onchain integrations with Lockup. We will use Foundry to install Lockup as a dependency, and run a few simple tests. At the end, you’ll have a development environment set up that you can use to build the rest of the examples under "Guides", or start your own integration project. ## Pre-requisites You will need the following software on your machine: - [Git](https://git-scm.com/downloads) - [Foundry](https://github.com/foundry-rs/foundry) - [Node.js](https://nodejs.org/en/download) - [Bun](https://bun.sh) In addition, familiarity with [Ethereum](https://ethereum.org/) and [Solidity](https://soliditylang.org/) is requisite. ## Set up using Lockup integration template We put together a template repository that you can use to get started quickly. This repository features a basic project structure, pre-configured Lockup imports, and a selection of sample contracts and tests. :::tip Make sure you are using the latest version of Foundry by running `foundryup`. ::: To install the template, simply execute the following commands: ```shell $ mkdir lockup-integration-template $ cd lockup-integration-template $ forge init --template sablier-labs/lockup-integration-template $ bun install ``` Then, hop to the [Run a Fork Test](/guides/lockup/examples/local-environment#run-a-fork-test) section to complete your set up and start developing. ## Set up using Foundry template Foundry is a popular development toolkit for Ethereum projects, which we have used to build the Sablier Protocols. For the purposes of this guide, Foundry will provide us with the tooling needed to compile and test our contracts. Let's use this command to spin up a new Foundry project: ```shell $ forge init my-project $ cd my-project ``` :::note You might notice that the CLI is `forge` rather than `foundry`. This is because Foundry is a toolkit, and `forge` is just one of the tools that comes with it. ::: Once the initialization completes, take a look around at what got set up: ```tree ├── foundry.toml ├── script ├── src └── test ``` The folder structure should be intuitive: - `src` is where you'll write Solidity contracts - `test` is where you'll write tests (also in Solidity) - `script` is where you'll write scripts to perform actions like deploying contracts (you guessed it, in Solidity) - `foundry.toml` is where you can configure your Foundry settings, which we will leave as is in this guide ## Install Lockup npm packages Let's install the Lockup Node.js packages using Bun: ```shell $ bun add @sablier/v2-core @sablier/v2-periphery ``` Bun will download the Lockup contracts, along with their dependencies, and put them in the `node_modules` directory. Let's remap the package names to point to the installed contracts. This step is required so that the Solidity compiler can find the Lockup contracts when you import them: ```shell $ echo "@sablier/v2-core=node_modules/@sablier/v2-core/" >> remappings.txt $ echo "@sablier/v2-periphery=node_modules/@sablier/v2-periphery/" >> remappings.txt $ echo "@openzeppelin/contracts/=node_modules/@openzeppelin/contracts/" >> remappings.txt $ echo "@prb/math/=node_modules/@prb/math/" >> remappings.txt ``` That's it! You should now have a functional development environment to start building onchain Lockup integrations. Let's run a quick test to confirm everything is set up properly. ## Write your first contract Delete the `src/Counter.sol` and `test/Counter.t.sol` files generated by Forge, and create two new files: `src/StreamCreator.sol` and `test/StreamCreator.t.sol`. Paste the following code into `src/StreamCreator.sol` (a detailed explanation of this contract can be found [here](/guides/lockup/examples/create-stream/lockup-linear)): ```solidity reference title="Lockup Linear Stream Creator" https://github.com/sablier-labs/examples/blob/main/lockup/core/LockupLinearStreamCreator.sol ``` Let's use Forge to compile this contract: ```shell $ forge build ``` If the contract was compiled correctly, you should see this message: ```text [⠢] Compiling... [⠰] Compiling { number } files with { compiler } [⠒] Solc { compiler } finished in { time } Compiler run successful ``` :::info The minimum Solidity version supported by the Lockup contracts is v0.8.13. ::: ## Run a fork test Foundry offers native support for running tests against a fork of Ethereum Mainnet, testnets and L2s, which is useful when building and testing integrations with onchain protocols like Sablier. In practice, this enables you to access all Sablier contracts deployed on Ethereum, and use them for testing your integration. As a prerequisite, you will need an RPC that supports forking. A good solution for this is [Alchemy](https://alchemy.com/), as it includes forking in its free tier plan. Once you have obtained your RPC, you can proceed to run the following test: ```solidity reference title="Stream Creator Test" https://github.com/sablier-labs/examples/blob/main/lockup/core/LockupStreamCreator.t.sol ``` You can run the test using Forge: ```shell $ forge test ``` If the test passed, you should see a message like this: ```text Ran 2 tests for lockup/core/LockupStreamCreator.t.sol:LockupStreamCreatorTest [PASS] test_LockupDynamicStreamCreator() (gas: 273719) [PASS] test_LockupLinearStreamCreator() (gas: 186388) Suite result: ok. 2 passed; 0 failed; 0 skipped; finished in 6.34s (5.80s CPU time) ``` ## Next steps Congratulations! Your environment is now configured, and you are prepared to start building. Explore the guides section to discover various Lockup features available for integration. Remember to include all contracts (`.sol` files) in the `src` folder and their corresponding tests in the `test` folder. As far as Foundry is concerned, there is much more to uncover. If you want to learn more about it, check out the [Foundry Book](https://book.getfoundry.sh/), which contains numerous examples and tutorials. A deep understanding of Foundry will enable you to create more sophisticated integrations with Lockup.
更改后文本
打开文件
--- id: "local-environment" sidebar_position: 1 title: "Configure Your Local Environment" --- In this guide, we will go through the steps to set up a local development environment for building onchain integrations with Flow. We will use Foundry to install Flow as a dependency, and run a few simple tests. At the end, you’ll have a development environment set up that you can use to build the rest of the examples under "Guides", or start your own integration project. ## Pre-requisites You will need the following software on your machine: - [Git](https://git-scm.com/downloads) - [Foundry](https://github.com/foundry-rs/foundry) - [Node.js](https://nodejs.org/en/download) - [Bun](https://bun.sh) In addition, familiarity with [Ethereum](https://ethereum.org/) and [Solidity](https://soliditylang.org/) is requisite. ## Set up using Flow integration template We put together a template repository that you can use to get started quickly. This repository features a basic project structure, pre-configured Flow imports, and a selection of sample contracts and tests. :::tip Make sure you are using the latest version of Foundry by running `foundryup`. ::: To install the template, simply execute the following commands: ```shell $ mkdir flow-integration-template $ cd flow-integration-template $ forge init --template sablier-labs/flow-integration-template $ bun install ``` Then, hop to the [Run a Fork Test](/guides/flow/examples/local-environment#run-a-fork-test) section to complete your set up and start developing. ## Set up using Foundry template Foundry is a popular development toolkit for Ethereum projects, which we have used to build the Sablier Protocols. For the purposes of this guide, Foundry will provide us with the tooling needed to compile and test our contracts. Let's use this command to spin up a new Foundry project: ```shell $ forge init my-project $ cd my-project ``` :::note You might notice that the CLI is `forge` rather than `foundry`. This is because Foundry is a toolkit, and `forge` is just one of the tools that comes with it. ::: Once the initialization completes, take a look around at what got set up: ```tree ├── foundry.toml ├── script ├── src └── test ``` The folder structure should be intuitive: - `src` is where you'll write Solidity contracts - `test` is where you'll write tests (also in Solidity) - `script` is where you'll write scripts to perform actions like deploying contracts (you guessed it, in Solidity) - `foundry.toml` is where you can configure your Foundry settings, which we will leave as is in this guide ## Install Flow npm package Let's install the Flow Node.js packages using Bun: ```shell $ bun add @sablier/flow ``` Bun will download the Flow contracts, along with their dependencies, and put them in the `node_modules` directory. Let's remap the package names to point to the installed contracts. This step is required so that the Solidity compiler can find the Flow contracts when you import them: ```shell $ echo "@sablier/flow=node_modules/@sablier/flow/" >> remappings.txt $ echo "@openzeppelin/contracts/=node_modules/@openzeppelin/contracts/" >> remappings.txt $ echo "@prb/math/=node_modules/@prb/math/" >> remappings.txt ``` That's it! You should now have a functional development environment to start building onchain Flow integrations. Let's run a quick test to confirm everything is set up properly. ## Write your first contract Delete the `src/Counter.sol` and `test/Counter.t.sol` files generated by Forge, and create a new file: `src/FlowStreamCreator.sol`. Paste the following code into `src/FlowStreamCreator.sol`. ```solidity reference title="Flow Stream Creator" https://github.com/sablier-labs/flow-integration-template/blob/main/src/FlowStreamCreator.sol ``` Let's use Forge to compile this contract: ```shell $ forge build ``` If the contract was compiled correctly, you should see this message: ```text [⠢] Compiling... [⠰] Compiling { number } files with { compiler } [⠒] Solc { compiler } finished in { time } Compiler run successful ``` :::info The minimum Solidity version supported by the Flow contracts is v0.8.22. ::: ## Run a fork test Foundry offers native support for running tests against a fork of Ethereum Mainnet, testnets and L2s, which is useful when building and testing integrations with onchain protocols like Sablier. In practice, this enables you to access all Sablier contracts deployed on Ethereum, and use them for testing your integration. As a prerequisite, you will need an RPC that supports forking. A good solution for this is [Alchemy](https://alchemy.com/), as it includes forking in its free tier plan. Once you have obtained your RPC, you can proceed to run the following test: ```solidity reference title="Stream Creator Test" https://github.com/sablier-labs/flow-integration-template/blob/main/test/FlowStreamCreator.t.sol ``` You can run the test using Forge: ```shell $ forge test ``` If the test passed, you should see a message like this: ```text Ran 2 tests for test/FlowStreamCreator.t.sol:FlowStreamCreatorTest [PASS] test_CreateFlowStream() (gas: 147915) [PASS] test_CreateFlowStreamAndDeposit() (gas: 224823) Suite result: ok. 2 passed; 0 failed; 0 skipped; finished in 986.20ms (4.16ms CPU time) ``` ## Next steps Congratulations! Your environment is now configured, and you are prepared to start building. Explore the guides section to discover various Flow features available for integration. Remember to include all contracts (`.sol` files) in the`src` folder and their corresponding tests in the `test` folder. As far as Foundry is concerned, there is much more to uncover. If you want to learn more about it, check out the [Foundry Book](https://book.getfoundry.sh/), which contains numerous examples and tutorials. A deep understanding of Foundry will enable you to create more sophisticated integrations with Flow.
查找差异