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

feat: dfx cycles top-up #3419

Merged
merged 17 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from 13 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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ This won't work on mainnet yet, but can work locally after installing the cycles

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

## Dependencies

Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

68 changes: 54 additions & 14 deletions docs/cli-reference/dfx-cycles.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,41 +73,81 @@ Use the `dfx cycles transfer` command to transfer cycles from your account to an
### 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.
You must specify the following arguments 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 |
|----------------------------------|--------------------------------------------------------------------|
| `--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. |
| `--memo <memo>` | Specifies a numeric memo for this transaction. |
| Option | Description |
|----------------------------------|----------------------------------------------------------------------------------------|
| `--to-subaccount <subaccount>` | The subaccount to which you want to transfer cycles. |
| `--from-subaccount <subaccount>` | The subaccount from which you want to transfer cycles. |
| `--memo <memo>` | Specifies a numeric memo for this transaction. Can only be passed in `--to-owner mode. |
ericswanson-dfinity marked this conversation as resolved.
Show resolved Hide resolved
| `--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

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
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there going to be support to specify the amount in a more human-readable format like 100B or 10T?

Copy link
Member Author

Choose a reason for hiding this comment

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

That's a great idea for a future improvement. I'll create a ticket.

Copy link
Member Author

Choose a reason for hiding this comment

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

```

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 arguments 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- |
ericswanson-dfinity marked this conversation as resolved.
Show resolved Hide resolved

### Examples

Send cycles to a canister in your project:

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

Send cycles to a canister by principal:

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