Skip to content

Instantly share code, notes, and snippets.

@rootulp
Last active March 20, 2024 18:30
Show Gist options
  • Save rootulp/c47606e177aad1f8959ea31fa077ca5e to your computer and use it in GitHub Desktop.
Save rootulp/c47606e177aad1f8959ea31fa077ca5e to your computer and use it in GitHub Desktop.
Short script to demonstrate feegrant
#!/bin/sh
# Stop script execution if an error is encountered
set -o errexit
# Stop script execution if an undefined variable is used
set -o nounset
CHAIN_ID="private"
KEY_NAME="validator"
KEYRING_BACKEND="test"
DEFAULT_FEES="20000utia"
BROADCAST_MODE="block"
DENOM="utia"
CELESTIA_APP_HOME="${HOME}/.celestia-app"
CELESTIA_APP_VERSION=$(celestia-appd version 2>&1)
echo "celestia-app home: ${CELESTIA_APP_HOME}"
echo "celestia-app version: ${CELESTIA_APP_VERSION}"
echo ""
celestia-appd keys add test1
TEST1=$(celestia-appd keys show test1 -a)
VALIDATOR=$(celestia-appd keys show validator -a)
echo "Creating a feegrant..."
celestia-appd tx feegrant grant $VALIDATOR $TEST1 --spend-limit 1000000utia --allowed-messages "/cosmos.bank.v1beta1.MsgSend,/celestia.blob.v1.MsgPayForBlobs" --chain-id $CHAIN_ID --keyring-backend $KEYRING_BACKEND --fees $DEFAULT_FEES --broadcast-mode $BROADCAST_MODE --yes >> output.log
echo "Created a feegrant."
echo "Sending 100000utia from validator to test1..."
celestia-appd tx bank send $VALIDATOR $TEST1 100000utia --from $VALIDATOR --fees $DEFAULT_FEES --chain-id $CHAIN_ID --keyring-backend $KEYRING_BACKEND --broadcast-mode $BROADCAST_MODE --yes >> output.log
echo "Sent."
echo "Querying test1 balance before send tx..."
celestia-appd query bank balances $TEST1 --chain-id $CHAIN_ID --denom $DENOM
echo "Sending 1utia from test1 to validator..."
celestia-appd tx bank send $TEST1 $VALIDATOR 1utia --chain-id $CHAIN_ID --keyring-backend $KEYRING_BACKEND --broadcast-mode $BROADCAST_MODE --yes >> output.log
echo "Sent."
echo "Querying test1 balance after send tx..."
celestia-appd query bank balances $TEST1 --chain-id $CHAIN_ID --denom $DENOM
echo "Querying test1 balance before PFB tx..."
celestia-appd query bank balances $TEST1 --chain-id $CHAIN_ID --denom $DENOM
echo "Submitting a PFB from test1..."
celestia-appd tx blob pay-for-blob 0x00010203040506070809 0x48656c6c6f2c20576f726c6421 --chain-id $CHAIN_ID --from $TEST1 --keyring-backend $KEYRING_BACKEND --broadcast-mode $BROADCAST_MODE --yes >> output.log
echo "Submitted."
echo "Querying test1 balance after PFB tx..."
celestia-appd query bank balances $TEST1 --chain-id $CHAIN_ID --denom $DENOM
Creating a feegrant...
Created a feegrant.
Sending 100000utia from validator to test1...
Sent.
Querying test1 balance before send tx...
amount: "100000"
denom: utia
Sending 1utia from test1 to validator...
Sent.
Querying test1 balance after send tx...
amount: "99999"
denom: utia
Querying test1 balance before PFB tx...
amount: "99999"
denom: utia
Submitting a PFB from test1...
Submitted.
Querying test1 balance after PFB tx...
amount: "99999"
denom: utia
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment