Skip to content

Commit

Permalink
format, update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ericswanson-dfinity committed Oct 17, 2023
1 parent 14b3e55 commit b022e49
Show file tree
Hide file tree
Showing 6 changed files with 371 additions and 339 deletions.
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ The message "transaction is a duplicate of another transaction in block ...", pr

This won't work on mainnet yet, but can work locally after installing the cycles ledger.

Added the following subcommands and variants:
Added the following subcommands:
- `dfx cycles balance`
- `dfx cycles transfer --to-owner <principal>` (transfer from one account to another account)
- `dfx cycles transfer --top-up <principal>` (transfer from an account to a canister)
- `dfx cycles transfer <to> <amount>` (transfer from one account to another account)
- `dfx cycles top-up <to> <amount>` (transfer from an account to a canister)

## Dependencies

Expand Down
62 changes: 45 additions & 17 deletions docs/cli-reference/dfx-cycles.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,37 +70,29 @@ dfx cycles balance --owner raxcz-bidhr-evrzj-qyivt-nht5a-eltcc-24qfc-o6cvi-hfw7j

Use the `dfx cycles transfer` command to transfer cycles from your account to another account.

The source of the transferred cycles is always the cycles ledger account associated with your identity's principal, or one of its subaccounts.

The destination of the transferred cycles is one of the following:
- A cycles ledger account associated with another identity's principal, or one of its subaccounts. This mode uses the `--to-owner` and `--to-subaccount` options.
- A canister. This mode uses the `--top-up` option.

### Basic usage

``` bash
dfx cycles transfer [options] <amount>
dfx cycles transfer [options] <to> <amount>
```

### Arguments

You must specify the following argument for the `dfx cycles transfer` command.

| Argument | Description |
|--------------|-----------------------------------|
| `<amount>` | The number of cycles to transfer. |
| Argument | Description |
|------------|-----------------------------------|
| `<to>` | The principal of the account to which you want to transfer cycles. |
| `<amount>` | The number of cycles to transfer. |

### Options

You can specify the following options for the `dfx cycles transfer` command.

| Option | Description |
|----------------------------------|----------------------------------------------------------------------------------------|
| `--top-up <principal>` | The canister which you want to top up. |
| `--to-owner <principal>` | The principal of the account to which you want to transfer cycles. |
| `--to-subaccount <subaccount>` | The subaccount to which you want to transfer cycles. |
| `--from-subaccount <subaccount>` | The subaccount from which you want to transfer cycles. |
| `--fee <fee>` | Specifies a transaction fee. Can only passed in `--to-owner` mode. |
| `--memo <memo>` | Specifies a numeric memo for this transaction. Can only be passed in `--to-owner mode. |
| `--created-at-time <timestamp>` | Specify the timestamp-nanoseconds for the `created_at_time` field on the transfer request. Useful for controlling transaction-de-duplication. https://internetcomputer.org/docs/current/developer-docs/integrations/icrc-1/#transaction-deduplication- |

Expand All @@ -109,17 +101,53 @@ You can specify the following options for the `dfx cycles transfer` command.
Transfer 1 billion cycles to another account:

``` bash
dfx cycles transfer 1000000000 --to-owner raxcz-bidhr-evrzj-qyivt-nht5a-eltcc-24qfc-o6cvi-hfw7j-dcecz-kae --network ic
dfx cycles transfer raxcz-bidhr-evrzj-qyivt-nht5a-eltcc-24qfc-o6cvi-hfw7j-dcecz-kae 1000000000 --network ic
```

Transfer from a subaccount:

``` bash
dfx cycles transfer 1000000000 --from-subaccount 000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f --to-owner raxcz-bidhr-evrzj-qyivt-nht5a-eltcc-24qfc-o6cvi-hfw7j-dcecz-kae --network ic
dfx cycles transfer raxcz-bidhr-evrzj-qyivt-nht5a-eltcc-24qfc-o6cvi-hfw7j-dcecz-kae 1000000000 --from-subaccount 000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f --network ic
```

## dfx cycles top-up

Use the `dfx cycles top-up` command to send cycles from your account to a canister.

### Basic usage

``` bash
dfx cycles top-up [options] <to> <amount>
```

### Arguments

You must specify the following argument for the `dfx cycles transfer` command.

| Argument | Description |
|------------|-------------------------------------------------------------------------|
| `<to>` | The name of a canister in the current project, or a canister principal. |
| `<amount>` | The number of cycles to transfer. |

### Options

You can specify the following options for the `dfx cycles top-up` command.

| Option | Description |
|----------------------------------|----------------------------------------------------------------------------------------|
| `--from-subaccount <subaccount>` | The subaccount from which you want to transfer cycles. |
| `--created-at-time <timestamp>` | Specify the timestamp-nanoseconds for the `created_at_time` field on the transfer request. Useful for controlling transaction-de-duplication. https://internetcomputer.org/docs/current/developer-docs/integrations/icrc-1/#transaction-deduplication- |

### Examples

Send cycles to a canister in your project:

``` bash
dfx cycles top-up my_backend 1000000000 --network ic
```

Transfer to (top up) a canister:
Send cycles to a canister by principal:

``` bash
dfx cycles transfer 1000000000 --top-up bkyz2-fmaaa-aaaaa-qaaaq-cai --network ic
dfx cycles top-up bkyz2-fmaaa-aaaaa-qaaaq-cai 1000000000 --network ic
```
Loading

0 comments on commit b022e49

Please sign in to comment.