Skip to content

Commit dde8065

Browse files
committed
docs(1636): Update docs and make owner optional
Signed-off-by: matevszm <mateusz.marcinkowski@blockydevs.com>
1 parent 372c50b commit dde8065

File tree

3 files changed

+89
-2
lines changed

3 files changed

+89
-2
lines changed

skills/hiero-cli/references/token.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,31 @@ hcli token associate --token MTK --account alice --batch myBatch
224224

225225
---
226226

227+
### `hcli token allowance-ft` [batchify]
228+
229+
Approve (or revoke) a spender allowance for fungible tokens on behalf of the owner.
230+
231+
| Option | Short | Type | Required | Default | Description |
232+
| --------------- | ----- | ------ | -------- | -------------- | ------------------------------------------------------------------------------------------ |
233+
| `--token` | `-T` | string | **yes** || Token alias or token ID |
234+
| `--owner` | `-o` | string | **yes** || Owner account: `accountId:privateKey`, key reference, or alias |
235+
| `--spender` | `-s` | string | **yes** || Spender account: account ID or alias |
236+
| `--amount` | `-a` | string | **yes** || Allowance amount. Default: display units. Append `"t"` for raw units. Set to `0` to revoke |
237+
| `--key-manager` | `-k` | string | no | config default | Key manager: `local` or `local_encrypted` |
238+
| `--batch` | `-B` | string | no || Queue into a named batch instead of executing immediately |
239+
240+
**Example:**
241+
242+
```
243+
hcli token allowance-ft --token MTK --owner alice --spender bob --amount 500
244+
hcli token allowance-ft --token 0.0.456 --owner 0.0.123:302e... --spender 0.0.789 --amount 0
245+
hcli token allowance-ft --token MTK --owner alice --spender bob --amount 500 --batch myBatch
246+
```
247+
248+
**Output:** `{ tokenId, ownerAccountId, spenderAccountId, amount, transactionId, network }`
249+
250+
---
251+
227252
### `hcli token list`
228253

229254
List all tokens (FT and NFT) stored in local state across all networks.

src/plugins/token/README.md

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ src/plugins/token/
6060
│ │ ├── input.ts # Input schema
6161
│ │ ├── output.ts # Output schema and template
6262
│ │ └── index.ts # Command exports
63+
│ ├── allowance-ft/
64+
│ │ ├── handler.ts # Fungible token allowance handler
65+
│ │ ├── input.ts # Input schema
66+
│ │ ├── output.ts # Output schema and template
67+
│ │ ├── types.ts # Internal types
68+
│ │ └── index.ts # Command exports
6369
│ ├── delete/
6470
│ │ ├── handler.ts # Token delete handler (local state only)
6571
│ │ ├── input.ts # Input schema
@@ -351,6 +357,62 @@ hcli token transfer-nft \
351357

352358
**Note:** Maximum 10 serial numbers per transaction (Hedera limit). The command verifies NFT ownership before transfer.
353359

360+
### Token Allowance FT
361+
362+
Approve (or revoke) a spender allowance for fungible tokens on behalf of the owner. Set amount to `0` to revoke an existing allowance.
363+
364+
```bash
365+
# Approve allowance using aliases
366+
hcli token allowance-ft \
367+
--token mytoken-alias \
368+
--owner alice \
369+
--spender bob \
370+
--amount 500
371+
372+
# Approve using token ID and account-id:key pairs
373+
hcli token allowance-ft \
374+
--token 0.0.123456 \
375+
--owner 0.0.111111:302e020100300506032b657004220420... \
376+
--spender 0.0.222222 \
377+
--amount 1000t
378+
379+
# Revoke allowance (set amount to 0)
380+
hcli token allowance-ft \
381+
--token mytoken-alias \
382+
--owner alice \
383+
--spender bob \
384+
--amount 0
385+
```
386+
387+
**Parameters:**
388+
389+
- `--token` / `-T`: Token identifier (alias or token ID) - **Required**
390+
- `--owner` / `-o`: Owner account. Accepts any key format (alias, `accountId:privateKey`, key reference) - **Required**
391+
- `--spender` / `-s`: Spender account (ID or alias) - **Required**
392+
- `--amount` / `-a`: Allowance amount - **Required**
393+
- Display units (default): `100` (will be multiplied by token decimals)
394+
- Base units: `100t` (raw amount without decimals)
395+
- `0` to revoke the allowance
396+
- `--key-manager` / `-k`: Key manager type (optional, defaults to config setting)
397+
- `local` or `local_encrypted`
398+
399+
**Batch support:** Pass `--batch <batch-name>` to add to a batch instead of executing immediately.
400+
401+
**Output:**
402+
403+
```json
404+
{
405+
"tokenId": "0.0.123456",
406+
"ownerAccountId": "0.0.111111",
407+
"spenderAccountId": "0.0.222222",
408+
"amount": "100000",
409+
"transactionId": "0.0.111111@1700000000.123456789",
410+
"network": "testnet"
411+
}
412+
```
413+
414+
**Note:** Amount in the output is always in base units (raw). The token must have been associated with the spender account before the allowance can be used.
415+
354416
### Token Delete
355417

356418
Delete a token from local state. This only removes the token from the local address book, not from the Hedera network.
@@ -546,7 +608,7 @@ The following token commands support the `--batch` / `-B` flag via the batch plu
546608
- `create-ft-from-file``TokenCreateFtFromFileBatchStateHook` persists FT-from-file state
547609
- `create-nft-from-file``TokenCreateNftFromFileBatchStateHook` persists NFT-from-file state
548610
- `associate``TokenAssociateBatchStateHook` persists association results
549-
- `mint-ft`, `mint-nft`, `transfer-ft`, `transfer-nft` – can be batched (no state hook; transactions execute atomically)
611+
- `mint-ft`, `mint-nft`, `transfer-ft`, `transfer-nft`, `allowance-ft` – can be batched (no state hook; transactions execute atomically)
550612

551613
When you pass `--batch <batch-name>`:
552614

src/plugins/token/commands/allowance-ft/input.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010

1111
export const TokenAllowanceFtInputSchema = z.object({
1212
token: EntityReferenceSchema.describe('Token identifier (ID or alias)'),
13-
owner: KeySchema.describe(
13+
owner: KeySchema.optional().describe(
1414
'Owner account. Accepts any key format. Defaults to operator.',
1515
),
1616
spender: AccountReferenceSchema.describe('Spender account (ID or alias)'),

0 commit comments

Comments
 (0)