|
1 | | -# Flare periphery package for smart contract development |
| 1 | +# Flare periphery package for Foundry |
2 | 2 |
|
3 | | -This package contains a collection of smart contracts deployed on the **Flare**, Coston2 (test network for Flare), **Songbird** and Coston (test network for Songbird) networks. |
| 3 | +This package contains a collection of smart contract interfaces deployed on the **Flare**, Coston2 (test network for Flare), **Songbird** and Coston (test network for Songbird) networks. |
4 | 4 |
|
5 | 5 | The intention of this package is to provide a set of **interfaces** for easier integration and development of smart contracts on Flare based networks. |
6 | | -Interfaces in the most recent version of this package are the same as the ones deployed on the networks. This package exposes all public and most of the internal interfaces but **does not** expose any of the implementations. If you want to access the implementations, you can use the official [flare smart contracts repo](https://gitlab.com/flarenetwork/flare-smart-contracts). |
| 6 | +Interfaces in the most recent version of this package are the same as the ones deployed on the networks. This package exposes all public and most of the internal interfaces but **does not** expose any of the implementations. If you want to access the implementations, you can use the official [Flare smart contracts repo](https://github.com/flare-foundation/flare-smart-contracts-v2). |
7 | 7 |
|
8 | | -The package functions similar to openzeppelin library packages and can easily be imported in `nodejs` based projects as well as directly in remix IDE. |
| 8 | +Basic familiarity with the Flare network and EVM is assumed for use. For more information, please refer to the [Flare Developer Hub](https://dev.flare.network/). For a guided introduction to smart contract development on Flare, see [Getting Started with Flare](https://dev.flare.network/network/getting-started). |
9 | 9 |
|
10 | | -Basic familiarity with the Flare network and EVM is assumed for use. For more information, please refer to the [Flare documentation](https://docs.flare.network/). If you want a guided tutorial on EVM development and Flare focused smart contract development with this package, please refer to the [Flare developer blogpost series](https://medium.com/@j0-0sko/setting-up-the-environment-3c9f20dcac7c). |
| 10 | +## Installation |
| 11 | + |
| 12 | +Install the package using Forge Soldeer: |
| 13 | + |
| 14 | +```sh |
| 15 | +forge soldeer install flare-periphery~<version> |
| 16 | +``` |
| 17 | + |
| 18 | +This will add the package to your `soldeer.lock` and make it available for import under the `flare-periphery/` prefix. |
11 | 19 |
|
12 | 20 | ## Package structure |
13 | 21 |
|
14 | | -Each of the networks has its own folder and subfolders for interfaces of specific flare based technologies. The folder structure is as follows: |
| 22 | +Each network has its own folder inside `src/`. All interfaces are placed flat within the respective network folder. |
15 | 23 |
|
16 | 24 | ``` |
| 25 | +src/ |
17 | 26 | ├── coston |
18 | | -│ ├── distribution |
19 | | -│ ├── ftso |
20 | | -│ ├── governance |
21 | | -│ ├── inflation |
22 | | -│ ├── mockContracts |
23 | | -│ ├── stateConnector |
24 | | -│ └── util-contracts |
25 | 27 | ├── coston2 |
26 | | -│ ├── distribution |
27 | | -│ ├── ftso |
28 | | -│ ├── governance |
29 | | -│ ├── mockContracts |
30 | | -│ ├── stateConnector |
31 | | -│ └── util-contracts |
32 | | -├── examples |
33 | | -│ ├── coston |
34 | | -│ ├── coston2 |
35 | | -│ ├── flare |
36 | | -│ └── songbird |
37 | 28 | ├── flare |
38 | | -│ ├── distribution |
39 | | -│ ├── ftso |
40 | | -│ ├── governance |
41 | | -│ ├── mockContracts |
42 | | -│ ├── stateConnector |
43 | | -│ └── util-contracts |
44 | 29 | └── songbird |
45 | | - ├── distribution |
46 | | - ├── ftso |
47 | | - ├── governance |
48 | | - ├── inflation |
49 | | - ├── mockContracts |
50 | | - ├── stateConnector |
51 | | - └── util-contracts |
52 | 30 | ``` |
53 | 31 |
|
| 32 | +> **Note:** The `coston2` folder also includes Smart Accounts interfaces. |
| 33 | +
|
54 | 34 | ## Example usages |
55 | 35 |
|
56 | | -### I want to use the FTSO prices in my contract |
| 36 | +### Using FTSO v2 feeds in your contract |
| 37 | + |
| 38 | +To read FTSO v2 feed data on Flare, import `IFtsoV2` and the relay interfaces: |
57 | 39 |
|
58 | | -You should use `IFtsoRegistry` (or `IIFtsoRegistry`) for simple price queries or |
59 | | -`IFtso` (or `IIFtso`) for more advanced queries. |
60 | | -The `IFtsoRegistry` interface is available in |
61 | | -`contracts/userInterfaces/IFtsoRegistry.sol` and the |
62 | | -`IFtso` interface is available in `contracts/userInterfaces/IFtso.sol`. |
| 40 | +```solidity |
| 41 | +import { IFtsoV2 } from "flare-periphery/src/flare/IFtsoV2.sol"; |
| 42 | +import { IRelay } from "flare-periphery/src/flare/IRelay.sol"; |
| 43 | +``` |
63 | 44 |
|
64 | | -To use the interfaces deployed on `Flare` network, just import them in your contract source: |
| 45 | +For Coston2 (testnet): |
65 | 46 |
|
66 | 47 | ```solidity |
67 | | -import { IPriceSubmitter } from "@flarenetwork/flare-periphery-contracts/flare/ftso/userInterfaces/IPriceSubmitter.sol"; |
68 | | -import { IFtsoRegistry } from "@flarenetwork/flare-periphery-contracts/flare/ftso/userInterfaces/IFtsoRegistry.sol"; |
| 48 | +import { IFtsoV2 } from "flare-periphery/src/coston2/IFtsoV2.sol"; |
69 | 49 | ``` |
70 | 50 |
|
71 | | -If you are using Foundry, you can install the interfaces with Forge and import them in your contract source: |
| 51 | +### Using the Flare Data Connector (FDC) |
| 52 | + |
| 53 | +To verify attestations using the FDC: |
72 | 54 |
|
73 | 55 | ```solidity |
74 | | -import { IPriceSubmitter } from "flare-periphery-contracts/flare/ftso/userInterfaces/IPriceSubmitter.sol"; |
75 | | -import { IFtsoRegistry } from "flare-periphery-contracts/flare/ftso/userInterfaces/IFtsoRegistry.sol"; |
| 56 | +import { IFdcHub } from "flare-periphery/src/flare/IFdcHub.sol"; |
| 57 | +import { IFdcVerification } from "flare-periphery/src/flare/IFdcVerification.sol"; |
76 | 58 | ``` |
77 | 59 |
|
78 | | -Very simple contract that can consume the FTSO prices is shown in `examples/networkName/SimpleFtsoExample.sol`. |
| 60 | +### Using FAssets interfaces |
| 61 | + |
| 62 | +FAsset interfaces are available on all networks: |
79 | 63 |
|
80 | | -An example usage of the FTSO system to dynamically price token in a contract is showcased in |
81 | | -`examples/network/DynamicToken.sol` with a more detailed explanation in the [blogpost](https://medium.com/@j0-0sko/taking-it-up-to-11-74dd91c39c2b). |
| 64 | +```solidity |
| 65 | +import { IAssetManager } from "flare-periphery/src/flare/IAssetManager.sol"; |
| 66 | +import { IFAsset } from "flare-periphery/src/flare/IFAsset.sol"; |
| 67 | +``` |
82 | 68 |
|
83 | | -### I want to confirm something using the attestation client |
| 69 | +### Using the ContractRegistry |
84 | 70 |
|
85 | | -Coming soon. |
| 71 | +Each network folder includes a generated `ContractRegistry` Solidity library with on-chain addresses for all registered contracts: |
| 72 | + |
| 73 | +```solidity |
| 74 | +import { ContractRegistry } from "flare-periphery/src/flare/ContractRegistry.sol"; |
| 75 | +``` |
86 | 76 |
|
87 | 77 | ------ |
88 | 78 |
|
89 | | -**You've got the tools, turn on your imagination and go, go and build something awesome** |
| 79 | +**You've got the tools, turn on your imagination and go build something awesome!** |
90 | 80 |
|
91 | | -If you find any mistake or have any suggestions, please open an issue or contact us are directly. |
| 81 | +If you find any mistakes or have suggestions, please open an issue or contact us directly. |
92 | 82 |
|
93 | 83 | **Package is provided as is, without any warranty.** |
0 commit comments