Add quick installation and example

This commit is contained in:
folex 2022-10-20 15:47:43 +04:00 committed by GitHub
parent e0a8abc1ac
commit fb00b33b68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,8 +1,33 @@
# Aqua IPFS bindings # Aqua IPFS bindings
Native IPFS integration to Aqua language. Orchestrate IPFS file transfer with Aqua scripts. 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 ## Documentation
See [Aqua Book](https://fluence.dev/aqua-book/libraries/aqua-ipfs). See [aqua-ipfs in Aqua Book](https://fluence.dev/docs/aqua-book/libraries/aqua-ipfs).
## How to use it in TypeScript ## How to use it in TypeScript
There's a simple example in [example](/example/index.ts) There's a simple example in [example](/example/index.ts)