mirror of
https://github.com/fluencelabs/aqua-ipfs
synced 2025-03-15 05:00:50 +00:00
2.1 KiB
2.1 KiB
Aqua IPFS bindings
Native IPFS integration to Aqua language. Orchestrate IPFS file transfer with Aqua scripts.
Quick installation with @fluencelabs/cli
fluence dep npm i @fluencelabs/aqua-ipfs
Quick Aqua example
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
Documentation
Directory structure
aqua
Aqua API of AquaIPFS. See aqua/READMEservice
contains Rust service that implements all the IPFS calls by usingipfs
cli mounted binaryexample
A simple example of how to use ipfs adapter from TypeScriptlocal-network
contains Docker Compose YAML config to run a local Fluence network of 3 nodes
How to use it in TypeScript
There's a simple example in example
How to run it in MREPL
First, you would need to install mrepl via cargo install mrepl
After that, here's an example
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.
Contribution
Contributions are welcome!
aqua-ipfs
integrates with IPFS by using ipfs
CLI, so it's possible to expose virtually any IPFS API to Aqua. Feel free to open an issue or contribute APIs and patterns you find useful.