aqua-ipfs/README.md

35 lines
1.4 KiB
Markdown
Raw Normal View History

# Aqua IPFS bindings
Native IPFS integration to Aqua language. Orchestrate IPFS file transfer with Aqua scripts.
## How to use it in TypeScript
1. Add the following to your dependencies
- `@fluencelabs/aqua-ipfs`
- `@fluencelabs/fluence`
- `@fluencelabs/fluence-network-environment`
2021-07-26 12:14:39 +03:00
2. Import and call
```typescript
2021-07-26 12:14:39 +03:00
import { get_and_cache } from '@fluencelabs/aqua-ipfs';
import { createClient } from "@fluencelabs/fluence";
import { krasnodar } from "@fluencelabs/fluence-network-environment";
2021-07-26 12:14:39 +03:00
// connect to the Fluence network
const fluence = await createClient(krasnodar[1]);
2021-07-26 12:14:39 +03:00
// get some file's or dir's IPFS CID
let cid = "Qm...";
2021-07-26 12:14:39 +03:00
let ipfsMultiaddr = "/ip4/x.x.x.x/tcp/5001/"
// And cache it on the IPFS node running along the Fluence node we've connected to
let path = await get_and_cache(fluence, fluence.relayPeerId, cid, ipfs, { ttl: 10000 });
```
2021-07-21 20:19:13 +03:00
## Directory structure
- `aqua` Aqua API of IPFS-adapter, go to its [README](/aqua/README.md)
2021-07-21 20:19:13 +03:00
- `service` contains Rust service that implements all the IPFS calls by using `ipfs` cli mounted binary
- `example` A simple example of how to use ipfs adapter from TypeScript
2021-07-21 20:19:13 +03:00
- `local-network` contains Docker Compose YAML config to run a local Fluence network of 3 nodes
# Contribution
Contributions are welcome!
`ipfs-adapter` 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.