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

Commit 92c07e6

Browse files
authored
docs: Add confidential transfer test script (#6561)
1 parent 8b0a011 commit 92c07e6

File tree

2 files changed

+82
-0
lines changed

2 files changed

+82
-0
lines changed

docs/src/confidential-token/quickstart.md

+5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ about Token-2022 and the concept of extensions.
1515
See the [Token Setup Guide](../token#setup) to install the client utilities.
1616
Token-2022 shares the same CLI and NPM packages for maximal compatibility.
1717

18+
All of the commands here exist in a
19+
[helper script](https://github.com/solana-labs/solana-program-library/tree/master/token/cli/examples/confidential-transfer.sh)
20+
at the
21+
[Token CLI Examples](https://github.com/solana-labs/solana-program-library/tree/master/token/cli/examples).
22+
1823
### Example: Create a mint with confidential transfers
1924

2025
To create a new mint with confidential transfers enabled, run:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!/usr/bin/env bash
2+
3+
# Set whichever network you would like to test with
4+
# solana config set -ul
5+
6+
program_id="TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"
7+
8+
echo "Setup keypairs"
9+
solana-keygen new -o confidential-mint.json --no-bip39-passphrase
10+
solana-keygen new -o confidential-source.json --no-bip39-passphrase
11+
solana-keygen new -o confidential-destination.json --no-bip39-passphrase
12+
mint_pubkey=$(solana-keygen pubkey "confidential-mint.json")
13+
source_pubkey=$(solana-keygen pubkey "confidential-source.json")
14+
destination_pubkey=$(solana-keygen pubkey "confidential-destination.json")
15+
16+
set -ex
17+
echo "Initializing mint"
18+
spl-token --program-id "$program_id" create-token confidential-mint.json --enable-confidential-transfers auto
19+
echo "Displaying"
20+
spl-token display "$mint_pubkey"
21+
read -n 1 -p "..."
22+
23+
echo "Setting up transfer accounts"
24+
spl-token create-account "$mint_pubkey" confidential-source.json
25+
spl-token configure-confidential-transfer-account --address "$source_pubkey"
26+
spl-token create-account "$mint_pubkey" confidential-destination.json
27+
spl-token configure-confidential-transfer-account --address "$destination_pubkey"
28+
spl-token mint "$mint_pubkey" 100 confidential-source.json
29+
30+
echo "Displaying"
31+
spl-token display "$source_pubkey"
32+
read -n 1 -p "..."
33+
34+
echo "Depositing into confidential"
35+
spl-token deposit-confidential-tokens "$mint_pubkey" 100 --address "$source_pubkey"
36+
echo "Displaying"
37+
spl-token display "$source_pubkey"
38+
read -n 1 -p "..."
39+
40+
echo "Applying pending balances"
41+
spl-token apply-pending-balance --address "$source_pubkey"
42+
echo "Displaying"
43+
spl-token display "$source_pubkey"
44+
read -n 1 -p "..."
45+
46+
echo "Transferring 10"
47+
spl-token transfer "$mint_pubkey" 10 "$destination_pubkey" --from "$source_pubkey" --confidential
48+
echo "Displaying source"
49+
spl-token display "$source_pubkey"
50+
echo "Displaying destination"
51+
spl-token display "$destination_pubkey"
52+
read -n 1 -p "..."
53+
54+
echo "Applying balance on destination"
55+
spl-token apply-pending-balance --address "$destination_pubkey"
56+
echo "Displaying destination"
57+
spl-token display "$destination_pubkey"
58+
read -n 1 -p "..."
59+
60+
echo "Transferring 0"
61+
spl-token transfer "$mint_pubkey" 0 "$destination_pubkey" --from "$source_pubkey" --confidential
62+
echo "Displaying destination"
63+
spl-token display "$destination_pubkey"
64+
read -n 1 -p "..."
65+
66+
echo "Transferring 0 again"
67+
spl-token transfer "$mint_pubkey" 0 "$destination_pubkey" --from "$source_pubkey" --confidential
68+
echo "Displaying destination"
69+
spl-token display "$destination_pubkey"
70+
read -n 1 -p "..."
71+
72+
echo "Withdrawing 10 from destination"
73+
spl-token apply-pending-balance --address "$destination_pubkey"
74+
spl-token withdraw-confidential-tokens "$mint_pubkey" 10 --address "$destination_pubkey"
75+
echo "Displaying destination"
76+
spl-token display "$destination_pubkey"
77+
read -n 1 -p "..."

0 commit comments

Comments
 (0)