Token Faucet (cosmosfaucet)
The cosmosfaucet package provides a local faucet service and client helpers to fund Cosmos accounts during development and tests.
For full API details, see the
cosmosfaucet Go package documentation.
When to use
- Automatically fund accounts in local/devnet environments.
- Expose a faucet HTTP endpoint backed by a chain key.
- Request funds from an existing faucet endpoint from automation code.
Key APIs
New(ctx context.Context, ccr chaincmdrunner.Runner, options ...Option) (Faucet, error)TryRetrieve(ctx context.Context, chainID, rpcAddress, faucetAddress, accountAddress string) (string, error)OpenAPI(apiAddress string) OptionCoin(amount, maxAmount sdkmath.Int, denom string) OptionFeeAmount(amount sdkmath.Int, denom string) OptionRefreshWindow(refreshWindow time.Duration) OptionNewTransferRequest(accountAddress string, coins []string) TransferRequest
Common Tasks
- Construct a
Faucetwith chain runner + options, then expose transfer endpoints for local users. - Use
TryRetrievein tests before broadcasting txs to ensure accounts have spendable balance. - Tune coin amount, max amount, and refresh window to limit faucet abuse.
Basic import
import "github.com/ignite/cli/v29/ignite/pkg/cosmosfaucet"