b6054cc05b
* Do not update in nox-distro * Update renovate |
||
---|---|---|
.cargo | ||
.github | ||
aqua | ||
aqua-tests | ||
builtin-package | ||
example | ||
local-network | ||
service | ||
.gitignore | ||
CHANGELOG.md | ||
CONTRIBUTING.md | ||
LICENSE | ||
README.md | ||
rust-toolchain.toml |
Aqua IPFS bindings
Aqua-ipfs is a native IPFS integration to Aqua language. It lets one call the API of an IPFS daemon, e.g., to transfer files between peers & services or to orchestrate IPFS nodes.
Quick Installation and Usage
First, make sure you have Fluence CLI installed. After this, installation is as simple as:
fluence dep npm i @fluencelabs/aqua-ipfs
Next, run:
import "@fluencelabs/aqua-ipfs/ipfs-api.aqua"
import "@fluencelabs/aqua-lib/builtin.aqua"
const PERIOD_SEC = 10
func install_scheduled_script_from_ipfs_to_peer(from: PeerId, to: PeerId, cid: string) -> ?string:
script_id: ?string
ipfs_maddr <- get_external_api_multiaddr(from)
if ipfs_maddr.success:
get <- get_from(to, cid, ipfs_maddr.multiaddr)
if get.success:
script_id <- Script.add_from_vault(get.path, ?[PERIOD_SEC])
<- script_id
To run it in Marine REPL (mrepl), one needs to install mrepl
via cargo install mrepl
first. After that:
cd service
mrepl
new Config.toml
call ipfs_pure set_local_api_multiaddr ["/ip4/134.209.186.43/tcp/5001/p2p/12D3KooWEhCqQ9NBnmtSfNeXSNfhgccmH86xodkCUxZNEXab6pkw"]
call ipfs_pure set_external_api_multiaddr ["/ip4/134.209.186.43/tcp/5001/p2p/12D3KooWEhCqQ9NBnmtSfNeXSNfhgccmH86xodkCUxZNEXab6pkw"]
call ipfs_pure get_from ["QmfBRabun4FpaHV4wVXtnqtopUTro93XJHiWhNZscViCaq", "/ip4/134.209.186.43/tcp/5001/p2p/12D3KooWEhCqQ9NBnmtSfNeXSNfhgccmH86xodkCUxZNEXab6pkw"]
You can use interface
and help
inside mrepl
to further discover what's possible.
A simple example of using aqua-ipfs
in TypeScript is available here.
Documentation
Comprehensive documentation including API and usage examples can be found in Aqua Book.
Repository Structure
- aqua is Aqua API of Aqua-ipfs. See its README for details.
- builtin-package Files necessary to use Aqua-ipfs on peers
- example A simple example of how to use IPFS adapter from TypeScript
- local-network contains Docker Compose YAML config to run a local Fluence network of 3 nodes
- service contains Rust service that implements all IPFS calls by using
ipfs
CLI mounted binary
Support
Please, file an issue if you find a bug. You can also contact us at Discord or Telegram. We will do our best to resolve the issue ASAP.
Contributing
Any interested person is welcome to contribute to the project. Please, make sure you read and follow some basic rules.
License
All software code is copyright (c) Fluence Labs, Inc. under the Apache-2.0 license.