Skip to main content
logo

authz

The authz module is responsible for the authorization for accounts to perform actions on behalf of other accounts and enables a granter to grant authorizations to a grantee that allows the grantee to execute messages on behalf of the granter. Authorizations must be granted for a particular Msg service method one by one using an implementation of the Authorization interface.

For more information, visit https://docs.cosmos.network/main/modules/authz/

Message Types

Msg defines the authz Msg service.

tx.proto
Copy

_16
service Msg {
_16
// Grant grants the provided authorization to the grantee on the granter's
_16
// account with the provided expiration time. If there is already a grant
_16
// for the given (granter, grantee, Authorization) triple, then the grant
_16
// will be overwritten.
_16
rpc Grant(MsgGrant) returns (MsgGrantResponse);
_16
_16
// Exec attempts to execute the provided messages using
_16
// authorizations granted to the grantee. Each message should have only
_16
// one signer corresponding to the granter of the authorization.
_16
rpc Exec(MsgExec) returns (MsgExecResponse);
_16
_16
// Revoke revokes any authorization corresponding to the provided method name on the
_16
// granter's account that has been granted to the grantee.
_16
rpc Revoke(MsgRevoke) returns (MsgRevokeResponse);
_16
}

MsgGrant

MsgGrant is a request type for Grant method. It declares authorization to the grantee on behalf of the granter with the provided expiration time.

tx.proto
Copy

_8
message MsgGrant {
_8
option (cosmos.msg.v1.signer) = "granter";
_8
_8
string granter = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
_8
string grantee = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
_8
_8
cosmos.authz.v1beta1.Grant grant = 3 [(gogoproto.nullable) = false];
_8
}

MsgGrantResponse

MsgGrantResponse defines the Msg/MsgGrant response type.

tx.proto
Copy

_1
message MsgGrantResponse {}

MsgExec

MsgExec attempts to execute the provided messages using authorizations granted to the grantee. Each message should have only one signer corresponding to the granter of the authorization.

tx.proto
Copy

_9
message MsgExec {
_9
option (cosmos.msg.v1.signer) = "grantee";
_9
_9
string grantee = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
_9
// Authorization Msg requests to execute. Each msg must implement Authorization interface
_9
// The x/authz will try to find a grant matching (msg.signers[0], grantee, MsgTypeURL(msg))
_9
// triple and validate it.
_9
repeated google.protobuf.Any msgs = 2 [(cosmos_proto.accepts_interface) = "sdk.Msg, authz.Authorization"];
_9
}

MsgExecResponse

MsgExecResponse defines the Msg/MsgExecResponse response type.

tx.proto
Copy

_3
message MsgExecResponse {
_3
repeated bytes results = 1;
_3
}

MsgRevoke

MsgRevoke revokes any authorization with the provided sdk.Msg type on the granter's account with that has been granted to the grantee.

tx.proto
Copy

_7
message MsgRevoke {
_7
option (cosmos.msg.v1.signer) = "granter";
_7
_7
string granter = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
_7
string grantee = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
_7
string msg_type_url = 3;
_7
}

MsgRevokeResponse

MsgRevokeResponse defines the Msg/MsgRevokeResponse response type.

tx.proto
Copy

_1
message MsgRevokeResponse {}

Queries

Query defines the gRPC querier service.

query.proto
Copy

_20
service Query {
_20
// Returns list of `Authorization`, granted to the grantee by the granter.
_20
rpc Grants(QueryGrantsRequest) returns (QueryGrantsResponse) {
_20
option (google.api.http).get = "/cosmos/authz/v1beta1/grants";
_20
}
_20
_20
// GranterGrants returns list of `GrantAuthorization`, granted by granter.
_20
//
_20
// Since: cosmos-sdk 0.46
_20
rpc GranterGrants(QueryGranterGrantsRequest) returns (QueryGranterGrantsResponse) {
_20
option (google.api.http).get = "/cosmos/authz/v1beta1/grants/granter/{granter}";
_20
}
_20
_20
// GranteeGrants returns a list of `GrantAuthorization` by grantee.
_20
//
_20
// Since: cosmos-sdk 0.46
_20
rpc GranteeGrants(QueryGranteeGrantsRequest) returns (QueryGranteeGrantsResponse) {
_20
option (google.api.http).get = "/cosmos/authz/v1beta1/grants/grantee/{grantee}";
_20
}
_20
}

QueryGrantsRequest

QueryGrantsRequest is the request type for the Query/Grants RPC method.

query.proto
Copy

_8
message QueryGrantsRequest {
_8
string granter = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
_8
string grantee = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
_8
// Optional, msg_type_url, when set, will query only grants matching given msg type.
_8
string msg_type_url = 3;
_8
// pagination defines an pagination for the request.
_8
cosmos.base.query.v1beta1.PageRequest pagination = 4;
_8
}

QueryGrantsResponse

QueryGrantsResponse is the response type for the Query/Authorizations RPC method.

query.proto
Copy

_6
message QueryGrantsResponse {
_6
// authorizations is a list of grants granted for grantee by granter.
_6
repeated Grant grants = 1;
_6
// pagination defines an pagination for the response.
_6
cosmos.base.query.v1beta1.PageResponse pagination = 2;
_6
}

QueryGranterGrantsRequest

QueryGranterGrantsRequest is the request type for the Query/GranterGrants RPC method.

query.proto
Copy

_6
message QueryGranterGrantsRequest {
_6
string granter = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
_6
_6
// pagination defines an pagination for the request.
_6
cosmos.base.query.v1beta1.PageRequest pagination = 2;
_6
}

QueryGranterGrantsResponse

QueryGranterGrantsResponse is the response type for the Query/GranterGrants RPC method.

query.proto
Copy

_6
message QueryGranterGrantsResponse {
_6
// grants is a list of grants granted by the granter.
_6
repeated GrantAuthorization grants = 1;
_6
// pagination defines an pagination for the response.
_6
cosmos.base.query.v1beta1.PageResponse pagination = 2;
_6
}

QueryGranteeGrantsRequest

QueryGranteeGrantsRequest is the request type for the Query/IssuedGrants RPC method.

query.proto
Copy

_6
message QueryGranteeGrantsRequest {
_6
string grantee = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
_6
_6
// pagination defines an pagination for the request.
_6
cosmos.base.query.v1beta1.PageRequest pagination = 2;
_6
}

QueryGranteeGrantsResponse

QueryGranteeGrantsResponse is the response type for the Query/GranteeGrants RPC method.

query.proto
Copy

_6
message QueryGranteeGrantsResponse {
_6
// grants is a list of grants granted to the grantee.
_6
repeated GrantAuthorization grants = 1;
_6
// pagination defines an pagination for the response.
_6
cosmos.base.query.v1beta1.PageResponse pagination = 2;
_6
}