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

Commit 6125acc

Browse files
authored
docs: Update token-2022 extensions (#5788)
* docs: Add token-2022 presentation info * docs: Update token-2022 status * docs: Add more transfer-hook info * token-cli: Make transfer-hook command consistent with docs
1 parent 5d5fbda commit 6125acc

File tree

4 files changed

+100
-22
lines changed

4 files changed

+100
-22
lines changed

docs/src/token-2022/extensions.mdx

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1370,13 +1370,13 @@ The example program and the interface are powered by the
13701370
library, which is explained in detail in the repository's
13711371
[README](https://github.com/solana-labs/solana-program-library/tree/master/libraries/tlv-account-resolution/README.md)
13721372

1373-
#### Example: Create a permissioned-transfer mint
1373+
#### Example: Create a mint with a transfer hook
13741374

13751375
<Tabs className="unique-tabs" groupId="language-selection">
13761376
<TabItem value="cli" label="CLI" default>
13771377

13781378
```console
1379-
$ spl-token --program-id TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb create-token --transfer-hook-program-id 7N4HggYEJAtCLJdnHGCtFqfxcB5rhQCsQTze3ftYstVj
1379+
$ spl-token --program-id TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb create-token --transfer-hook 7N4HggYEJAtCLJdnHGCtFqfxcB5rhQCsQTze3ftYstVj
13801380
Creating token HFg1FFaj4PqFHmkYrqbZsarNJEZT436aXAXgQFMJihwc under program TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb
13811381

13821382
Address: HFg1FFaj4PqFHmkYrqbZsarNJEZT436aXAXgQFMJihwc
@@ -1446,13 +1446,13 @@ import {
14461446
</TabItem>
14471447
</Tabs>
14481448

1449-
#### Example: Update permissioned-transfer program in mint
1449+
#### Example: Update transfer-hook program in mint
14501450

14511451
<Tabs className="unique-tabs" groupId="language-selection">
14521452
<TabItem value="cli" label="CLI" default>
14531453

14541454
```console
1455-
$ spl-token set-transfer-hook-program-id HFg1FFaj4PqFHmkYrqbZsarNJEZT436aXAXgQFMJihwc EbPBt3XkCb9trcV4c8fidhrvoeURbDbW87Acustzyi8N
1455+
$ spl-token set-transfer-hook HFg1FFaj4PqFHmkYrqbZsarNJEZT436aXAXgQFMJihwc EbPBt3XkCb9trcV4c8fidhrvoeURbDbW87Acustzyi8N
14561456

14571457
Signature: 3Ffw6yjseDsL3Az5n2LjdwXXwVPYxDF3JUU1JC1KGAEb1LE68S9VN4ebtAyvKeYMHvhjdz1LJVyugGNdWHyotzay
14581458
```
@@ -1475,6 +1475,28 @@ await updateTransferHook(
14751475
</TabItem>
14761476
</Tabs>
14771477

1478+
#### Example: Manage a transfer-hook programa
1479+
1480+
A sample CLI for managing a transfer-hook program exists at
1481+
[spl-transfer-hook-cli](https://github.com/solana-labs/solana-program-library/tree/master/token/transfer-hook/cli).
1482+
A mint manager can fork the tool for their own program.
1483+
1484+
It only contains a command to create the required transfer-hook account for the
1485+
mint.
1486+
1487+
First, you must build the transfer-hook program and deploy it:
1488+
1489+
```console
1490+
$ cargo build-sbf
1491+
$ solana program deploy target/deploy/spl-transfer-hook-example.so
1492+
```
1493+
1494+
After that, you can initialize the transfer-hook account:
1495+
1496+
```console
1497+
$ spl-transfer-hook create-extra-metas <PROGRAM_ID> <MINT_ID> [<ACCOUNT_PUBKEY>:<ROLE> ...]
1498+
```
1499+
14781500
### Metadata Pointer
14791501

14801502
With the potential proliferation of multiple metadata programs, a mint can have

docs/src/token-2022/presentation.md

Lines changed: 55 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ The base is mostly there.
5454

5555
- RPC indexes Token-2022
5656
- Anchor
57-
- Wallets: Backpack, others coming
58-
- DeFi Protocols: limited to spl-token-swap
59-
- Metadata: Metaplex can't, so we're making our own
57+
- Wallets
58+
- DeFi Protocols
59+
- Token Metadata
6060

6161
---
6262

@@ -65,7 +65,8 @@ The base is mostly there.
6565
- 4 audits
6666
- 1 more after WIP features
6767
- Currently upgradeable
68-
- Officially recommended after 1.16 on mainnet
68+
- Officially recommended after 1.17 on mainnet (~January 2024)
69+
- More ZK features in 1.18 (~May 2024)
6970
- May be frozen ~6 months after that
7071

7172
---
@@ -89,7 +90,8 @@ The base is mostly there.
8990
- Default account state
9091
- Permanent delegate
9192
- Transfer-hook
92-
- Metadata pointer + metadata (WIP)
93+
- Metadata pointer + metadata
94+
- Group pointer + group
9395

9496
---
9597

@@ -320,11 +322,59 @@ Docs and examples at https://spl.solana.com/token-2022/wallet
320322

321323
---
322324

325+
### Question 14
326+
327+
Why did you add metadata?
328+
329+
---
330+
331+
### Answer 14
332+
333+
- On-chain programming should become more open
334+
- People kept bothering us about it
335+
336+
---
337+
338+
### Question 15
339+
340+
What if I don't want to use your metadata?
341+
342+
---
343+
344+
### Answer 15
345+
346+
- No problem, bring your own!
347+
- The "metadata pointer" extension lets you point to *any* account
348+
- You can also implement the "SPL Token Metadata Interface" in your program
349+
350+
Security bonus: check that the mint and metadata point to each other!
351+
352+
---
353+
354+
### Question 16
355+
356+
Can I just use my own token program?
357+
358+
---
359+
360+
#### Answer 16
361+
362+
- That's the future! In the meantime, we have Transfer Hooks
363+
- With a Transfer Hook, Token-2022 calls a program of your choice during all
364+
transfers for your mint
365+
- The program must implement `spl-transfer-hook-interface`
366+
- Feel free to fork `spl-transfer-hook-example`
367+
368+
---
369+
323370
### I'm a bit overwhelmed
324371

325372
No problem, we're done, here are your links:
326373

327374
- Token-2022: https://spl.solana.com/token-2022
328375
- Token-upgrade: https://spl.solana.com/token-upgrade
376+
- Metadata interface: https://docs.rs/crate/spl-token-metadata-interface/latest
377+
- Transfer hook interface: https://docs.rs/crate/spl-transfer-hook-interface/latest
378+
- Confidential transfers: https://github.com/solana-labs/solana-program-library/blob/master/token/zk-token-protocol-paper/part1.pdf
329379

330380
Thanks for listening!

docs/src/token-2022/status.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,27 @@ development purposes ONLY**.
1010

1111
Here is the general program timeline and rough ETAs:
1212

13-
| Issue | ETA |
14-
| --------------------------- | ---------------------------- |
15-
| Code-complete & final audit | Summer 2023 |
16-
| Mainnet recommendation | Fall 2023 (depends on v1.16) |
17-
| Freeze program | 2024 |
13+
| Issue | ETA |
14+
| --------------------------- | ------------------------------ |
15+
| Code-complete & final audit | Fall 2023 |
16+
| Mainnet recommendation | Winter 2024 (depends on v1.17) |
17+
| More ZK features | Spring 2024 (depends on v1.18) |
18+
| Freeze program | 2024 |
1819

1920
More information: https://github.com/orgs/solana-labs/projects/34
2021

2122
## Remaining items
2223

23-
### v1.16 with curve syscalls
24+
### v1.17 with curve syscalls
2425

25-
In order to use confidential tokens, the cluster must run at least version 1.16
26+
In order to use confidential tokens, the cluster must run at least version 1.17
2627
with the elliptic curve operations syscalls enabled.
2728

2829
More information: https://github.com/solana-labs/solana/issues/29612
2930

3031
### Zero-knowledge proof split
3132

32-
In order to use confidential tokens, the cluster must run at least version 1.16
33+
In order to use confidential tokens, the cluster must run at least version 1.17
3334
with the ZK Token proof program enabled.
3435

3536
More information: https://github.com/solana-labs/solana/pull/32613
@@ -43,6 +44,11 @@ More information: https://github.com/solana-labs/solana-program-library/issues/4
4344

4445
## Future work
4546

47+
### Confidential transfers with fee
48+
49+
Due to the transaction size limit, it is not possible to do confidential transfers
50+
with a fee. We plan to include that capability with Solana 1.18.
51+
4652
### Wallets
4753

4854
To start, wallets need to properly handle the token-2022 program and its accounts,

token/cli/src/main.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ pub enum CommandName {
184184
WithdrawWithheldTokens,
185185
SetTransferFee,
186186
WithdrawExcessLamports,
187-
SetTransferHookProgram,
187+
SetTransferHook,
188188
InitializeMetadata,
189189
UpdateMetadata,
190190
UpdateConfidentialTransferSettings,
@@ -3852,7 +3852,7 @@ fn app<'a, 'b>(
38523852
)
38533853
)
38543854
.subcommand(
3855-
SubCommand::with_name(CommandName::SetTransferHookProgram.into())
3855+
SubCommand::with_name(CommandName::SetTransferHook.into())
38563856
.about("Set the transfer hook program id for a token")
38573857
.arg(
38583858
Arg::with_name("token")
@@ -5535,7 +5535,7 @@ async fn process_command<'a>(
55355535
)
55365536
.await
55375537
}
5538-
(CommandName::SetTransferHookProgram, arg_matches) => {
5538+
(CommandName::SetTransferHook, arg_matches) => {
55395539
let token_pubkey = pubkey_of_signer(arg_matches, "token", &mut wallet_manager)
55405540
.unwrap()
55415541
.unwrap();
@@ -9819,7 +9819,7 @@ mod tests {
98199819
&payer,
98209820
&[
98219821
"spl-token",
9822-
CommandName::SetTransferHookProgram.into(),
9822+
CommandName::SetTransferHook.into(),
98239823
&mint.to_string(),
98249824
&new_transfer_hook_program_id.to_string(),
98259825
],
@@ -9883,7 +9883,7 @@ mod tests {
98839883
&payer,
98849884
&[
98859885
"spl-token",
9886-
CommandName::SetTransferHookProgram.into(),
9886+
CommandName::SetTransferHook.into(),
98879887
&mint.to_string(),
98889888
"--disable",
98899889
],

0 commit comments

Comments
 (0)