Skip to content

Instantly share code, notes, and snippets.

@ad2ien
Last active September 5, 2022 06:50
Show Gist options
  • Save ad2ien/0562838253d9002fa1346c279000930d to your computer and use it in GitHub Desktop.
Save ad2ien/0562838253d9002fa1346c279000930d to your computer and use it in GitHub Desktop.
Generate address / mnemonics CSV for a cosmos blockchain
#!/bin/bash
source .env
# create some wallets, strore address and mnemonics in a file
# use stargaze tool with airdrop_file
# distribute 0.5 Stars on each wallet
# make crypted files with mnemonics
# affect an email to each wallet
# send mails with attached mnemonics
INPUT_FILE=keys.csv
# Testnet config
RPC_ENDPOINT=https://rpc.elgafar-1.stargaze-apis.com:443
CHAIN_ID=elgafar-1
ACCOUNT_NAME=star-testnet-account-file
# Mainnet config
# RPC_ENDPOINT=https://rpc.stargaze-apis.com:443
# CHAIN_ID=stargaze-1
# ACCOUNT_NAME=okp4-official
# TX_NOTE="Gracefully_offered_by_OKP4"
# Prerequisite
# g clone git@github.com:public-awesome/stargaze.git
# cd stargaze
# make install
# fill a csv file with wallets and associated mnemonics
for i in {2..75}
do
starsd keys add 1 --dry-run --output json | jq ' {address,mnemonic} | .[]' | paste - - >> keys-mnemonics.csv
done
# add an account manually
# starsd keys add $ACCOUNT_NAME -i
#Amount & Fees
FEE=2500ustars
AMOUNT=500000ustars
addresses=$(cat $INPUT_FILE)
source .env
# Idempotently Distribute $STARS to your wallet list
for DEST_ADDRESS in $addresses
do
BALANCE=$(starsd query bank balances $DEST_ADDRESS --node $RPC_ENDPOINT -o json | jq '.balances | .[] | .amount')
echo "BALANCE : $DEST_ADDRESS $BALANCE"
if [ "$BALANCE" = "" ]; then
echo "Sould send Sending $AMOUNT to $DEST_ADDRESS"
echo $KEYRING_PASS | starsd tx bank send $ACCOUNT_NAME $DEST_ADDRESS ${AMOUNT} --fees ${FEE} --note $TX_NOTE --node $RPC_ENDPOINT -y --keyring-backend file --chain-id $CHAIN_ID
sleep 20
fi
done
# rm -rf attached-files
# mkdir -p attached-files
# for key in `cat $INPUT_FILE | sed 's/ /-/g; s/\t/_/g; s/"//g;'`;
# do
# KEY=$(echo $key | sed 's/_/ /g;' | awk '{print $1}')
# MNEMONIC=$(echo $key | sed 's/_/ /g;' | awk '{print $2}' | sed 's/-/ /g;')
# echo $MNEMONIC > attached-files/$KEY.txt
# done
# cd attached-files
# for key in `ls`;
# do
# ZIP_FILENAME=$(echo $key | sed 's/\.txt//g').zip
# echo zip -P $ZIP_PASSWORD $ZIP_FILENAME ./$key
# zip -P $ZIP_PASSWORD $ZIP_FILENAME ./$key
# done
# rm *.txt
LINES=$(cat keys-mails.csv)
for entry in $LINES
do
echo entry
IFS=',' array=($entry)
TO=${array[1]}
swaks --to $TO --auth LOGIN --protocol SSMTP --attach-type text/html --attach-body @./mail.html\
--h-Subject "NFT OKP4" --attach-type application/zip --attach @./attached-files/${array[0]}.zip
echo " -done"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment