2021-02-11 08:56:37 -08:00
<!--
order: 3
-->
# Messages
In this section we describe the processing of messages for the authz module.
2021-05-19 13:22:06 -07:00
## MsgGrant
2021-02-11 08:56:37 -08:00
2021-05-19 13:22:06 -07:00
An authorization grant is created using the `MsgGrant` message.
2021-09-30 01:07:58 -07:00
If there is already a grant for the `(granter, grantee, Authorization)` triple, then the new grant overwrites the previous one. To update or extend an existing grant, a new grant with the same `(granter, grantee, Authorization)` triple should be created.
2021-02-11 08:56:37 -08:00
2022-02-14 14:39:35 -08:00
+++ https://github.com/cosmos/cosmos-sdk/blob/v0.43.0-beta1/proto/cosmos/authz/v1beta1/tx.proto#L32-L37
2021-02-11 08:56:37 -08:00
2021-05-19 13:22:06 -07:00
The message handling should fail if:
2022-02-10 04:07:01 -08:00
* both granter and grantee have the same address.
* provided `Expiration` time is less than current unix timestamp.
* provided `Grant.Authorization` is not implemented.
* `Authorization.MsgTypeURL()` is not defined in the router (there is no defined handler in the app router to handle that Msg types).
2021-05-06 11:23:48 -07:00
2021-05-19 13:22:06 -07:00
## MsgRevoke
2021-02-11 08:56:37 -08:00
2021-05-19 13:22:06 -07:00
A grant can be removed with the `MsgRevoke` message.
2021-02-11 08:56:37 -08:00
2022-02-14 14:39:35 -08:00
+++ https://github.com/cosmos/cosmos-sdk/blob/v0.43.0-beta1/proto/cosmos/authz/v1beta1/tx.proto#L60-L64
2021-02-11 08:56:37 -08:00
2021-05-19 13:22:06 -07:00
The message handling should fail if:
2021-02-11 08:56:37 -08:00
2022-02-10 04:07:01 -08:00
* both granter and grantee have the same address.
* provided `MsgTypeUrl` is empty.
2021-02-11 08:56:37 -08:00
2021-05-19 13:22:06 -07:00
NOTE: The `MsgExec` message removes a grant if the grant has expired.
2021-02-11 08:56:37 -08:00
2021-05-19 13:22:06 -07:00
## MsgExec
2021-02-11 08:56:37 -08:00
2021-05-19 13:22:06 -07:00
When a grantee wants to execute a transaction on behalf of a granter, they must send `MsgExec` .
2021-02-11 08:56:37 -08:00
2022-02-14 14:39:35 -08:00
+++ https://github.com/cosmos/cosmos-sdk/blob/v0.43.0-beta1/proto/cosmos/authz/v1beta1/tx.proto#L47-L53
2021-02-11 08:56:37 -08:00
2021-05-19 13:22:06 -07:00
The message handling should fail if:
2022-02-10 04:07:01 -08:00
* provided `Authorization` is not implemented.
* grantee doesn't have permission to run the transaction.
* if granted authorization is expired.