Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,81 @@ You can create arbitrary aliases with the `alias` command. For example `aztec-wa

:::

## Paying Fees

import { Why_Fees, CLI_Fees } from '/components/snippets';

<Why_Fees />

Below are all the payment methods available to pay transaction fees on Aztec, starting with the simplest.

### Fee Paying Contract

Fee paying contracts specify their own criteria of payment in exchange for paying the fee juice of a transaction, e.g. an FPC
be written to accept some banana tokens to pay for another's transaction fee.
With an alias corresponding to the FPC's address this would be:

```bash
aztec-wallet <your transaction> --payment method=fpc,fpc-contract=contracts:bananaFPC
```

### Sponsored Fee Paying Contract

This is a special type of FPC that can be used to pay for account deployment and regular txs.
Eg: to create an account paid for by the sponsoredFPC:

```bash
aztec-wallet create-account -a main --payment method=fpc-sponsored,fpc=<fpc-address>
```

:::Note
In the sandbox, the sponsored FPC address is printed at the end of its initial logs.
:::

### Fee Juice from Sandbox Test accounts

In the sandbox pre-loaded test accounts can be used to cover fee juice when deploying contracts.

First import them:

#include_code import-test-accounts yarn-project/cli-wallet/test/flows/basic.sh bash
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how do I mint my own fee juice for new accounts?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explained in bridging section (which specifies --mint) parameter


Then use the alias (test0, test1...) when paying in fee juice. Eg to create accounts:

#include_code declare-accounts yarn-project/end-to-end/src/guides/up_quick_start.sh bash

### Mint and Bridge Fee Juice

#### On Sandbox

First register an account, mint the fee asset on L1 and bridge it to fee juice:

#include_code bridge-fee-juice yarn-project/cli-wallet/test/flows/create_account_pay_native.sh bash

You'll have to wait for two blocks to pass for bridged fee juice to be ready on Aztec.
For the sandbox you do this by putting through two arbitrary transactions. Eg:

#include_code force-two-blocks yarn-project/cli-wallet/test/flows/create_account_pay_native.sh bash

Now the funded account can deploy itself with the bridged fees, claiming the bridged fee juice and deploying the contract in one transaction:

#include_code claim-deploy-account yarn-project/cli-wallet/test/flows/create_account_pay_native.sh bash

#### Minting on Testnet

To mint the fee asset on L1, call the fee asset ERC20 token contract on the appropriate network.

```bash
cast call $FEE_ASSET_HANDLER_CONTRACT "mint(address)" $MY_L1_ADDRESS --rpc-url <RPC_URL>
```

With the fee asset on L1, call `bridge-fee-juice` to bridge it to Aztec, omitting the `--mint` flag, as described [here](../../reference/environment_reference/cli_reference.md#bridge-fee-juice).

## Account Management

The wallet comes with some options for account deployment and management. You can register and deploy accounts, or only register them, and pass different options to serve your workflow.

### create-account
### Create Account

Generates a secret key and deploys an account contract.

Expand Down Expand Up @@ -157,4 +227,5 @@ aztec-wallet bridge-fee-juice --mint 1000 master_yoda
```

## Proving

You can prove a transaction using the aztec-wallet with a running sandbox. Follow the guide [here](../../guides/local_env/sandbox_proving.md#proving-with-aztec-wallet)
2 changes: 2 additions & 0 deletions yarn-project/cli-wallet/test/flows/basic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ test_title "Basic flow"

AMOUNT=42

# docs:start:import-test-accounts
aztec-wallet import-test-accounts
# docs:end:import-test-accounts
aztec-wallet deploy token_contract@Token --args accounts:test0 Test TST 18 -f test0
aztec-wallet send mint_to_public -ca last --args accounts:test0 $AMOUNT -f test0
RESULT=$(aztec-wallet simulate balance_of_public -ca last --args accounts:test0 -f test0 | grep "Simulation result:" | awk '{print $3}')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,26 @@ source shared/setup.sh

test_title "Create an account and deploy using native fee payment with bridging"

# docs:start:bridge-fee-juice
aztec-wallet create-account -a main --register-only
aztec-wallet bridge-fee-juice 1000000000000000000 main --mint --no-wait
# docs:end:bridge-fee-juice


section "Use a pre-funded test account to send dummy txs to force block creations"

aztec-wallet import-test-accounts
# docs:start:force-two-blocks
aztec-wallet deploy counter_contract@Counter --init initialize --args 0 accounts:test0 -f test0 -a counter
aztec-wallet send increment -ca counter --args accounts:test0 accounts:test0 -f test0
# docs:end:force-two-blocks


section "Deploy main account claiming the fee juice, use it later"

# docs:start:claim-deploy-account
aztec-wallet deploy-account -f main --payment method=fee_juice,claim
# docs:end:claim-deploy-account
aztec-wallet send increment -ca counter --args accounts:main accounts:main -f main
aztec-wallet send increment -ca counter --args accounts:main accounts:main -f main

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ aztec-wallet bridge-fee-juice 1000000000000000000 $ALIAS --mint --no-wait
source $flows/shared/deploy_token.sh tmp-token-$ALIAS $ALIAS

# Deploying the account, paying the fee via bridging fee juice from L1 using the claim created above.
# docs:start:deploy-with-bridged-claim
aztec-wallet deploy-account -f $ALIAS --payment method=fee_juice,claim
# docs:end:deploy-with-bridged-claim
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ MINT_AMOUNT=42

source $flows/shared/deploy_sponsored_fpc_and_token.sh

# docs:start:fpc-sponsored
PAYMENT_METHOD="--payment method=fpc-sponsored,fpc=contracts:sponsoredFPC"
# docs:end:fpc-sponsored

aztec-wallet create-account -a user $PAYMENT_METHOD

Expand Down