Learn More →
Learn More →
We can't build durable, long-lived systems without stability. We need a solid foundation to start building other layers.
Blockchain is hard! A successful blockchain development platform must have a strong focus on DevX to balance against the inherent complexity of developing distributed ledger technologies.
Simplified workflow for implementing a module:
RegisterServices
entry pointpackage cosmos.bank;
// Msg defines the bank Msg service.
service Msg {
// Send defines a method for sending coins from one account to another account.
rpc Send(MsgSend) returns (MsgSendResponse);
// MultiSend defines a method for sending coins from some accounts to other accounts.
rpc MultiSend(MsgMultiSend) returns (MsgMultiSendResponse);
}
message MsgSend {
string from_address = 1;
string to_address = 2;
repeated cosmos.base.v1beta1.Coin amount = 3;
}
message MsgSendResponse {}
message MsgMultiSend {
repeated Input inputs = 1;
repeated Output outputs = 2;
}
message MsgMultiSendResponse {}
package bank; // MsgServer is the server API for Msg service. type MsgServer interface { // Send defines a method for sending coins from one account to another account. Send(context.Context, *MsgSend) (*MsgSendResponse, error) // MultiSend defines a method for sending coins from some accounts to other accounts. MultiSend(context.Context, *MsgMultiSend) (*MsgMultiSendResponse, error) }
func (k msgServer) Send(ctx context.Context, msg *types.MsgSend) (*types.MsgSendResponse, error) { ... } func (k msgServer) MultiSend(goCtx context.Context, msg *types.MsgMultiSend) (*types.MsgMultiSendResponse, error) { ... }
RegisterServices
entry pointfunc (am AppModule) RegisterServices(cfg module.Configurator) { types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) types.RegisterQueryServer(cfg.QueryServer(), am.keeper) }
v1
proto files/**
* Msg defines the bank Msg service.
*/
export interface Msg {
/**
* Send defines a method for sending coins from one account to another account.
*/
Send(request: MsgSend): Promise<MsgSendResponse>;
/**
* MultiSend defines a method for sending coins from some accounts to other accounts.
*/
MultiSend(request: MsgMultiSend): Promise<MsgMultiSendResponse>;
}
app.go
is pretty massive 🤔
v1
(they're currently mostly v1beta1
)v1
before the SDK reaches v1
and when they do clients can expect stabilitySIGN_MODE_TEXTUAL
to fully replace Amino JSONAny
s and custom typestypes/
package
AppModule
interface and inter-module wiringProtobuf generates client golang interfaces:
type MsgClient interface { Send(ctx context.Context, in *MsgSend, opts ...grpc.CallOption) (*MsgSendResponse, error) MultiSend(ctx context.Context, in *MsgMultiSend, opts ...grpc.CallOption) (*MsgMultiSendResponse, error) }
app.go
module wiring and standardize inter-module interfacesapp.go
is much more conciseBuilding a blockchain from existing modules should be really simple
app := NewApp([]Module{
bank.Module{/* some settings */},
gov.Module{/* some settings */},
staking.Module{/* some settings */},
...
})
app.Start()
types/
and baseapp/
) and modules (x/bank
, etc.) into separate go modulesIf you have comments, questions, etc. please post in https://github.com/cosmos/cosmos-sdk/issues/7421
We hope this roadmap brings us one step close to realizing the Cosmos vision