Some checks are pending
Docs Deploy / build_and_deploy (push) Waiting to run
Generate Docs / cli (push) Waiting to run
Generate Config Doc / cli (push) Waiting to run
Go formatting / go-formatting (push) Waiting to run
Check links / markdown-link-check (push) Waiting to run
Integration / pre-test (push) Waiting to run
Integration / test on (push) Blocked by required conditions
Integration / status (push) Blocked by required conditions
Lint / Lint Go code (push) Waiting to run
Test / test (ubuntu-latest) (push) Waiting to run
1.4 KiB
1.4 KiB
| sidebar_position | title | slug |
|---|---|---|
| 5 | Token Faucet (cosmosfaucet) | /packages/cosmosfaucet |
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"