Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit 5fa6d2a

Browse files
Add burn/destroy/melt commands (#101)
* Add burn/destroy/melt commands * Clean readme * Order and add examples * Update example values * Update documentation/docs/03_account.md Co-authored-by: Thibault Martinez <[email protected]> * Update documentation/docs/03_account.md Co-authored-by: Thibault Martinez <[email protected]> * Reverse log for consistency Co-authored-by: Thibault Martinez <[email protected]>
1 parent 5ed3125 commit 5fa6d2a

File tree

6 files changed

+214
-116
lines changed

6 files changed

+214
-116
lines changed

README.md

Lines changed: 1 addition & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -35,96 +35,7 @@ Alternatively, you can select an existing account by it's alias, to use with the
3535

3636
## Commands
3737

38-
The wallet CLI has a set of main commands accesible with `./wallet COMMAND [ARGS]` and a dedicated command list for the account prompt.
39-
40-
### Main commands
41-
42-
#### help [COMMAND]
43-
44-
Prints the CLI help information. If a command is specified, the command's help will be printed.
45-
46-
#### init [NODE, MNEMONIC]
47-
48-
Initialize the wallet with a mnemonic, if none is provided, a new one will be generated.
49-
50-
#### new [ALIAS]
51-
52-
Creates a new account, optionally takes an account alias.
53-
54-
#### account ALIAS
55-
56-
Selects the account associated with the specified alias.
57-
58-
#### set-node NODE
59-
60-
Set the node url to be used.
61-
```
62-
./wallet set-node "http://localhost:14265"
63-
```
64-
65-
#### sync
66-
67-
Synchronizes all accounts with the Tangle.
68-
69-
70-
### Account prompt commands
71-
72-
#### help [COMMAND]
73-
74-
Prints the CLI help information. If a command is specified, the command's help will be printed.
75-
76-
#### exit
77-
78-
Exits the account prompt.
79-
80-
#### sync
81-
82-
Synchronizes the account with the Tangle and returns the balance.
83-
84-
#### address
85-
86-
Generates a new unused address.
87-
88-
#### balance
89-
90-
Gets the account balance.
91-
92-
#### faucet [URL]
93-
94-
Request funds from the faucet to the latest address, `url` is optional, default is `http://localhost:8091/api/enqueue`.
95-
96-
#### list-addresses
97-
98-
Lists the account's addresses.
99-
100-
#### list-transactions
101-
102-
Lists the account's transactions.
103-
104-
#### mint-native-token SUPPLY [FOUNDRY METADATA]
105-
106-
Mint a native token: `mint-native-token 100 "0x..."`
107-
108-
#### mint-nft [ADDRESS, IMMUTABLEMETADATA, METADATA]
109-
110-
Mint an nft to an optional bech32 encoded address: `mint-nft atoi1qpszqzadsym6wpppd6z037dvlejmjuke7s24hm95s9fg9vpua7vluehe53e "immutable-metadata" "metadata"`
111-
112-
#### send ADDRESS AMOUNT
113-
114-
Send funds from the account to the given Bech32 address.
115-
Example: `send atoi1qpszqzadsym6wpppd6z037dvlejmjuke7s24hm95s9fg9vpua7vluehe53e 1000000`
116-
117-
#### send-micro ADDRESS AMOUNT
118-
119-
Send an amount below the storage deposit minimum to a bech32 address: `send-micro atoi1qpszqzadsym6wpppd6z037dvlejmjuke7s24hm95s9fg9vpua7vluehe53e 10`
120-
121-
#### send-native ADDRESS TOKEN_ID AMOUNT
122-
123-
Send native tokens to a bech32 address: `send-native atoi1qpszqzadsym6wpppd6z037dvlejmjuke7s24hm95s9fg9vpua7vluehe53e 08e3a2f76cc934bc0cc21575b4610c1d7d4eb589ae0100000000000000000000000000000000 10`
124-
125-
#### send-nft ADDRESS NFT_ID
126-
127-
Send an nft to a bech32 encoded address: `send-nft atoi1qpszqzadsym6wpppd6z037dvlejmjuke7s24hm95s9fg9vpua7vluehe53e 0x0f9d4ddb128e97af0eb05b960e84e6e6659868da`
38+
To see the full list of available commands look at the documentation [here](./documentation/docs).
12839

12940
## Caveats
13041

documentation/docs/03_account.md

Lines changed: 89 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,41 @@ Prints the account balance.
2727
> Account "main": balance
2828
```
2929

30+
### `burn-native-token`
31+
32+
Burns a native token.
33+
34+
#### Parameters
35+
36+
| Name | Optional | Default | Example |
37+
| ---------- | --------- | ------- | -------------------------------------------------------------------------------- |
38+
| `token_id` || N/A | "0x08860e1f3593ba86c597cf86f61d8b04d8a714c02c7c5da7132d45be9c2ce6445c0300000000" |
39+
| `amount` || N/A | 100 |
40+
41+
#### Example
42+
43+
Burn the provided amount of a native token.
44+
```sh
45+
> Account "main": burn-native-token 0x08860e1f3593ba86c597cf86f61d8b04d8a714c02c7c5da7132d45be9c2ce6445c0300000000 100
46+
```
47+
48+
### `burn-nft`
49+
50+
Burns an NFT.
51+
52+
#### Parameters
53+
54+
| Name | Optional | Default | Example |
55+
| -------- | --------- | ------- | -------------------------------------------------------------------- |
56+
| `nft_id` || N/A | "0x397ae8552dcf0dc604a44c9d86a5005d09f95d67e2965ea3b1c1271f9a9ae44c" |
57+
58+
#### Example
59+
60+
Burn a provided NFT.
61+
```sh
62+
> Account "main": burn-nft 0x397ae8552dcf0dc604a44c9d86a5005d09f95d67e2965ea3b1c1271f9a9ae44c
63+
```
64+
3065
### `claim`
3166

3267
Tries to claim outputs with storage deposit return, expiration or timelock unlock conditions.
@@ -59,6 +94,38 @@ Note that only Basic Outputs with only an address unlock condition can be consol
5994
> Account "main": consolidate
6095
```
6196

97+
### `destroy-alias`
98+
99+
Destroys an alias.
100+
101+
#### Parameters
102+
103+
| Name | Optional | Default | Example |
104+
| ---------- | --------- | ------- | -------------------------------------------------------------------- |
105+
| `alias_id` || N/A | "0xb2bcba092bfb3fe3a12afcf21115016b27d833a7c456404fe2fe0921799f24dd" |
106+
107+
#### Example
108+
109+
```sh
110+
> Account "main": destroy-alias 0xb2bcba092bfb3fe3a12afcf21115016b27d833a7c456404fe2fe0921799f24dd
111+
```
112+
113+
### `destroy-foundry`
114+
115+
Destroys a foundry.
116+
117+
#### Parameters
118+
119+
| Name | Optional | Default | Example |
120+
| ------------ | --------- | ------- | -------------------------------------------------------------------------------- |
121+
| `foundry_id` || N/A | "0x08b2bcba092bfb3fe3a12afcf21115016b27d833a7c456404fe2fe0921799f24dd0100000000" |
122+
123+
#### Example
124+
125+
```sh
126+
> Account "main": destroy-foundry 0x08b2bcba092bfb3fe3a12afcf21115016b27d833a7c456404fe2fe0921799f24dd0100000000
127+
```
128+
62129
### `exit`
63130

64131
Exits the `cli-wallet`.
@@ -102,6 +169,24 @@ Displays the account interface usage.
102169
> Account "main": help
103170
```
104171

172+
### `melt-native-token`
173+
174+
Melt a native token.
175+
176+
#### Parameters
177+
178+
| Name | Optional | Default | Example |
179+
| ---------- | --------- | ------- | -------------------------------------------------------------------------------- |
180+
| `token_id` || N/A | "0x08860e1f3593ba86c597cf86f61d8b04d8a714c02c7c5da7132d45be9c2ce6445c0300000000" |
181+
| `amount` || N/A | 100 |
182+
183+
#### Example
184+
185+
Melt the provided amount of a native token.
186+
```sh
187+
> Account "main": melt-native-token 0x08860e1f3593ba86c597cf86f61d8b04d8a714c02c7c5da7132d45be9c2ce6445c0300000000 100
188+
```
189+
105190
### `mint-native-token`
106191

107192
Mints a native token.
@@ -137,17 +222,17 @@ Mint a native token with a maximum supply and foundry metadata.
137222

138223
#### Examples
139224

140-
Mint a NFT to the latest address of the account.
225+
Mint an NFT to the latest address of the account.
141226
```sh
142227
> Account "main": mint-nft
143228
```
144229

145-
Mint a NFT to a given address.
230+
Mint an NFT to a given address.
146231
```sh
147232
> Account "main": mint-nft "rms1qztwng6cty8cfm42nzvq099ev7udhrnk0rw8jt8vttf9kpqnxhpsx869vr3"
148233
```
149234

150-
Mint a NFT to a given address with immutable metadata and metadata.
235+
Mint an NFT to a given address with immutable metadata and metadata.
151236
```sh
152237
> Account "main": mint-nft "rms1qztwng6cty8cfm42nzvq099ev7udhrnk0rw8jt8vttf9kpqnxhpsx869vr3" "{ key: value }" "{ key: value }"
153238
```
@@ -216,7 +301,7 @@ Sends native tokens to an address with StorageDepositReturn and Expiration Unloc
216301

217302
### `send-nft`
218303

219-
Sends a NFT to an address.
304+
Sends an NFT to an address.
220305

221306
#### Parameters
222307

documentation/docs/04_step_by_step.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ $ ./wallet main
129129

130130
### Mint
131131

132-
Mint a NFT.
132+
Mint an NFT.
133133
```sh
134134
$ ./wallet main
135135
> Account "main": mint-nft

src/account.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ use iota_wallet::account::AccountHandle;
77

88
use crate::{
99
command::account::{
10-
addresses_command, balance_command, claim_command, consolidate_command, faucet_command,
10+
addresses_command, balance_command, burn_native_token_command, burn_nft_command, claim_command,
11+
consolidate_command, destroy_alias_command, destroy_foundry_command, faucet_command, melt_native_token_command,
1112
mint_native_token_command, mint_nft_command, new_address_command, send_command, send_micro_command,
1213
send_native_token_command, send_nft_command, sync_command, transactions_command, AccountCli, AccountCommand,
1314
},
@@ -54,16 +55,25 @@ pub async fn account_prompt_internal(account_handle: AccountHandle) -> Result<bo
5455
}
5556
};
5657
if let Err(err) = match account_cli.command {
57-
AccountCommand::NewAddress => new_address_command(&account_handle).await,
58+
AccountCommand::Addresses => addresses_command(&account_handle).await,
5859
AccountCommand::Balance => balance_command(&account_handle).await,
60+
AccountCommand::BurnNativeToken { token_id, amount } => {
61+
burn_native_token_command(&account_handle, token_id, amount).await
62+
}
63+
AccountCommand::BurnNft { nft_id } => burn_nft_command(&account_handle, nft_id).await,
5964
AccountCommand::Claim => claim_command(&account_handle).await,
6065
AccountCommand::Consolidate => consolidate_command(&account_handle).await,
66+
AccountCommand::DestroyAlias { alias_id } => destroy_alias_command(&account_handle, alias_id).await,
67+
AccountCommand::DestroyFoundry { foundry_id } => {
68+
destroy_foundry_command(&account_handle, foundry_id).await
69+
}
6170
AccountCommand::Exit => {
6271
return Ok(true);
6372
}
6473
AccountCommand::Faucet { url, address } => faucet_command(&account_handle, url, address).await,
65-
AccountCommand::Addresses => addresses_command(&account_handle).await,
66-
AccountCommand::Transactions => transactions_command(&account_handle).await,
74+
AccountCommand::MeltNativeToken { token_id, amount } => {
75+
melt_native_token_command(&account_handle, token_id, amount).await
76+
}
6777
AccountCommand::MintNativeToken {
6878
maximum_supply,
6979
foundry_metadata,
@@ -73,6 +83,7 @@ pub async fn account_prompt_internal(account_handle: AccountHandle) -> Result<bo
7383
immutable_metadata,
7484
metadata,
7585
} => mint_nft_command(&account_handle, address, immutable_metadata, metadata).await,
86+
AccountCommand::NewAddress => new_address_command(&account_handle).await,
7687
AccountCommand::Send { address, amount } => send_command(&account_handle, address, amount).await,
7788
AccountCommand::SendMicro { address, amount } => {
7889
send_micro_command(&account_handle, address, amount).await
@@ -84,6 +95,7 @@ pub async fn account_prompt_internal(account_handle: AccountHandle) -> Result<bo
8495
} => send_native_token_command(&account_handle, address, token_id, amount).await,
8596
AccountCommand::SendNft { address, nft_id } => send_nft_command(&account_handle, address, nft_id).await,
8697
AccountCommand::Sync => sync_command(&account_handle).await,
98+
AccountCommand::Transactions => transactions_command(&account_handle).await,
8799
} {
88100
log::error!("{}", err);
89101
}

0 commit comments

Comments
 (0)