github.com/Finschia/finschia-sdk@v0.48.1/x/authz/spec/05_client.md (about) 1 <!-- 2 order: 5 3 --> 4 5 # Client 6 7 ## CLI 8 9 A user can query and interact with the `authz` module using the CLI. 10 11 ### Query 12 13 The `query` commands allow users to query `authz` state. 14 15 ```bash 16 simd query authz --help 17 ``` 18 19 #### grants 20 21 The `grants` command allows users to query grants for a granter-grantee pair. If the message type URL is set, it selects grants only for that message type. 22 23 ```bash 24 simd query authz grants [granter-addr] [grantee-addr] [msg-type-url]? [flags] 25 ``` 26 27 Example: 28 29 ```bash 30 simd query authz grants cosmos1.. cosmos1.. /cosmos.bank.v1beta1.MsgSend 31 ``` 32 33 Example Output: 34 35 ```bash 36 grants: 37 - authorization: 38 '@type': /cosmos.bank.v1beta1.SendAuthorization 39 spend_limit: 40 - amount: "100" 41 denom: stake 42 expiration: "2022-01-01T00:00:00Z" 43 pagination: null 44 ``` 45 46 ### Transactions 47 48 The `tx` commands allow users to interact with the `authz` module. 49 50 ```bash 51 simd tx authz --help 52 ``` 53 54 #### exec 55 56 The `exec` command allows a grantee to execute a transaction on behalf of granter. 57 58 ```bash 59 simd tx authz exec [tx-json-file] --from [grantee] [flags] 60 ``` 61 62 Example: 63 64 ```bash 65 simd tx authz exec tx.json --from=cosmos1.. 66 ``` 67 68 #### grant 69 70 The `grant` command allows a granter to grant an authorization to a grantee. 71 72 ```bash 73 simd tx authz grant <grantee> <authorization_type="send"|"generic"|"delegate"|"unbond"|"redelegate"> --from <granter> [flags] 74 ``` 75 76 Example: 77 78 ```bash 79 simd tx authz grant cosmos1.. send --spend-limit=100stake --from=cosmos1.. 80 ``` 81 82 #### revoke 83 84 The `revoke` command allows a granter to revoke an authorization from a grantee. 85 86 ```bash 87 simd tx authz revoke [grantee] [msg-type-url] --from=[granter] [flags] 88 ``` 89 90 Example: 91 92 ```bash 93 simd tx authz revoke cosmos1.. /cosmos.bank.v1beta1.MsgSend --from=cosmos1.. 94 ``` 95 96 ## gRPC 97 98 A user can query the `authz` module using gRPC endpoints. 99 100 ### Grants 101 102 The `Grants` endpoint allows users to query grants for a granter-grantee pair. If the message type URL is set, it selects grants only for that message type. 103 104 ```bash 105 cosmos.authz.v1beta1.Query/Grants 106 ``` 107 108 Example: 109 110 ```bash 111 grpcurl -plaintext \ 112 -d '{"granter":"cosmos1..","grantee":"cosmos1..","msg_type_url":"/cosmos.bank.v1beta1.MsgSend"}' \ 113 localhost:9090 \ 114 cosmos.authz.v1beta1.Query/Grants 115 ``` 116 117 Example Output: 118 119 ```bash 120 { 121 "grants": [ 122 { 123 "authorization": { 124 "@type": "/cosmos.bank.v1beta1.SendAuthorization", 125 "spendLimit": [ 126 { 127 "denom":"stake", 128 "amount":"100" 129 } 130 ] 131 }, 132 "expiration": "2022-01-01T00:00:00Z" 133 } 134 ] 135 } 136 ``` 137 138 ## REST 139 140 A user can query the `authz` module using REST endpoints. 141 142 ```bash 143 /cosmos/authz/v1beta1/grants 144 ``` 145 146 Example: 147 148 ```bash 149 curl "localhost:1317/cosmos/authz/v1beta1/grants?granter=cosmos1..&grantee=cosmos1..&msg_type_url=/cosmos.bank.v1beta1.MsgSend" 150 ``` 151 152 Example Output: 153 154 ```bash 155 { 156 "grants": [ 157 { 158 "authorization": { 159 "@type": "/cosmos.bank.v1beta1.SendAuthorization", 160 "spend_limit": [ 161 { 162 "denom": "stake", 163 "amount": "100" 164 } 165 ] 166 }, 167 "expiration": "2022-01-01T00:00:00Z" 168 } 169 ], 170 "pagination": null 171 } 172 ```