mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-11-28 09:02:58 +03:00
d31b707c4b
* improve leo example run scripts * add leo build warning message, reduce number of calls to snarkvm package open * cargo clippy * Update examples/token/run.sh Co-authored-by: Eric McCarthy <7607035+bendyarm@users.noreply.github.com> Signed-off-by: Collin Chin <16715212+collinc97@users.noreply.github.com> * Update examples/token/run.sh Co-authored-by: Eric McCarthy <7607035+bendyarm@users.noreply.github.com> Signed-off-by: Collin Chin <16715212+collinc97@users.noreply.github.com> * Update examples/token/run.sh Co-authored-by: Eric McCarthy <7607035+bendyarm@users.noreply.github.com> Signed-off-by: Collin Chin <16715212+collinc97@users.noreply.github.com> * Update examples/token/run.sh Co-authored-by: Eric McCarthy <7607035+bendyarm@users.noreply.github.com> Signed-off-by: Collin Chin <16715212+collinc97@users.noreply.github.com> * Update examples/token/run.sh Co-authored-by: Eric McCarthy <7607035+bendyarm@users.noreply.github.com> Signed-off-by: Collin Chin <16715212+collinc97@users.noreply.github.com> * fix comments * make auctioneer the starting private key in auction example --------- Signed-off-by: Collin Chin <16715212+collinc97@users.noreply.github.com> Co-authored-by: Eric McCarthy <7607035+bendyarm@users.noreply.github.com>
211 lines
14 KiB
Bash
Executable File
211 lines
14 KiB
Bash
Executable File
#!/bin/bash
|
|
# First check that Leo is installed.
|
|
if ! command -v leo &> /dev/null
|
|
then
|
|
echo "leo is not installed."
|
|
exit
|
|
fi
|
|
|
|
# The private key and address of the bank.
|
|
# Swap these into program.json, when running transactions as the first bidder.
|
|
# "private_key": "APrivateKey1zkpHtqVWT6fSHgUMNxsuVf7eaR6id2cj7TieKY1Z8CP5rCD",
|
|
# "address": "aleo1t0uer3jgtsgmx5tq6x6f9ecu8tr57rzzfnc2dgmcqldceal0ls9qf6st7a"
|
|
|
|
# The private key and address of the user.
|
|
# Swap these into program.json, when running transactions as the second bidder.
|
|
# "private_key": "APrivateKey1zkp75cpr5NNQpVWc5mfsD9Uf2wg6XvHknf82iwB636q3rtc"
|
|
# "address": "aleo1zeklp6dd8e764spe74xez6f8w27dlua3w7hl4z2uln03re52egpsv46ngg"
|
|
|
|
# Swap in the private key and address of the bank to .env.
|
|
echo "
|
|
NETWORK=testnet3
|
|
PRIVATE_KEY=APrivateKey1zkpHtqVWT6fSHgUMNxsuVf7eaR6id2cj7TieKY1Z8CP5rCD
|
|
" > .env
|
|
|
|
# Have the bank issue 100 tokens to the user.
|
|
echo "
|
|
###############################################################################
|
|
######## ########
|
|
######## STEP 1: Initialize 100 tokens for aleo1zeklp...v46ngg ########
|
|
######## ########
|
|
######## ----------------------------------------- ########
|
|
######## | ACTION | AMOUNT | ########
|
|
######## ----------------------------------------- ########
|
|
######## ----------------------------------------- ########
|
|
######## | Issuing | 100 | ########
|
|
######## ----------------------------------------- ########
|
|
######## | Depositing | 0 | ########
|
|
######## ----------------------------------------- ########
|
|
######## | Withdrawing | 0 | ########
|
|
######## ----------------------------------------- ########
|
|
######## ########
|
|
######## ----------------------------------------- ########
|
|
######## | WALLET | aleo1zeklp...v46ngg | ########
|
|
######## ----------------------------------------- ########
|
|
######## ----------------------------------------- ########
|
|
######## | Balance | 100 | ########
|
|
######## ----------------------------------------- ########
|
|
######## ########
|
|
######## ----------------------------------------- ########
|
|
######## | BANK | aleo1zeklp...v46ngg | ########
|
|
######## ----------------------------------------- ########
|
|
######## ----------------------------------------- ########
|
|
######## | Balance | 0 | ########
|
|
######## ----------------------------------------- ########
|
|
######## | Periods | 0 | ########
|
|
######## ----------------------------------------- ########
|
|
######## | Interest Rate | 12.34% | ########
|
|
######## ----------------------------------------- ########
|
|
######## ########
|
|
######## ----------------------------------------- ########
|
|
######## | TOTAL BALANCE | 100 | ########
|
|
######## ----------------------------------------- ########
|
|
######## ########
|
|
###############################################################################
|
|
"
|
|
leo run issue aleo1zeklp6dd8e764spe74xez6f8w27dlua3w7hl4z2uln03re52egpsv46ngg 100u64 || exit
|
|
|
|
# Swap in the private key and address of the user to .env.
|
|
echo "
|
|
NETWORK=testnet3
|
|
PRIVATE_KEY=APrivateKey1zkp75cpr5NNQpVWc5mfsD9Uf2wg6XvHknf82iwB636q3rtc
|
|
" > .env
|
|
|
|
# Have the user deposit 50 tokens into the bank.
|
|
echo "
|
|
###############################################################################
|
|
######## ########
|
|
######## STEP 2: aleo1zeklp...v46ngg deposits 50 tokens ########
|
|
######## ########
|
|
######## ----------------------------------------- ########
|
|
######## | ACTION | AMOUNT | ########
|
|
######## ----------------------------------------- ########
|
|
######## ----------------------------------------- ########
|
|
######## | Issuing | 0 | ########
|
|
######## ----------------------------------------- ########
|
|
######## | Depositing | 50 | ########
|
|
######## ----------------------------------------- ########
|
|
######## | Withdrawing | 0 | ########
|
|
######## ----------------------------------------- ########
|
|
######## ########
|
|
######## ----------------------------------------- ########
|
|
######## | WALLET | aleo1zeklp...v46ngg | ########
|
|
######## ----------------------------------------- ########
|
|
######## ----------------------------------------- ########
|
|
######## | Balance | 50 | ########
|
|
######## ----------------------------------------- ########
|
|
######## ########
|
|
######## ----------------------------------------- ########
|
|
######## | BANK | aleo1zeklp...v46ngg | ########
|
|
######## ----------------------------------------- ########
|
|
######## ----------------------------------------- ########
|
|
######## | Balance | 50 | ########
|
|
######## ----------------------------------------- ########
|
|
######## | Periods | 0 | ########
|
|
######## ----------------------------------------- ########
|
|
######## | Interest Rate | 12.34% | ########
|
|
######## ----------------------------------------- ########
|
|
######## ########
|
|
######## ----------------------------------------- ########
|
|
######## | TOTAL BALANCE | 100 | ########
|
|
######## ----------------------------------------- ########
|
|
######## ########
|
|
###############################################################################
|
|
"
|
|
leo run deposit "{
|
|
owner: aleo1zeklp6dd8e764spe74xez6f8w27dlua3w7hl4z2uln03re52egpsv46ngg.private,
|
|
amount: 100u64.private,
|
|
_nonce: 4668394794828730542675887906815309351994017139223602571716627453741502624516group.public
|
|
}" 50u64 || exit
|
|
|
|
echo "
|
|
###############################################################################
|
|
######## ########
|
|
######## STEP 3: Wait 15 periods ########
|
|
######## ########
|
|
######## ----------------------------------------- ########
|
|
######## | ACTION | AMOUNT | ########
|
|
######## ----------------------------------------- ########
|
|
######## ----------------------------------------- ########
|
|
######## | Issuing | 0 | ########
|
|
######## ----------------------------------------- ########
|
|
######## | Depositing | 0 | ########
|
|
######## ----------------------------------------- ########
|
|
######## | Withdrawing | 0 | ########
|
|
######## ----------------------------------------- ########
|
|
######## ########
|
|
######## ----------------------------------------- ########
|
|
######## | WALLET | aleo1zeklp...v46ngg | ########
|
|
######## ----------------------------------------- ########
|
|
######## ----------------------------------------- ########
|
|
######## | Balance | 50 | ########
|
|
######## ----------------------------------------- ########
|
|
######## ########
|
|
######## ----------------------------------------- ########
|
|
######## | BANK | aleo1zeklp...v46ngg | ########
|
|
######## ----------------------------------------- ########
|
|
######## ----------------------------------------- ########
|
|
######## | Balance | 266 | ########
|
|
######## ----------------------------------------- ########
|
|
######## | Periods | 15 | ########
|
|
######## ----------------------------------------- ########
|
|
######## | Interest Rate | 12.34% | ########
|
|
######## ----------------------------------------- ########
|
|
######## ########
|
|
######## ----------------------------------------- ########
|
|
######## | TOTAL BALANCE | 316 | ########
|
|
######## ----------------------------------------- ########
|
|
######## ########
|
|
###############################################################################
|
|
"
|
|
|
|
# Swap in the private key and address of the bank to .env.
|
|
echo "
|
|
NETWORK=testnet3
|
|
PRIVATE_KEY=APrivateKey1zkpHtqVWT6fSHgUMNxsuVf7eaR6id2cj7TieKY1Z8CP5rCD
|
|
" > .env
|
|
|
|
# Have the bank withdraw all of the user's tokens with compound interest over 15 periods at 12.34%.
|
|
echo "
|
|
###############################################################################
|
|
######## ########
|
|
######## STEP 4: Withdraw tokens of aleo1zeklp...v46ngg w/ interest ########
|
|
######## ########
|
|
######## ----------------------------------------- ########
|
|
######## | ACTION | AMOUNT | ########
|
|
######## ----------------------------------------- ########
|
|
######## ----------------------------------------- ########
|
|
######## | Issuing | 0 | ########
|
|
######## ----------------------------------------- ########
|
|
######## | Depositing | 0 | ########
|
|
######## ----------------------------------------- ########
|
|
######## | Withdrawing | 266 | ########
|
|
######## ----------------------------------------- ########
|
|
######## ########
|
|
######## ----------------------------------------- ########
|
|
######## | WALLET | aleo1zeklp...v46ngg | ########
|
|
######## ----------------------------------------- ########
|
|
######## ----------------------------------------- ########
|
|
######## | Balance | 316 | ########
|
|
######## ----------------------------------------- ########
|
|
######## ########
|
|
######## ----------------------------------------- ########
|
|
######## | BANK | aleo1zeklp...v46ngg | ########
|
|
######## ----------------------------------------- ########
|
|
######## ----------------------------------------- ########
|
|
######## | Balance | 0 | ########
|
|
######## ----------------------------------------- ########
|
|
######## | Periods | 15 | ########
|
|
######## ----------------------------------------- ########
|
|
######## | Interest Rate | 12.34% | ########
|
|
######## ----------------------------------------- ########
|
|
######## ########
|
|
######## ----------------------------------------- ########
|
|
######## | TOTAL BALANCE | 316 | ########
|
|
######## ----------------------------------------- ########
|
|
######## ########
|
|
###############################################################################
|
|
"
|
|
leo run withdraw aleo1t0uer3jgtsgmx5tq6x6f9ecu8tr57rzzfnc2dgmcqldceal0ls9qf6st7a 50u64 1234u64 15u64 || exit
|
|
|