|
| 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