Skip to content

Commit adb8fb2

Browse files
authored
Merge branch 'main' into meta-tag
2 parents a678d9f + 1eb7f36 commit adb8fb2

11 files changed

+1154
-10
lines changed

docs/fassets/developer-guides/1-fassets-asset-manager-settings-node.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
2-
title: Get FAssets Lot Size (Node)
2+
title: Read FAssets Settings (Node)
33
tags: [intermediate, fassets]
44
slug: fassets-settings-node
55
description: Fetch FAsset Lot Size and Value in USD (via FTSO) using Node.js
66
keywords: [fassets, ftso, oracle, flare-time-series-oracle, flare-network, node]
7-
sidebar_position: 1
7+
sidebar_position: 3
88
---
99

1010
import ExploringAdditionalParameters from "./_exploring-additional-parameters.mdx";

docs/fassets/developer-guides/2-fassets-asset-manager-settings-solidity.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
2-
title: Get FAssets Lot Size (Solidity)
2+
title: Read FAssets Settings (Solidity)
33
tags: [intermediate, fassets]
44
slug: fassets-settings-solidity
55
description: Fetch FAsset Lot Size and Value in USD (via FTSO) from a smart contract
66
keywords: [fassets, ftso, oracle, flare-time-series-oracle, flare-network, node]
7-
sidebar_position: 2
7+
sidebar_position: 4
88
---
99

1010
import CodeBlock from "@theme/CodeBlock";

docs/fassets/developer-guides/3-fassets-minting.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ tags: [intermediate, fassets]
44
slug: fassets-mint
55
description: Learn how to mint FAssets
66
keywords: [fassets, flare-network]
7-
sidebar_position: 3
7+
sidebar_position: 1
88
---
99

1010
import CodeBlock from "@theme/CodeBlock";

docs/fassets/developer-guides/4-fassets-redeem.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ tags: [intermediate, fassets]
44
slug: fassets-redeem
55
description: Learn how to redeem FAssets
66
keywords: [fassets, flare-network]
7-
sidebar_position: 4
7+
sidebar_position: 2
88
---
99

1010
import CodeBlock from "@theme/CodeBlock";
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
title: IAssetManagerController
3+
description: FAssets IAssetManagerController interface reference.
4+
keywords: [fassets, xrp, bitcoin, dogecoin, flare-network]
5+
sidebar_position: 2
6+
---
7+
8+
Command line reference for interacting with the FAssets `AssetManagerController` contract.
9+
10+
Sourced from `IAssetManagerController.sol` on [GitHub](https://github.com/flare-foundation/fassets/blob/main/contracts/userInterfaces/IAssetManagerController.sol).
11+
12+
## Functions
13+
14+
### `getAssetManagers`
15+
16+
Returns the list of all asset managers managed by this controller.
17+
To interact with the asset manager, follow [IAssetManager](/fassets/reference/IAssetManager) reference.
18+
19+
```solidity
20+
function getAssetManagers()
21+
external view
22+
returns (IAssetManager[] memory);
23+
```
24+
25+
### `assetManagerExists`
26+
27+
Check if the asset manager is managed by this asset manager controller.
28+
29+
Parameters:
30+
31+
- `_assetManager`: Address of the asset manager
32+
33+
Returns:
34+
35+
- `bool`: `true` if the asset manager is managed by this controller, `false` otherwise.
36+
37+
```solidity
38+
function assetManagerExists(address _assetManager)
39+
external view
40+
returns (bool);
41+
```

docs/fassets/reference/IAssetManagerEvents.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: IAssetManagerEvents
33
description: FAssets IAssetManager interface reference.
44
keywords: [fassets, xrp, bitcoin, dogecoin, flare-network]
5-
sidebar_position: 2
5+
sidebar_position: 3
66
---
77

88
`IAssetManagerEvents` is an interface that defines the events emitted by the [`IAssetManager`](/fassets/reference/IAssetManager) contract.

docs/fassets/reference/ICoreVaultManager.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: ICoreVaultManager
33
description: FAssets ICoreVaultManager interface reference.
44
keywords: [fassets, xrp, bitcoin, dogecoin, flare-network]
5-
sidebar_position: 3
5+
sidebar_position: 4
66
---
77

88
Command line reference for managing and interacting with FAssets `ICoreVaultSettings`.

docs/fassets/reference/ICoreVaultSettings.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: ICoreVaultSettings
33
description: FAssets IAssetManager interface reference.
44
keywords: [fassets, xrp, bitcoin, dogecoin, flare-network]
5-
sidebar_position: 4
5+
sidebar_position: 5
66
---
77

88
Command line reference for managing and interacting with FAssets `ICoreVaultSettings`.

docs/fdc/guides/foundry/json-api.mdx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,15 @@ description: Retrieve arbitrary Web2 data.
55
tags: [intermediate, ethereum, fdc, foundry]
66
keywords: [ethereum, flare-data-connector, evm, flare-network]
77
sidebar_position: 8
8-
unlisted: false
8+
unlisted: true
99
---
1010

11+
:::danger
12+
Since May 2025 this guide is considered deprecated.
13+
The `JsonApi` attestation type has been update to a new version, `Web2Json`.
14+
You can find the updated version of this guide [here](/fdc/guides/foundry/web-2-json).
15+
:::
16+
1117
The `JsonApi` attestation type enables data collection from an arbitrary Web2 source.
1218
You can learn more about it in the official [specification repo](/fdc/attestation-types/json-api).
1319

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
---
2+
title: Web2Json for Custom API
3+
authors: [nikerzetic, filipkoprivec]
4+
description: Retrieve arbitrary Web2 data.
5+
tags: [intermediate, ethereum, fdc, hardhat]
6+
keywords: [ethereum, flare-data-connector, evm, flare-network]
7+
sidebar_position: 12
8+
---
9+
10+
The [Web2Json guide](/fdc/guides/foundry/web-2-json) demonstrates how the Flare Data Connector can be used to fetch Web2 and store it on the chain.
11+
The code for this and other examples is available within the [Flare Hardhat starter](https://github.com/flare-foundation/flare-foundry-starter) repository.
12+
In this guide, we will see how the `Web2Json` example script within the Flare Hardhat starter can be modified to work with custom data and custom contracts.
13+
That way, the example code can serve as the base building block for a custom project.
14+
15+
## Necessary modifications
16+
17+
In order to run on custom data, the example code needs to be modified in four places only.
18+
Those are:
19+
20+
1. The contract within the `src/fdcExample/Web2Json.sol` file.
21+
2. The attestation request parameters at the top of the `script/fdcExample/Web2Json.s.sol`.
22+
In particular the parameters:
23+
24+
- `apiUrl`
25+
- `postProcessJq`
26+
- `abiSignature`
27+
28+
3. The `DeployContract` script within the `script/fdcExample/Web2Json.s.sol` file.
29+
4. The `InteractWithContract` function within the `script/fdcExample/Web2Json.s.sol` file.
30+
31+
## Contract
32+
33+
The contract within the `src/fdcExample/Web2Json.sol` file should be changed to reflect the project goals.
34+
It could be omitted entirely and replaced with multiple files.
35+
The only requirement is that at least one contract - the one interacting with FDC - implements a function that accepts an `IWeb2Json.Proof` struct parameter.
36+
37+
## Attestation request parameters
38+
39+
```solidity title="script/fdcExample/Web2Json.s.sol"
40+
// Setting request data
41+
string public apiUrl = "https://swapi.info/api/people/3";
42+
string public httpMethod = "GET";
43+
string public headers = '{\\"Content-Type\\":\\"text/plain\\"}';
44+
string public queryParams = "{}";
45+
string public body = "{}";
46+
string public postProcessJq =
47+
'{name: .name, height: .height, mass: .mass, numberOfFilms: .films | length, uid: (.url | split(\\"/\\") | .[-1] | tonumber)}';
48+
string public abiSignature =
49+
'{\\"components\\": [{\\"internalType\\": \\"string\\", \\"name\\": \\"name\\", \\"type\\": \\"string\\"},{\\"internalType\\": \\"uint256\\", \\"name\\": \\"height\\", \\"type\\": \\"uint256\\"},{\\"internalType\\": \\"uint256\\", \\"name\\": \\"mass\\", \\"type\\": \\"uint256\\"},{\\"internalType\\": \\"uint256\\", \\"name\\": \\"numberOfFilms\\", \\"type\\": \\"uint256\\"},{\\"internalType\\": \\"uint256\\", \\"name\\": \\"uid\\", \\"type\\": \\"uint256\\"}],\\"name\\": \\"task\\",\\"type\\": \\"tuple\\"}';
50+
```
51+
52+
The attestation request parameters should describe the new Web2 source.
53+
54+
The `apiUrl` is the URL of the API.
55+
It can additionally be configured with the `headers`, `queryParams`, and `body` fields.
56+
A different `httpMethod` can also be selected.
57+
58+
The `postProcessJq` is the jq-filter that will be applied to the JSON data retrieved from the `apiUrl` API.
59+
It rearranges and modifies the input JSON into a new JSON.
60+
The `postProcessJq` filter can be workshopped using an online tool, like [The JQ Playground](https://play.jqlang.org).
61+
62+
The `abiSignature` parameter determines how the modified JSON should be represented in Solidity.
63+
It is the ABI signature of an appropriate struct.
64+
65+
The easiest way to acquire it is to create a `DataTransportObject` struct with the correct fields within some solidity file.
66+
Then, create a public dummy function that accepts a `DataTransportObject` parameter.
67+
After running `yarn hardhat compile` or `npx hardhat compile`, the contract artifact will be created within the `artifacts/contracts` directory.
68+
The dummy function can be searched for within the file of its parent contract, and the `abiSignature` read from its `inputs` field.
69+
70+
## Deploy script
71+
72+
```solidity title="script/fdcExample/Web2Json.s.sol"
73+
contract DeployContract is Script {
74+
function run() external {
75+
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
76+
vm.startBroadcast(deployerPrivateKey);
77+
78+
StarWarsCharacterList characterList = new StarWarsCharacterList();
79+
address _address = address(characterList);
80+
81+
vm.stopBroadcast();
82+
83+
Base.writeToFile(
84+
dirPath,
85+
string.concat(attestationTypeName, "_address"),
86+
StringsBase.toHexString(abi.encodePacked(_address)),
87+
true
88+
);
89+
}
90+
}
91+
```
92+
93+
The `DeployContract` script should be modified to deploy and verify the new contract.
94+
If the contract is deployed and verified by another script, and thus the script will only interact with an existing contract, the script can be omitted.
95+
96+
## Interact with contract script
97+
98+
```solidity title="script/fdcExample/Web2Json.s.sol"
99+
contract InteractWithContract is Script {
100+
function run() external {
101+
string memory addressString = vm.readLine(
102+
string.concat(dirPath, attestationTypeName, "_address", ".txt")
103+
);
104+
address _address = vm.parseAddress(addressString);
105+
string memory proofString = vm.readLine(
106+
string.concat(dirPath, attestationTypeName, "_proof", ".txt")
107+
);
108+
bytes memory proofBytes = vm.parseBytes(proofString);
109+
IWeb2Json.Proof memory proof = abi.decode(
110+
proofBytes,
111+
(IWeb2Json.Proof)
112+
);
113+
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
114+
vm.startBroadcast(deployerPrivateKey);
115+
IStarWarsCharacterList characterList = IStarWarsCharacterList(_address);
116+
characterList.addCharacter(proof);
117+
vm.stopBroadcast();
118+
}
119+
}
120+
```
121+
122+
The `InteractWithContract` script should be modified to interact with the new contract.
123+
Unless the dApp requires a more intricate interaction with the new contract, only the last few lines should be fundamentally changed.
124+
Likely, only the parameter type and the contract functions called should change.

0 commit comments

Comments
 (0)