Skip to main content

Sending a Payment

How to send a MINA payment using the Mina CLI.

info

Reminder that this section is intended for node operators. If you want to store, send, and receive MINA without running a node, please see the Install a Wallet page for links to various user-friendly wallets available for Mina.

In this section, we'll give a brief overview on how to send a transaction with the Mina client and how to get started with interacting with the blockchain.

Using an offline signed-transaction

If you want to send a transaction without running a node yourself, but by delegating to someone else running a node, keep following along here. If you wish to send the transaction directly with a running node, skip to using a connected node.

Using a Ledger device

To generate a signed transaction offline if your private key is on a Ledger device, see Ledger Offline Mode.

Using a keypair generated with the generate-keypair tool

A better tool is coming soon: https://github.com/MinaProtocol/mina/issues/8928. For now, please use the workaround provided in a comment on that issue.

Using a keypair generated with the offline client-sdk

Use the Mina Signer. See the README in the Mina Signer repository for installation and usage instructions.

Send the transaction

You can use a hosted service to broadcast your signed transaction. Sending your signed transaction does not leak your private key.

Transactions signed with the Mina Signer can use: https://minaexplorer.com/broadcast-tx

Transactions signed with the ledger can use: https://minaexplorer.com/broadcast-ledger

Using a connected node

We are assuming in the rest of section that you have the Mina client installed on your system, if you do not have Mina installed please see the Getting Started.

Import your account

Once our node is synced, we'll need to import our public/private keypair so that we can sign transactions and generate an address to receive payments. For security reasons, we'll want to put the keys under a directory that is harder for attackers to access.

Run the following command to import your previously generated keypair file:

mina accounts import --privkey-path ~/keys/my-wallet

You will be prompted for the password you entered when the account was created.

caution

The public key can be shared freely with anyone, but be very careful with your private key file. Never share this private key with anyone, as it is the equivalent of a password for your funds.

The response from this command will look like this:

😄 Imported account!
Public key: B62qjaA4N9843FKM5FZk1HmeuDiojG42cbCDyZeUDQVjycULte9PFkC

Additionally you can use the mina accounts create command to generate new accounts to send and receive transactions.

Since the public key is quite long and difficult to remember, let's save it as an environment variable. Use the following command but replace <YOUR-PUBLIC-KEY> with the public key output from the previous command:

export MINA_PUBLIC_KEY=<YOUR-PUBLIC-KEY>

Now we can access this everywhere as $MINA_PUBLIC_KEY -- check if it saved properly by trying echo $MINA_PUBLIC_KEY.

Note that these environment variables will only be saved for the current shell session, so if you want to save them for future use, you can add them to ~/.profile or ~/.bash_profile.

tip

If you are running the node on a cloud virtual machine, make sure to export and save the key file. You can export the key with:

mina accounts export --public-key <PUBLIC-KEY> --privkey-path <EXPORT-PATH>

Then save it to your local machine, maybe using scp:

scp <EXPORT-PATH> <LOCAL-DESTINATION>

Later, when starting up a new VM, you can upload the key and then import it:

mina accounts import --privkey-path <PRIVATE-KEY-FILE>

If you ever forget what keypairs you've already created, you can see them all with:

mina accounts list

Check account balance

We can check the balance of all our accounts using this command:

mina accounts list

You might see Balance: 0 mina for your account. Depending on the traffic in the network, it may take a few blocks before your transaction goes through.

tip

You can run mina client status to see the current block height updating.

Make a payment

Finally, we get to the good stuff–sending our first transaction! Before you send a payment, you'll need to unlock your account:

mina accounts unlock --public-key $MINA_PUBLIC_KEY

For testing purposes, we will specify your public key as the receiver and sender. This just means that we are sending a transaction to ourselves, you can see your public key by issuing the following command:

echo $MINA_PUBLIC_KEY
caution

If the receiving account has not received any transactions, there will be an additional Account Creation Fee of 1 MINA that will be deducted from the transaction amount.

Let's send some of our Mina to ourselves to see what a payment looks like:

mina client send-payment \
--amount 1.5 \
--receiver $MINA_PUBLIC_KEY \
--fee 0.1 \
--sender $MINA_PUBLIC_KEY

If you're wondering what we passed in to the commands above:

  • For amount, we're sending a test value of 1.5 mina which is enough to cover the Account Creation Fee
  • The receiver is the public key of the account receiving the transaction, eg. B62qjaA4N9843FKM5FZk...
  • For fee, let's use 0.1 mina
  • The sender is the public key of the account sending the transaction, eg. B62qjaA4N9843FKM5FZk...

If this command is formatted properly, we should get a response that looks like the following:

Dispatched payment with ID 3XCgvAHLAqz9VVbU7an7f2L5ffJtZoFega7jZpVJrPCYA4j5HEmUAx51BCeMc232eBWVz6q9t62Kp2cNvQZoNCSGqJ1rrJpXFqMN6NQe7x987sAC2Sd6wu9Vbs9xSr8g1AkjJoB65v3suPsaCcvvCjyUvUs8c3eVRucH4doa2onGj41pjxT53y5ZkmGaPmPnpWzdJt4YJBnDRW1GcJeyqj61GKWcvvrV6KcGD25VEeHQBfhGppZc7ewVwi3vcUQR7QFFs15bMwA4oZDEfzSbnr1ECoiZGy61m5LX7afwFaviyUwjphtrzoPbQ2QAZ2w2ypnVUrcJ9oUT4y4dvDJ5vkUDazRdGxjAA6Cz86bJqqgfMHdMFqpkmLxCdLbj2Nq3Ar2VpPVvfn2kdKoxwmAGqWCiVhqYbTvHkyZSc4n3siGTEpTGAK9usPnBnqLi53Z2bPPaJ3PuZTMgmdZYrRv4UPxztRtmyBz2HdQSnH8vbxurLkyxK6yEwS23JSZWToccM83sx2hAAABNynBVuxagL8aNZF99k3LKX6E581uSVSw5DAJ2S198DvZHXD53QvjcDGpvB9jYUpofkk1aPvtW7QZkcofBYruePM7kCHjKvbDXSw2CV5brHVv5ZBV9DuUcuFHfcYAA2TVuDtFeNLBjxDumiBASgaLvcdzGiFvSqqnzmS9MBXxYybQcmmz1WuKZHjgqph99XVEapwTsYfZGi1T8ApahcWc5EX9
Receipt chain hash is now A3gpLyBJGvcpMXny2DsHjvE5GaNFn2bbpLLQqTCHuY3Nd7sqy8vDbM6qHTwHt8tcfqqBkd36LuV4CC6hVH6YsmRqRp4Lzx77WnN9gnRX7ceeXdCQUVB7B2uMo3oCYxfdpU5Q2f2KzJQ46

You may not see the Receipt chain hash on the first transaction from the account, but in following transactions, this will show you the head of the receipt chain hash list.

Staking and Snarking

Once you feel comfortable with the basics of creating an address, and sending & receiving mina, we can move on to the truly unique parts of the Mina network like participating in consensus and helping compress the blockchain.

Advanced

Sending Many Transactions

Sometimes you may wish to send many transactions: for example, to payout rewards to those delegating to you if you're running a staking pool.

All information here is relevant as of the 1.3.0 build:

Rate limiting

Currently, nodes on the network will rate limit receiving messages from a given node. As of the 1.3.0 build, your node will also follow this rate limit when sending transactions. Specifically, the limit is currently set at 10 transactions every 15 seconds computed over a 5 minute window. If you attempt to send transactions faster than this rate, your node will queue them up and flush them as older transactions expire from the window upon which the rate limit is computed. You do not need to throttle sending these transactions yourself.

Note that older releases of the mina daemon do not perform this rate limiting; if you are running an older version, you should manually limit the number of transactions. Due to overheads from rebroadcasting transactions, we do not recommend sending more than 50 transactions every 5 minutes if you need to manually rate limit.

My node crashed or disconnected before I could finish sending transactions

The Mina daemon does not currently persist the transaction pool. This means that the transactions that your node will be unaware of any transactions that you've sent so far if your node crashes in the middle of this process. As of the 1.3.0 build, you can resend all transactions (exactly in the same manner as before) and they will be rebroadcasted on the network.

If you believe you were temporarily disconnected from the network, but your node stayed online (i.e. the gossip network may have missed one or more of your transactions), as of the 1.3.0 build, you can resend any of the transactions locally and they will be broadcasted again to the network even if your node thinks they've already been shared.

Cancelling a transaction and setting a new fee

To cancel a transaction, you'll need to have all the transactions that haven't been committed to the chain yet before in your local transaction mempool. This means if your node crashed (see above) you'll need to resend those earlier transactions. Finally, to cancel a transaction, all you need to do is send a transaction with the same nonce of the one you want to cancel with a larger fee. There is no minimum increment, it just needs to be slightly larger (and large enough such that a block producer will choose your transaction).