A Cosmos SDK module for recurring payments between two addresses on a single denomination. One stream per (sender, receiver, denom) triple, with a configurable per-second flow rate, top-up + claim + cancel + flow-rate-update lifecycle, and a default 1% validator fee on each claim.
Extracted from unification-com/mainchain where the module previously lived at x/stream/. Designed to be portable into any Cosmos SDK chain.
Early release. Mainchain is the reference integration. The latest tag is shown in the badge at the top of this README.
| Version | |
|---|---|
| Cosmos SDK | v0.54.x |
| CometBFT | v0.39.x |
| Go | >= 1.25.9 |
From your chain's repo root, pull in the latest tagged release:
go get github.com/unification-com/x-stream@latestTo pin a specific version (recommended for production chains), substitute the tag:
go get github.com/unification-com/x-stream@vX.Y.ZInside your chain's app.go:
import (
"github.com/unification-com/x-stream/x/stream"
streamkeeper "github.com/unification-com/x-stream/x/stream/keeper"
streamtypes "github.com/unification-com/x-stream/x/stream/types"
)
// Add the store key:
keys := storetypes.NewKVStoreKeys(
// ... your existing store keys
streamtypes.StoreKey,
)
// Add the module account permissions:
maccPerms := map[string][]string{
// ... your existing module accounts
streamtypes.ModuleName: nil,
}
// Construct the keeper:
app.StreamKeeper = streamkeeper.NewKeeper(
keys[streamtypes.StoreKey],
app.BankKeeper,
app.AccountKeeper,
appCodec,
authtypes.FeeCollectorName,
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)
// Register the module with the module manager:
app.ModuleManager = module.NewManager(
// ... your existing modules
stream.NewAppModule(appCodec, app.StreamKeeper, app.AccountKeeper, app.BankKeeper),
)See mainchain's app/app.go for a complete reference integration.
| Message | Purpose |
|---|---|
MsgCreateStream |
Open a new stream with an initial deposit and flow rate. |
MsgTopUpDeposit |
Sender adds to a stream's deposit. |
MsgClaimStream |
Receiver withdraws accrued payout. 1% default validator fee applied. |
MsgUpdateFlowRate |
Sender re-tunes the flow rate. |
MsgCancelStream |
Sender cancels (unless cancellable=false). Remaining deposit refunded. |
MsgUpdateParams |
Gov-authority updates module params (e.g. ValidatorFee). |
Streams are keyed by (receiver, sender, denom). Each stream holds:
deposit— total amount the sender has depositedflow_rate— units ofdeposit.denomper secondlast_outflow_time— timestamp of the most recent claimdeposit_zero_time— timestamp when the deposit will be exhausted at the current flow ratecancellable— whetherMsgCancelStreamis permitted (defaulttrue)
go build ./...
go test ./...Make targets for the additional CI gates:
make lint # gofmt -s check + golangci-lint v2
make fmt # apply gofmt -s in place
make test-sim-simple # single-seed 500-block sim (~35s)
make test-sim-multi-seed-short # 3 seeds × 50 blocks determinism check (~20s)
make test-sim-nondeterminism # 3 seeds × 100 blocks × 3 runs determinism (~5min)make proto-allRequires Docker (uses the same buf-based proto chain as upstream Cosmos SDK).
Apache-2.0. See NOTICE for attribution.