/ basic_bank / run.sh
run.sh
1 #!/bin/bash 2 # First check that Leo is installed. 3 if ! command -v leo &> /dev/null 4 then 5 echo "leo is not installed." 6 exit 7 fi 8 9 # The private key and address of the bank. 10 # Swap these into .env, when running transactions as the bank. 11 # NETWORK=testnet 12 # PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH 13 14 # The private key and address of the user. 15 # Swap these into .env, when running transactions as the user. 16 # NETWORK=testnet 17 # PRIVATE_KEY=APrivateKey1zkp2RWGDcde3efb89rjhME1VYA8QMxcxep5DShNBR6n8Yjh 18 19 # Swap in the private key and address of the bank to .env. 20 echo "NETWORK=testnet 21 PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH 22 ENDPOINT=http://localhost:3030 23 " > .env 24 25 # Have the bank issue 100 tokens to the user. 26 echo " 27 ############################################################################### 28 ######## ######## 29 ######## STEP 1: Initialize 100 tokens for aleo1s3ws5...em2u4t ######## 30 ######## ######## 31 ######## ----------------------------------------- ######## 32 ######## | ACTION | AMOUNT | ######## 33 ######## ----------------------------------------- ######## 34 ######## ----------------------------------------- ######## 35 ######## | Issuing | 100 | ######## 36 ######## ----------------------------------------- ######## 37 ######## | Depositing | 0 | ######## 38 ######## ----------------------------------------- ######## 39 ######## | Withdrawing | 0 | ######## 40 ######## ----------------------------------------- ######## 41 ######## ######## 42 ######## ----------------------------------------- ######## 43 ######## | WALLET | aleo1s3ws5...em2u4t | ######## 44 ######## ----------------------------------------- ######## 45 ######## ----------------------------------------- ######## 46 ######## | Balance | 100 | ######## 47 ######## ----------------------------------------- ######## 48 ######## ######## 49 ######## ----------------------------------------- ######## 50 ######## | BANK | aleo1rhgdu...vzp9px | ######## 51 ######## ----------------------------------------- ######## 52 ######## ----------------------------------------- ######## 53 ######## | Balance | 0 | ######## 54 ######## ----------------------------------------- ######## 55 ######## | Periods | 0 | ######## 56 ######## ----------------------------------------- ######## 57 ######## | Interest Rate | 12.34% | ######## 58 ######## ----------------------------------------- ######## 59 ######## ######## 60 ######## ----------------------------------------- ######## 61 ######## | TOTAL BALANCE | 100 | ######## 62 ######## ----------------------------------------- ######## 63 ######## ######## 64 ############################################################################### 65 " 66 leo run issue aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t 100u64 || exit 67 68 69 # Swap in the private key and address of the user to .env. 70 echo "NETWORK=testnet 71 PRIVATE_KEY=APrivateKey1zkp2RWGDcde3efb89rjhME1VYA8QMxcxep5DShNBR6n8Yjh 72 ENDPOINT=http://localhost:3030 73 " > .env 74 75 # Have the user deposit 50 tokens into the bank. 76 echo " 77 ############################################################################### 78 ######## ######## 79 ######## STEP 2: aleo1s3ws5...em2u4t deposits 50 tokens ######## 80 ######## ######## 81 ######## ----------------------------------------- ######## 82 ######## | ACTION | AMOUNT | ######## 83 ######## ----------------------------------------- ######## 84 ######## ----------------------------------------- ######## 85 ######## | Issuing | 0 | ######## 86 ######## ----------------------------------------- ######## 87 ######## | Depositing | 50 | ######## 88 ######## ----------------------------------------- ######## 89 ######## | Withdrawing | 0 | ######## 90 ######## ----------------------------------------- ######## 91 ######## ######## 92 ######## ----------------------------------------- ######## 93 ######## | WALLET | aleo1s3ws5...em2u4t | ######## 94 ######## ----------------------------------------- ######## 95 ######## ----------------------------------------- ######## 96 ######## | Balance | 50 | ######## 97 ######## ----------------------------------------- ######## 98 ######## ######## 99 ######## ----------------------------------------- ######## 100 ######## | BANK | aleo1rhgdu...vzp9px | ######## 101 ######## ----------------------------------------- ######## 102 ######## ----------------------------------------- ######## 103 ######## | Balance | 50 | ######## 104 ######## ----------------------------------------- ######## 105 ######## | Periods | 0 | ######## 106 ######## ----------------------------------------- ######## 107 ######## | Interest Rate | 12.34% | ######## 108 ######## ----------------------------------------- ######## 109 ######## ######## 110 ######## ----------------------------------------- ######## 111 ######## | TOTAL BALANCE | 100 | ######## 112 ######## ----------------------------------------- ######## 113 ######## ######## 114 ############################################################################### 115 " 116 leo run deposit "{ 117 owner: aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t.private, 118 amount: 100u64.private, 119 _nonce: 4668394794828730542675887906815309351994017139223602571716627453741502624516group.public 120 }" 50u64 || exit 121 122 echo " 123 ############################################################################### 124 ######## ######## 125 ######## STEP 3: Wait 15 periods ######## 126 ######## ######## 127 ######## ----------------------------------------- ######## 128 ######## | ACTION | AMOUNT | ######## 129 ######## ----------------------------------------- ######## 130 ######## ----------------------------------------- ######## 131 ######## | Issuing | 0 | ######## 132 ######## ----------------------------------------- ######## 133 ######## | Depositing | 0 | ######## 134 ######## ----------------------------------------- ######## 135 ######## | Withdrawing | 0 | ######## 136 ######## ----------------------------------------- ######## 137 ######## ######## 138 ######## ----------------------------------------- ######## 139 ######## | WALLET | aleo1s3ws5...em2u4t | ######## 140 ######## ----------------------------------------- ######## 141 ######## ----------------------------------------- ######## 142 ######## | Balance | 50 | ######## 143 ######## ----------------------------------------- ######## 144 ######## ######## 145 ######## ----------------------------------------- ######## 146 ######## | BANK | aleo1rhgdu...vzp9px | ######## 147 ######## ----------------------------------------- ######## 148 ######## ----------------------------------------- ######## 149 ######## | Balance | 266 | ######## 150 ######## ----------------------------------------- ######## 151 ######## | Periods | 15 | ######## 152 ######## ----------------------------------------- ######## 153 ######## | Interest Rate | 12.34% | ######## 154 ######## ----------------------------------------- ######## 155 ######## ######## 156 ######## ----------------------------------------- ######## 157 ######## | TOTAL BALANCE | 316 | ######## 158 ######## ----------------------------------------- ######## 159 ######## ######## 160 ############################################################################### 161 " 162 163 # Swap in the private key and address of the bank to .env. 164 echo "NETWORK=testnet 165 PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH 166 ENDPOINT=http://localhost:3030 167 " > .env 168 169 # Have the bank withdraw all of the user's tokens with compound interest over 15 periods at 12.34%. 170 echo " 171 ############################################################################### 172 ######## ######## 173 ######## STEP 4: Withdraw tokens of aleo1s3ws5...em2u4t w/ interest ######## 174 ######## ######## 175 ######## ----------------------------------------- ######## 176 ######## | ACTION | AMOUNT | ######## 177 ######## ----------------------------------------- ######## 178 ######## ----------------------------------------- ######## 179 ######## | Issuing | 0 | ######## 180 ######## ----------------------------------------- ######## 181 ######## | Depositing | 0 | ######## 182 ######## ----------------------------------------- ######## 183 ######## | Withdrawing | 266 | ######## 184 ######## ----------------------------------------- ######## 185 ######## ######## 186 ######## ----------------------------------------- ######## 187 ######## | WALLET | aleo1s3ws5...em2u4t | ######## 188 ######## ----------------------------------------- ######## 189 ######## ----------------------------------------- ######## 190 ######## | Balance | 316 | ######## 191 ######## ----------------------------------------- ######## 192 ######## ######## 193 ######## ----------------------------------------- ######## 194 ######## | BANK | aleo1rhgdu...vzp9px | ######## 195 ######## ----------------------------------------- ######## 196 ######## ----------------------------------------- ######## 197 ######## | Balance | 0 | ######## 198 ######## ----------------------------------------- ######## 199 ######## | Periods | 15 | ######## 200 ######## ----------------------------------------- ######## 201 ######## | Interest Rate | 12.34% | ######## 202 ######## ----------------------------------------- ######## 203 ######## ######## 204 ######## ----------------------------------------- ######## 205 ######## | TOTAL BALANCE | 316 | ######## 206 ######## ----------------------------------------- ######## 207 ######## ######## 208 ############################################################################### 209 " 210 leo run withdraw aleo1t0uer3jgtsgmx5tq6x6f9ecu8tr57rzzfnc2dgmcqldceal0ls9qf6st7a 50u64 1234u64 15u64 || exit 211