mirror of
https://github.com/fluencelabs/examples
synced 2024-12-04 19:20:17 +00:00
update readmes
This commit is contained in:
parent
e5f96c9948
commit
c98c838a2d
58
Readme.md
58
Readme.md
@ -1,60 +1,8 @@
|
||||
# Examples
|
||||
|
||||
This repo holds a collection of Fluence examples and tutorials across the entire Fluence stack. If you encounter any issues or have improvement suggestions, please raise them in Issues or create a PR.
|
||||
|
||||
### call_parameters
|
||||
|
||||
To Do:
|
||||
- [ ] Add documentation
|
||||
|
||||
### greeting
|
||||
Fluence's peer-to-peer analogy to "Hello World."
|
||||
|
||||
To Do:
|
||||
- [ ] Add documentation
|
||||
|
||||
### ipfs-node
|
||||
To Do:
|
||||
- [ ] Add documentation
|
||||
|
||||
### records
|
||||
|
||||
To Do:
|
||||
- [ ] Add documentation
|
||||
|
||||
### sqlite
|
||||
|
||||
To Do:
|
||||
- [ ] Add documentation
|
||||
|
||||
|
||||
### url-downloader
|
||||
|
||||
To Do:
|
||||
- [ ] Add Rust frontend
|
||||
|
||||
|
||||
### ether-price-getter
|
||||
ETH price getter as Fluence service from centralized CoinMarketCap.
|
||||
|
||||
### fluence-cuckoo
|
||||
Expose[Cuckoofilter](https://crates.io/crates/cuckoofilter) crate as a Fluence service.
|
||||
|
||||
To Do:
|
||||
- [x] Add documentation
|
||||
- [ ] Add Rust frontend
|
||||
|
||||
### web3-examples
|
||||
Illustrate Ethereum RPC calls as Fluence services.
|
||||
|
||||
To Do:
|
||||
- [x] Add documentation
|
||||
- [x] Add frontend
|
||||
|
||||
|
||||
## Contributing
|
||||
While the project is a still in the early stage of development, you are welcome to track progress and contribute. At the current moment we don't have detailed instructions on how to join development or which code guidelines to follow. However, you can expect more info to appear soon enough. In the meanwhile, check out the basic [contributing rules](https://github.com/fluencelabs/fluence/blob/master/CONTRIBUTING.md).
|
||||
|
||||
This repo holds a collection of examples on how to build distributed applications with the Fluence stack.
|
||||
If you encounter issues, please post an Issue or open a PR. If you want to contribute an example, please contact us by opening an Issue or a draft PR. See the [contribution rules](https://github.com/fluencelabs/fluence/blob/master/CONTRIBUTING.md).
|
||||
|
||||
## License
|
||||
|
||||
Unless otherwise indicated, the applicable license is [Apache 2.0](https://github.com/fluencelabs/fluence/blob/master/LICENSE).
|
@ -1,4 +1,113 @@
|
||||
# Title
|
||||
|
||||
This example illustrates how to use a greeting service as a consumer of upstream output(s) generated by an echo service.
|
||||
This example illustrates how to use a greeting service as a consumer of output(s) from an upstream service.
|
||||
|
||||
|
||||
Echo-Service
|
||||
peer service-id client-seed name
|
||||
12D3KooWFtf3rfCDAfWwt6oLZYZbDfn9Vn7bv7g6QjjQxUUEFVBt
|
||||
fb5f7126-e1ee-4ecf-81e7-20804cb7203b
|
||||
CXFpzXPC2WUpoME3jBX7F53dorK15bcux9Wmt52Geprn
|
||||
|
||||
12D3KooWJd3HaMJ1rpLY1kQvcjRPEvnDwcXrH8mJvk7ypcZXqXGE
|
||||
893a6fb8-43b9-4b11-8786-93300bd68bc8
|
||||
CUwsEyKop4rR8mwfGiu8qPZHCzAjKnA7LQGd1VFHAVgM
|
||||
|
||||
|
||||
Greeting-Service
|
||||
peer service-id client-seed name
|
||||
12D3KooWJd3HaMJ1rpLY1kQvcjRPEvnDwcXrH8mJvk7ypcZXqXGE
|
||||
5a03906b-3217-40a2-93fb-7e83be735408
|
||||
4X9p5vRWqS9rxgPop9C3p6fn1TpHGxRxTe9dga1NN77R
|
||||
|
||||
|
||||
12D3KooWFtf3rfCDAfWwt6oLZYZbDfn9Vn7bv7g6QjjQxUUEFVBt
|
||||
5cf520ff-dd65-47d7-a51a-2bf08dfe2ede
|
||||
2nypBDAGsxgft4TrQgBupJ3smoaRbkiYjC2MqTzSBRw1
|
||||
|
||||
|
||||
|
||||
Utilities-Service
|
||||
peer service-id client-seed name
|
||||
12D3KooWFtf3rfCDAfWwt6oLZYZbDfn9Vn7bv7g6QjjQxUUEFVBt
|
||||
abeaf9ef-c5c0-46ef-92eb-de605eb86ffd
|
||||
BvVwn1X36j5UGttGRdxQfJ1zFqMsAivLzXY6sdkbv2mx
|
||||
|
||||
12D3KooWJd3HaMJ1rpLY1kQvcjRPEvnDwcXrH8mJvk7ypcZXqXGE
|
||||
e23c2a8b-c3f2-4067-8e92-803691fdf5b7
|
||||
7SDxZerQxQCFjivromanTurV3UNj7Up4cdh9ZxXWwX5e
|
||||
|
||||
|
||||
|
||||
fldist run_air -p aqua-compiled/echo_greeter.echo_greeting_seq.air -d '{"names":["1", "2", "3"],"echo_service_id":"893a6fb8-43b9-4b11-8786-93300bd68bc8", "greeting_service_id":"5a03906b-3217-40a2-93fb-7e83be735408", "greet": false, "node":"12D3KooWJd3HaMJ1rpLY1kQvcjRPEvnDwcXrH8mJvk7ypcZXqXGE"}' --generated
|
||||
[
|
||||
[
|
||||
"Bye, 1",
|
||||
"Bye, 2",
|
||||
"Bye, 3"
|
||||
]
|
||||
]
|
||||
|
||||
|
||||
fldist run_air -p aqua-compiled/echo_greeter.echo_greeting_par.air -d '{"names": ["n1", "n2", "n3"], "greet": true, "echo_service":{"node":"12D3KooWFtf3rfCDAfWwt6oLZYZbDfn9Vn7bv7g6QjjQxUUEFVBt", "service_id":"fb5f7126-e1ee-4ecf-81e7-20804cb7203b"}, "greeting_services":[{"node":"12D3KooWJd3HaMJ1rpLY1kQvcjRPEvnDwcXrH8mJvk7ypcZXqXGE", "service_id":"5a03906b-3217-40a2-93fb-7e83be735408"},{"node":"12D3KooWFtf3rfCDAfWwt6oLZYZbDfn9Vn7bv7g6QjjQxUUEFVBt", "service_id":"5cf520ff-dd65-47d7-a51a-2bf08dfe2ede"}]}' --generated
|
||||
[
|
||||
[]
|
||||
]
|
||||
|
||||
fldist run_air -p aqua-compiled/echo_greeter.greeting.air -d '{"name":"boo", "node":"12D3KooWJd3HaMJ1rpLY1kQvcjRPEvnDwcXrH8mJvk7ypcZXqXGE", "greeting_service_id":"5a03906b-3217-40a2-93fb-7e83be735408", "greet":true}' --generated
|
||||
[
|
||||
"Hi, boo"
|
||||
]
|
||||
|
||||
|
||||
|
||||
|
||||
fldist run_air -p aqua-compiled/echo_greeter.echo_greeting_par.air -d '{"names": ["n1", "n2", "n3"], "greet": true, "echo_service":{"node":"12D3KooWFtf3rfCDAfWwt6oLZYZbDfn9Vn7bv7g6QjjQxUUEFVBt", "service_id":"fb5f7126-e1ee-4ecf-81e7-20804cb7203b"}, "greeting_services":[{"node":"12D3KooWJd3HaMJ1rpLY1kQvcjRPEvnDwcXrH8mJvk7ypcZXqXGE", "service_id":"5a03906b-3217-40a2-93fb-7e83be735408"},{"node":"12D3KooWFtf3rfCDAfWwt6oLZYZbDfn9Vn7bv7g6QjjQxUUEFVBt", "service_id":"5cf520ff-dd65-47d7-a51a-2bf08dfe2ede"}]}' --generated
|
||||
[
|
||||
[
|
||||
"Hi, n1",
|
||||
"Hi, n2",
|
||||
"Hi, n3",
|
||||
"Hi, n3"
|
||||
]
|
||||
]
|
||||
|
||||
|
||||
|
||||
|
||||
fldist --node-id 12D3KooWJd3HaMJ1rpLY1kQvcjRPEvnDwcXrH8mJvk7ypcZXqXGE run_air -p aqua-compiled/utilities.splitter.air -d '{"node":"12D3KooWJd3HaMJ1rpLY1kQvcjRPEvnDwcXrH8mJvk7ypcZXqXGE", "service_id":"e23c2a8b-c3f2-4067-8e92-803691fdf5b7", "array":[1,2,3,4,5,6,7,8,9], "chunk_size": 3 }' --generated
|
||||
[
|
||||
[
|
||||
[
|
||||
1,
|
||||
2,
|
||||
3
|
||||
],
|
||||
[
|
||||
4,
|
||||
5,
|
||||
6
|
||||
],
|
||||
[
|
||||
7,
|
||||
8,
|
||||
9
|
||||
]
|
||||
]
|
||||
]
|
||||
|
||||
|
||||
ldist --node-id 12D3KooWJd3HaMJ1rpLY1kQvcjRPEvnDwcXrH8mJvk7ypcZXqXGE run_air -p aqua-compiled/utilities.increment_u64.air -d '{"node":"12D3KooWJd3HaMJ1rpLY1kQvcjRPEvnDwcXrH8mJvk7ypcZXqXGE", "service_id":"e23c2a8b-c3f2-4067-8e92-803691fdf5b7", "value":10, "step":3, "incr": true}' --generated
|
||||
[
|
||||
{
|
||||
"err_msg": "",
|
||||
"value": 13
|
||||
}
|
||||
]
|
||||
mbp16~/localdev/examples-fork/echo-greeter/utilities(main↑1|✚3…) % fldist --node-id 12D3KooWJd3HaMJ1rpLY1kQvcjRPEvnDwcXrH8mJvk7ypcZXqXGE run_air -p aqua-compiled/utilities.increment_u64.air -d '{"node":"12D3KooWJd3HaMJ1rpLY1kQvcjRPEvnDwcXrH8mJvk7ypcZXqXGE", "service_id":"e23c2a8b-c3f2-4067-8e92-803691fdf5b7", "value":10, "step":3, "incr": false}' --generated
|
||||
[
|
||||
{
|
||||
"err_msg": "",
|
||||
"value": 7
|
||||
}
|
||||
]
|
@ -4,24 +4,25 @@
|
||||
|
||||
Getting accurate timestamps can be problematic in various contexts including blockchains. Timestamp oracles can alleviate this concern by aggregating and processing a variety of timestamp sources into a point- or range-estimate. Of course, the acquisition of accurate timestamps not subject to manipulation is a critical attribute of a good oracle. The Fluence peer-to-peer network offers a large number of independent nodes that can serve as timestamp sources from either Kademilia or TrustGraph neighborhoods.
|
||||
|
||||
**Note: The timestamps are currently NOT signed by the nodes. But that could be easily addressed.**
|
||||
**Note: The timestamps are currently** **not** **signed by the nodes. But that could be easily addressed.**
|
||||
|
||||
### Fluence Solution
|
||||
Fluence Labs provides an open Web3 protocol, framework and associated tooling to develop and host applications, interfaces and backends on permissionless peer-to-peer networks. An integral part of the Fluence solution is the Aquamarine stack comprised of Aqua and Marine.
|
||||
|
||||
Aqua is a new programming language and paradigm purpose-built to program distributed networks and compose applications from distributed services. For more information on Aqua, see
|
||||
Fluence provides an open Web3 protocol, framework and associated tooling to develop and host applications, interfaces and backends on permissionless peer-to-peer networks. An integral part of the Fluence solution is the Aquamarine stack comprised of Aqua and Marine. Aqua is a new programming language and paradigm purpose-built to program distributed networks and compose applications from distributed services. For more information on Aqua, see
|
||||
|
||||
* [Aqua Book](https://app.gitbook.com/@fluence/s/aqua-book/)
|
||||
* [Aqua Playground](https://github.com/fluencelabs/aqua-playground)
|
||||
* [Aqua repo](https://github.com/fluencelabs/aqua)
|
||||
|
||||
|
||||
Marine is a general purpose Wasm runtime and toolkit, allows developers to build distributed services that can be composed into applications by Aqua. For more information on Marine, see
|
||||
Marine is a general purpose Wasm runtime and toolkit, allows developers to build distributed services that can be composed into distributed applications by Aqua. For more information on Marine, see
|
||||
|
||||
* [Marine repo](https://github.com/fluencelabs/marine)
|
||||
* [Marine SDK](https://github.com/fluencelabs/marine-rs-sdk)
|
||||
|
||||
### Setup
|
||||
|
||||
*Please note that we already deployed the Rust service to node `12D3KooWHLxVhUQyAuZe6AHMB29P7wkvTNMn7eDMcsqimJYLKREf` with service id `ed657e45-0fe3-4d6c-b3a4-a2981b7cadb9`, which is all that's needed to use the service in Aqua.*
|
||||
*Note that we already deployed the service to node `12D3KooWHLxVhUQyAuZe6AHMB29P7wkvTNMn7eDMcsqimJYLKREf` with service id `ed657e45-0fe3-4d6c-b3a4-a2981b7cadb9`, which is all what's needed to use the service in Aqua.*
|
||||
|
||||
In order to run the entire code base, Rust and Node required. If necessary see [Install Rust](https://www.rust-lang.org/tools/install) and [NVM](https://github.com/nvm-sh/nvm) for details.
|
||||
|
||||
@ -82,7 +83,7 @@ We implemented a custom service that returns the mode and frequency for an array
|
||||
|
||||
Our oracle solution is implemented in Aqua and utilizes timestamps from peers selected from our Kademlia neighborhood and, for illustrative purposes, use the deployed service to arrive at the point estimate for our oracle. See `src/main.rs`. There certanly are better ways to process the timestamps into an oracle but for our purposes, mode works.
|
||||
|
||||
In our Aqua script, `aqua-scripts/ts_getter`, we separate the timestamp collections from the subsequent oracle processing. That is, if a peer-client wants to process the timestamps locally, all that's needed are the timestamps, which can be obtained by calling the `ts_getter` function. Alternatively, the timestamps may be processed by calling one or more `ts-oracle` services deployed to the network.
|
||||
In our Aqua script, `aqua-scripts/ts_getter.aqua`, we separate the timestamp collections from the subsequent oracle processing. That is, if a peer-client wants to process the timestamps locally, all that's needed are the timestamps, which can be obtained by calling the `ts_getter` function. Alternatively, the timestamps may be processed by calling one or more `ts-oracle` services deployed on the network.
|
||||
|
||||
```aqua
|
||||
-- aqua-scripts/ts_getter.aqua
|
||||
|
@ -1,13 +1,15 @@
|
||||
# Download file to disk
|
||||
|
||||
Example to show how to work with disk + link several .wasm modules into a service.
|
||||
Example that shows how to work with disk access and how to link several Wasm modules into a service.
|
||||
|
||||
# Build & deploy it
|
||||
|
||||
```shell
|
||||
./deploy.sh
|
||||
```
|
||||
|
||||
# Call it
|
||||
|
||||
```shell
|
||||
fldist run_air -p download.air -d '{"service": "f7db6966-2d75-4424-812e-85e2ec5cb61b"}'
|
||||
```
|
||||
|
Loading…
Reference in New Issue
Block a user