-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: Add confidential transfer test script (#6561)
- Loading branch information
Showing
2 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Set whichever network you would like to test with | ||
# solana config set -ul | ||
|
||
program_id="TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" | ||
|
||
echo "Setup keypairs" | ||
solana-keygen new -o confidential-mint.json --no-bip39-passphrase | ||
solana-keygen new -o confidential-source.json --no-bip39-passphrase | ||
solana-keygen new -o confidential-destination.json --no-bip39-passphrase | ||
mint_pubkey=$(solana-keygen pubkey "confidential-mint.json") | ||
source_pubkey=$(solana-keygen pubkey "confidential-source.json") | ||
destination_pubkey=$(solana-keygen pubkey "confidential-destination.json") | ||
|
||
set -ex | ||
echo "Initializing mint" | ||
spl-token --program-id "$program_id" create-token confidential-mint.json --enable-confidential-transfers auto | ||
echo "Displaying" | ||
spl-token display "$mint_pubkey" | ||
read -n 1 -p "..." | ||
|
||
echo "Setting up transfer accounts" | ||
spl-token create-account "$mint_pubkey" confidential-source.json | ||
spl-token configure-confidential-transfer-account --address "$source_pubkey" | ||
spl-token create-account "$mint_pubkey" confidential-destination.json | ||
spl-token configure-confidential-transfer-account --address "$destination_pubkey" | ||
spl-token mint "$mint_pubkey" 100 confidential-source.json | ||
|
||
echo "Displaying" | ||
spl-token display "$source_pubkey" | ||
read -n 1 -p "..." | ||
|
||
echo "Depositing into confidential" | ||
spl-token deposit-confidential-tokens "$mint_pubkey" 100 --address "$source_pubkey" | ||
echo "Displaying" | ||
spl-token display "$source_pubkey" | ||
read -n 1 -p "..." | ||
|
||
echo "Applying pending balances" | ||
spl-token apply-pending-balance --address "$source_pubkey" | ||
echo "Displaying" | ||
spl-token display "$source_pubkey" | ||
read -n 1 -p "..." | ||
|
||
echo "Transferring 10" | ||
spl-token transfer "$mint_pubkey" 10 "$destination_pubkey" --from "$source_pubkey" --confidential | ||
echo "Displaying source" | ||
spl-token display "$source_pubkey" | ||
echo "Displaying destination" | ||
spl-token display "$destination_pubkey" | ||
read -n 1 -p "..." | ||
|
||
echo "Applying balance on destination" | ||
spl-token apply-pending-balance --address "$destination_pubkey" | ||
echo "Displaying destination" | ||
spl-token display "$destination_pubkey" | ||
read -n 1 -p "..." | ||
|
||
echo "Transferring 0" | ||
spl-token transfer "$mint_pubkey" 0 "$destination_pubkey" --from "$source_pubkey" --confidential | ||
echo "Displaying destination" | ||
spl-token display "$destination_pubkey" | ||
read -n 1 -p "..." | ||
|
||
echo "Transferring 0 again" | ||
spl-token transfer "$mint_pubkey" 0 "$destination_pubkey" --from "$source_pubkey" --confidential | ||
echo "Displaying destination" | ||
spl-token display "$destination_pubkey" | ||
read -n 1 -p "..." | ||
|
||
echo "Withdrawing 10 from destination" | ||
spl-token apply-pending-balance --address "$destination_pubkey" | ||
spl-token withdraw-confidential-tokens "$mint_pubkey" 10 --address "$destination_pubkey" | ||
echo "Displaying destination" | ||
spl-token display "$destination_pubkey" | ||
read -n 1 -p "..." |