Aqua CLI
Aqua CLI allows you to manage all aspects of Aqua development and includes:
  • Compiler
  • Client Peer
  • Utilities
To install the Aqua CLI package:
1
npm install -g @fluencelabs/aqua
Copied!

Compiler

The compiler turns high-level Aqua code into either JS/TS handlers wrapping AIR, the default, or pure AIR.
The quickest way to compile Aqua code is to take all .aqua files from the specified input directory, e.g., src/aqua, and place the generated JavaScript code in some output directory of your choosing, e.g. src/generated. Please note that if the specified output directory does not exist, the CLI creates it for you:
1
aqua --input src/aqua --output src/generated
Copied!
Of course, we can be more specific and name a filename:
1
aqua --input src/aqua/some_file.aqua --output src/generated
Copied!
As mentioned in the intro, the Aqua compiler generates .js with .d.ts TypeScript files by default. Output files will contain functions exported from .aqua files and methods for registering defined services. You can read more about calling functions and service registration in the FluenceJS documentation.
Additional compiler options are:
  • --js flag, which generates only .js files
  • --air or -a flag, which generates pure AIR code
  • --scheduled, which generates AIR code suitable for [script storage](add link)
Use aqua --help for a complete listing of available flags, subcommands and explanations.

Subcommands

The CLI provides additional features and utilities via subcommands.

Aqua Run

The aqua run command creates a one-shot client peer over the compiled Aqua code specified allowing you to quickly and effectively test Aqua code against deployed services on the network.
1
aqua run --input <your aqua filepath> --func '<function name>(<args>)'
Copied!
For the following Aqua script:
1
-- some-dir/hello.aqua
2
service Hello("service_id"):
3
hello(name:string) -> string
4
5
func hello(name: string, node:string, sid: string) -> string:
6
on node:
7
Hello sid
8
res <- Hello.hello(name)
9
<- res
Copied!
We instantiate our aqua client peer:
1
aqua run --input some-dir/hello.aqua --func 'hello("reader", "peer id", "service id")'
Copied!
The aqua run command provides additional features such as:
  • --sk or -s , which allows you to provide your secret key (sk) in base64
  • --addr or -a , which allows you to specify a relay in multiaddr format, e.g., /dns4/kras-04.fluence.dev/tcp/19001/wss/p2p/12D3KooWFEwNWcHqi9rtsmDhsYcDbRUCDXH84RC4FW6UfsFWaoHi
  • --import or -m, which allows you to import functionality from one or more source folders by using the flag repeatedly
  • --data or -d, which allows you to specify data arguments as a json map:
    1
    aqua run --input my_code.aqua --func 'my_aqua_func(a, b)' --data '{"a": "some_string", "b": 123}'
    Copied!
  • --data-path or p, which allows you to specify data arguments, see --data, as a file. Note that --data and --data-path are mutually exclusive
Use aqua run --help for a complete listing of available flags and explanations.

Aqua Create Keypair

The aqua create_keypair utility allows you to create an ed25519-based keypair in base64:
1
aqua create_keypair
Copied!
And produces the following json document:
1
{
2
"peerId": "12D3KooWMC6picJQNruwFMFWqP62FWLtbM94TGYEzCsthsKa46CQ",
3
"secretKey": "QG3Ot2i1kD4Mpw0RpsKtUjbA/0XjZ0WP7dajDBwLQi0=",
4
"publicKey": "CAESIKkB+6eYhFDsEZhn0u+xwIKVhE+1xvgJoV5/csc+CS6R"
5
}
Copied!
Last modified 1mo ago
Copy link