|
| 1 | +--- |
| 2 | +title: Wallet operations |
| 3 | +description: CLI wallet commands for managing accounts and sending transactions |
| 4 | +sidebar_position: 15 |
| 5 | +--- |
| 6 | + |
| 7 | +# Wallet operations |
| 8 | + |
| 9 | +The Mina CLI provides wallet functionality for sending transactions and managing |
| 10 | +accounts. All wallet operations use encrypted key files and interact with a |
| 11 | +running Mina node via GraphQL. |
| 12 | + |
| 13 | +## Prerequisites |
| 14 | + |
| 15 | +Before using wallet commands, you need: |
| 16 | + |
| 17 | +- An encrypted private key file |
| 18 | +- The password to decrypt the key |
| 19 | +- A running Mina node (local or remote) - only required for sending transactions |
| 20 | + |
| 21 | +## Get address from key file |
| 22 | + |
| 23 | +Extract the public address from an encrypted key file. |
| 24 | + |
| 25 | +### Basic usage |
| 26 | + |
| 27 | +```bash |
| 28 | +mina wallet address --from /path/to/encrypted/key |
| 29 | +``` |
| 30 | + |
| 31 | +### Arguments |
| 32 | + |
| 33 | +**Required:** |
| 34 | + |
| 35 | +- `--from <PATH>` - Path to encrypted key file |
| 36 | + |
| 37 | +**Optional:** |
| 38 | + |
| 39 | +- `[PASSWORD]` - Password to decrypt the key. Can be provided as an argument or |
| 40 | + via the `MINA_PRIVKEY_PASS` environment variable (recommended for security) |
| 41 | + |
| 42 | +### Example |
| 43 | + |
| 44 | +```bash |
| 45 | +# Get address from encrypted key |
| 46 | +mina wallet address --from ./keys/my-wallet |
| 47 | + |
| 48 | +# Using environment variable for password |
| 49 | +export MINA_PRIVKEY_PASS="my-secret-password" |
| 50 | +mina wallet address --from ./keys/my-wallet |
| 51 | +``` |
| 52 | + |
| 53 | +This command simply decrypts the key file and displays the associated public |
| 54 | +address. It does not require a connection to a node. |
| 55 | + |
| 56 | +## Send payment |
| 57 | + |
| 58 | +Send a payment transaction to the network. |
| 59 | + |
| 60 | +### Basic usage |
| 61 | + |
| 62 | +```bash |
| 63 | +mina wallet send \ |
| 64 | + --from /path/to/encrypted/key \ |
| 65 | + --to <receiver_public_key> \ |
| 66 | + --amount <amount_in_nanomina> \ |
| 67 | + --fee <fee_in_nanomina> |
| 68 | +``` |
| 69 | + |
| 70 | +### Arguments |
| 71 | + |
| 72 | +**Required:** |
| 73 | + |
| 74 | +- `--from <PATH>` - Path to encrypted sender key file |
| 75 | +- `--to <PUBLIC_KEY>` - Receiver's public key (Base58Check encoded) |
| 76 | +- `--amount <AMOUNT>` - Amount in nanomina (1 MINA = 1,000,000,000 nanomina) |
| 77 | +- `--fee <FEE>` - Transaction fee in nanomina |
| 78 | + |
| 79 | +**Optional:** |
| 80 | + |
| 81 | +- `[PASSWORD]` - Password to decrypt the sender key. Can be provided as an |
| 82 | + argument or via the `MINA_PRIVKEY_PASS` environment variable (recommended for |
| 83 | + security) |
| 84 | +- `--memo <MEMO>` - Transaction memo (max 32 bytes, default: empty) |
| 85 | +- `--nonce <NONCE>` - Transaction nonce (default: fetched from node) |
| 86 | +- `--valid-until <SLOT>` - Slot until which transaction is valid (default: never |
| 87 | + expires) |
| 88 | +- `--fee-payer <PUBLIC_KEY>` - Optional fee payer public key (default: sender |
| 89 | + pays) |
| 90 | +- `--network <NETWORK>` - Network for signing: `mainnet` or `testnet` (default: |
| 91 | + `testnet`) |
| 92 | +- `--node <URL>` - Node GraphQL endpoint (default: `http://localhost:3000`) |
| 93 | + |
| 94 | +### Environment variables |
| 95 | + |
| 96 | +You can set the following environment variables: |
| 97 | + |
| 98 | +```bash |
| 99 | +export MINA_PRIVKEY_PASS="your-password" |
| 100 | +export MINA_NETWORK="mainnet" |
| 101 | +``` |
| 102 | + |
| 103 | +### Examples |
| 104 | + |
| 105 | +#### Send payment on testnet |
| 106 | + |
| 107 | +```bash |
| 108 | +mina wallet send \ |
| 109 | + --from ./keys/my-wallet \ |
| 110 | + --to B62qre3erTHfzQckNuibViWQGyyKwZseztqrjPZBv6SQF384Rg6ESAy \ |
| 111 | + --amount 1000000000 \ |
| 112 | + --fee 10000000 \ |
| 113 | + --network testnet |
| 114 | +``` |
| 115 | + |
| 116 | +#### Send payment on mainnet with memo |
| 117 | + |
| 118 | +```bash |
| 119 | +mina wallet send \ |
| 120 | + --from ./keys/my-wallet \ |
| 121 | + --to B62qre3erTHfzQckNuibViWQGyyKwZseztqrjPZBv6SQF384Rg6ESAy \ |
| 122 | + --amount 5000000000 \ |
| 123 | + --fee 10000000 \ |
| 124 | + --memo "Payment for services" \ |
| 125 | + --network mainnet |
| 126 | +``` |
| 127 | + |
| 128 | +#### Send payment with separate fee payer |
| 129 | + |
| 130 | +```bash |
| 131 | +mina wallet send \ |
| 132 | + --from ./keys/sender-wallet \ |
| 133 | + --to B62qre3erTHfzQckNuibViWQGyyKwZseztqrjPZBv6SQF384Rg6ESAy \ |
| 134 | + --amount 1000000000 \ |
| 135 | + --fee 10000000 \ |
| 136 | + --fee-payer B62qkfHpLpELqpMK6ZvUTJ5wRqKDRF3UHyJ4Kv3FU79Sgs4qpBnx5RG |
| 137 | +``` |
| 138 | + |
| 139 | +#### Send payment to remote node |
| 140 | + |
| 141 | +```bash |
| 142 | +mina wallet send \ |
| 143 | + --from ./keys/my-wallet \ |
| 144 | + --to B62qre3erTHfzQckNuibViWQGyyKwZseztqrjPZBv6SQF384Rg6ESAy \ |
| 145 | + --amount 1000000000 \ |
| 146 | + --fee 10000000 \ |
| 147 | + --node https://node.example.com:3000 |
| 148 | +``` |
| 149 | + |
| 150 | +#### Use environment variable for password |
| 151 | + |
| 152 | +```bash |
| 153 | +export MINA_PRIVKEY_PASS="my-secret-password" |
| 154 | + |
| 155 | +mina wallet send \ |
| 156 | + --from ./keys/my-wallet \ |
| 157 | + --to B62qre3erTHfzQckNuibViWQGyyKwZseztqrjPZBv6SQF384Rg6ESAy \ |
| 158 | + --amount 1000000000 \ |
| 159 | + --fee 10000000 |
| 160 | +``` |
| 161 | + |
| 162 | +## Understanding amounts |
| 163 | + |
| 164 | +All amounts in the CLI are specified in **nanomina**: |
| 165 | + |
| 166 | +- 1 MINA = 1,000,000,000 nanomina |
| 167 | +- 0.1 MINA = 100,000,000 nanomina |
| 168 | +- 0.01 MINA = 10,000,000 nanomina (common minimum fee) |
| 169 | + |
| 170 | +## How it works |
| 171 | + |
| 172 | +When you send a payment, the CLI: |
| 173 | + |
| 174 | +1. **Decrypts your key** - Uses the provided password to decrypt your private |
| 175 | + key |
| 176 | +2. **Fetches nonce** - Queries the node via GraphQL to get your current account |
| 177 | + nonce (if not specified) |
| 178 | +3. **Creates payload** - Builds the payment transaction payload with all details |
| 179 | +4. **Signs transaction** - Signs the transaction using your private key and the |
| 180 | + correct network ID |
| 181 | +5. **Submits to node** - Sends the signed transaction to the node via GraphQL |
| 182 | + `sendPayment` mutation |
| 183 | +6. **Returns hash** - Displays the transaction hash for tracking |
| 184 | + |
| 185 | +## Network selection |
| 186 | + |
| 187 | +The `--network` flag controls which network the transaction is signed for: |
| 188 | + |
| 189 | +- `testnet` - For development and testing (default) |
| 190 | +- `mainnet` - For production transactions |
| 191 | + |
| 192 | +**Important:** Make sure to use the correct network flag. A transaction signed |
| 193 | +for testnet will not be valid on mainnet and vice versa. |
| 194 | + |
| 195 | +## Fee payer |
| 196 | + |
| 197 | +By default, the sender pays the transaction fee. However, you can specify a |
| 198 | +different fee payer using the `--fee-payer` option: |
| 199 | + |
| 200 | +- The sender's key is used to sign the payment |
| 201 | +- The fee payer's public key is included in the transaction |
| 202 | +- The fee payer must also sign the transaction (currently requires manual |
| 203 | + coordination) |
| 204 | + |
| 205 | +This is useful for sponsored transactions where another party pays the fees. |
| 206 | + |
| 207 | +## Transaction status |
| 208 | + |
| 209 | +After submitting a transaction, you'll receive a transaction hash. You can check |
| 210 | +its status by querying the node's GraphQL endpoint: |
| 211 | + |
| 212 | +```bash |
| 213 | +curl -X POST http://localhost:3000/graphql \ |
| 214 | + -H "Content-Type: application/json" \ |
| 215 | + -d '{ |
| 216 | + "query": "query { transactionStatus(payment: \"<base64_transaction>\") }" |
| 217 | + }' |
| 218 | +``` |
| 219 | + |
| 220 | +## GraphQL integration |
| 221 | + |
| 222 | +The wallet commands use the node's GraphQL API: |
| 223 | + |
| 224 | +- **Account query** - Fetches current nonce and account information |
| 225 | +- **sendPayment mutation** - Submits signed transactions to the network |
| 226 | + |
| 227 | +For more details on the GraphQL API, see the [GraphQL API](./graphql-api.md) |
| 228 | +documentation. |
0 commit comments