-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexample-usage.sh
executable file
·97 lines (78 loc) · 3.98 KB
/
example-usage.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/bash
BLUE='\033[0;34m'
RED='\033[0;31m'
NC='\033[0m' # No Color
mnemonic=$(cat ./.mnemonic)
if [ -z "$mnemonic" ]
then
echo "Please provide a devnet seedphrase in the .mnemonic file, and use a faucet to provide it with some balance."
exit 1
fi
if [ ! -f "./flare" ]
then
echo "Building binary and copying to root..."
cargo build && cp ./target/debug/flare .
fi
echo
echo "-------------------------------------"
echo -e "$BLUE Recovering keypair file and address... $NC"
echo -e "$RED ./flare wallet-recover --mnemonic \"$(echo $mnemonic)\" $NC"
./flare wallet-recover --mnemonic "$(echo $mnemonic)"
output=$(./flare wallet-recover --mnemonic "$(echo $mnemonic)")
address=$(echo "$output" | grep -oP 'Address: \K\w+')
keypair="$address.json"
echo
echo "-------------------------------------"
echo -e "$BLUE Checking wallet balance... $NC"
echo -e "$RED ./flare --cluster devnet balance $(echo $address) $NC"
./flare --cluster devnet balance $(echo $address)
echo
echo "-------------------------------------"
echo -e "$BLUE Recovering address from keypair file... $NC"
echo -e "$RED ./flare address-derive --keypair $(echo $keypair) $NC"
./flare address-derive --keypair $(echo $keypair)
echo
echo "-------------------------------------"
echo -e "$BLUE Signing arbitrary message... $NC"
echo -e "$RED ./flare sign --keypair $(echo $keypair) \"Hello Solana!\" $NC"
./flare sign --keypair $(echo $keypair) "Hello Solana!"
echo
echo "-------------------------------------"
echo -e "$BLUE Creating a new wallet... $NC"
echo -e "$RED ./flare wallet-create $NC"
./flare wallet-create
echo
echo "-------------------------------------"
echo -e "$BLUE Checking current epoch number... $NC"
echo "./flare --cluster devnet epoch"
./flare --cluster devnet epoch
echo
echo "-------------------------------------"
echo -e "$BLUE Checking current block-height number... $NC"
echo -e "$RED ./flare --cluster devnet block-height $NC"
./flare --cluster devnet block-height
echo
echo "-------------------------------------"
echo -e "$BLUE Sending SOL to another account... $NC"
echo -e "$RED ./flare --cluster devnet send --keypair $(echo $keypair) --to 67pUbVFbg4Q94id7NgLFiC5GdtWKgmKYgNXp2CtwsWty 100 $NC"
./flare --cluster devnet send --keypair $(echo $keypair) --to 67pUbVFbg4Q94id7NgLFiC5GdtWKgmKYgNXp2CtwsWty 100
echo
echo "-------------------------------------"
echo -e "$BLUE Calling a method from a program... $NC"
echo -e "$RED ./flare --cluster devnet call --keypair $(echo $keypair) --program WixFUMVqBSTygzeFy9Wuy5XxkeH8xHnUEGvfyyJYqve --accounts 78vJRdkATNZm7cJHaLscYu1HZq24EH3FV6Eppx3BS9qA,$(echo $address) --signers $(echo $keypair) --idl ./example/onchain_voting.json gibVote GM $NC"
./flare call --keypair $(echo $keypair) --program WixFUMVqBSTygzeFy9Wuy5XxkeH8xHnUEGvfyyJYqve --accounts 78vJRdkATNZm7cJHaLscYu1HZq24EH3FV6Eppx3BS9qA,$(echo $address) --signers $(echo $keypair) --idl ./example/onchain_voting.json gibVote GM
echo
echo "-------------------------------------"
echo -e "$BLUE Reading and deserializing an account from a program... $NC"
echo -e "$RED ./flare --cluster devnet read-account --program WixFUMVqBSTygzeFy9Wuy5XxkeH8xHnUEGvfyyJYqve --account 78vJRdkATNZm7cJHaLscYu1HZq24EH3FV6Eppx3BS9qA --idl ./example/onchain_voting.json $NC"
./flare --cluster devnet read-account --program WixFUMVqBSTygzeFy9Wuy5XxkeH8xHnUEGvfyyJYqve --account 78vJRdkATNZm7cJHaLscYu1HZq24EH3FV6Eppx3BS9qA --idl ./example/onchain_voting.json
echo
echo "-------------------------------------"
echo -e "$BLUE Generating PDA... $NC"
echo -e "$RED ./flare generate-pda --program WixFUMVqBSTygzeFy9Wuy5XxkeH8xHnUEGvfyyJYqve $(echo $address),foo,bar $NC"
./flare generate-pda --program WixFUMVqBSTygzeFy9Wuy5XxkeH8xHnUEGvfyyJYqve $(echo $address),foo,bar
echo
echo "-------------------------------------"
echo -e "$BLUE Fetching published IDL... $NC"
echo -e "$RED ./flare --cluster devnet fetch-idl --program 39EmHuEbqkzUvPncNchXW1Yt6VPmps2Z9ucR82EozNAa $NC"
./flare --cluster devnet fetch-idl --program 39EmHuEbqkzUvPncNchXW1Yt6VPmps2Z9ucR82EozNAa