Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: CLI docs #2336

Merged
merged 3 commits into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions yarn-project/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -308,12 +308,12 @@ aztec-cli get-account 0x123456789abcdef123456789abcdef12345678

### send

Calls a function on an Aztec contract.
Sends a transaction invoking a function on an Aztec contract.

Syntax:

```shell
aztec-cli call-fn <contractAbi> <contractAddress> <functionName> [functionArgs...] [options]
aztec-cli send <functionName> --args [functionArgs...] --contract-abi <contractAbi> --contract-address <contractAddress> --private-key <senderPrivateKey>
```

- `functionName`: Name of the function to call.
Expand All @@ -334,14 +334,15 @@ Example usage:
aztec-cli send transfer -ca 0x123456789abcdef123456789abcdef12345678 -a 100 -c path/to/abi.json
```

### view-fn
### call

Simulates the execution of a view (read-only) function on a deployed contract, without modifying state.
Calls a view (read-only) function on a deployed contract.
Unlike transactions, view calls do not modify the state of the contract.

Syntax:

```shell
aztec-cli call <contractAbi> <contractAddress> <functionName> [functionArgs...] [options]
aztec-cli call <functionName> -a [functionArgs...] -c <contractAbi> -ca <contractAddress> -f <fromAddress>
```

- `functionName`: Name of the function to view.
Expand All @@ -351,7 +352,7 @@ Options:
- `'-a, --args [functionArgs...]` (optional): Function arguments. Default: [].
- `-c, --contract-abi <fileLocation>`: The compiled contract's ABI in JSON format. You can also use one of Aztec's example contracts found in (@aztec/noir-contracts)[https://www.npmjs.com/package/@aztec/noir-contracts], e.g. PrivateTokenContractAbi.
- `-ca, --contract-address <address>`: Address of the contract.
- `-f, --from <string>`: Public key of the transaction viewer. If empty, it will try to find an account in the RPC.
- `-f, --from <string>`: Address of the caller. If empty, first account in the Aztec RPC Server will be used.
- `-u, --rpc-url <string>`: URL of the Aztec RPC. Default: `http://localhost:8080`.

This command simulates the execution of a view function on a deployed contract without modifying the state. It requires the contract's ABI, address, function name, and optionally, function arguments. The command displays the result of the view function.
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ export function getProgram(log: LogFn, debugLogger: DebugLogger): Command {
"A compiled Aztec.nr contract's ABI in JSON format or name of a contract ABI exported by @aztec/noir-contracts",
)
.requiredOption('-ca, --contract-address <address>', 'Aztec address of the contract.')
.option('-f, --from <string>', 'Public key of the TX viewer. If empty, will try to find account in RPC.')
.option('-f, --from <string>', 'Aztec address of the caller. If empty, will use the first account from RPC.')
.option('-u, --rpc-url <string>', 'URL of the Aztec RPC', AZTEC_RPC_HOST || 'http://localhost:8080')
.action(async (functionName, options) => {
const { contractAddress, functionArgs, contractAbi } = await prepTx(
Expand Down