Skip to content

Commit

Permalink
token-2022: Show all extensions (#315)
Browse files Browse the repository at this point in the history
#### Problem

Although the explorer has some support of token-2022, it doesn't show
any mint or account extensions, which leads to a lot of confusion for
people who create mints.

#### Solution

Everything is provided with JSON-parsed encoding, so:

* create types for all of the JSON-parsed returns
* show each extension

For the most part, each commit corresponds to an extension, except
otherwise noted. I wasn't sure about the best way to display all of
these, especially those with many fields, so I went with a little header
line before showing each field. Let me know what you think of that.

Here are some screenshots of a mint with every extension (minus token
group, group member, group pointer, and member pointer):


![image](https://github.com/solana-labs/explorer/assets/934662/7a1e46b5-acb7-49c4-ac50-5a1e647197c3)


![image](https://github.com/solana-labs/explorer/assets/934662/b5a4fb6f-1de1-4708-892f-dc7a2dd1feb2)


![image](https://github.com/solana-labs/explorer/assets/934662/b956f391-3665-4e57-9ba3-4a7a2e69afc1)

And an account with all extensions:


![image](https://github.com/solana-labs/explorer/assets/934662/62d738ec-1aa8-4d14-b41e-acd462e9020e)


![image](https://github.com/solana-labs/explorer/assets/934662/9967e50e-5bd4-43a3-947c-c79ee112d920)

And in case you care, here's how you can create your own mega-token:

```
set -ex
solana-keygen -o mint.json --no-passphrase
mint=$(solana-keygen pubkey mint.json)
solana-keygen -o source.json --no-passphrase
source_pubkey=$(solana-keygen pubkey source.json)
spl-token -ul \
  create-token \
  --enable-close \
  --enable-freeze \
  --enable-metadata \
  --enable-non-transferable \
  --enable-permanent-delegate \
  --enable-confidential-transfers auto \
  --default-account-state initialized \
  --interest-rate 5 \
  --transfer-fee 10 11 \
  --transfer-hook $mint \
  --program-id TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb \
  mint.json
spl-token -ul initialize-metadata $mint MegaToken MT https://spl.solana.com/token-2022
spl-token -ul update-metadata $mint Mega Token

spl-token -ul create-account --immutable $mint source.json
spl-token -ul enable-required-transfer-memos "$source_pubkey"
spl-token -ul enable-cpi-guard "$source_pubkey"
spl-token -ul configure-confidential-transfer-account --address "$source_pubkey"
```
  • Loading branch information
joncinque committed Jan 23, 2024
1 parent 5dcb646 commit 248801a
Show file tree
Hide file tree
Showing 3 changed files with 844 additions and 12 deletions.

1 comment on commit 248801a

@vercel
Copy link

@vercel vercel bot commented on 248801a Jan 23, 2024

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

explorer – ./

explorer-solana-labs.vercel.app
explorer.solana.com
explorer-git-master-solana-labs.vercel.app

Please sign in to comment.