Skip to main content

Mina Signer

Mina Signer is a NodeJS/Browser-compatible library for signing transactions and generating keys. The Rosetta stack also ships an offline signer CLI tool. Both can be used to sign transactions offline for later submission via the Construction API.

Migration from o1labs/client-sdk​

The signing library o1labs/client-sdk is deprecated and will stop working after the Mina mainnet upgrade. All users should migrate to mina-signer.

When migrating:

  1. Adjust the nonce to the correct nonce on the sender account
  2. Update the url variable with an existing Mina Node GraphQL endpoint

See Broadcasting a Signed Payment for a complete example.

Generating a key pair with mina-signer​

See Generating Keys for full details. A quick example:

import { Client } from 'mina-signer'
const mina = new Client({network: 'testnet'})
const keypair = mina.genKeys()

Generating a key pair with signer CLI​

In a native build, the signer is at _build/default/src/app/rosetta/ocaml-signer/signer.exe. In Docker, it's at /rosetta/app/mina-ocaml-signer. Examples below use signer as an alias.

Generate a private key:

signer generate-private-key

Derive the public key and account address:

signer derive-public-key --private-key <private key>

Signing a transaction with mina-signer​

mina.signRosettaTransaction(payload, privateKey)
note

We recommend using mina.rosettaCombinePayload to sign and prepare a payload for the /construction/combine request. See Sending Transactions for the full flow.

Signing a transaction with signer CLI​

signer sign --private-key <private key> --unsigned-transaction <tx>

Replace <tx> with the unsigned transaction string from the /construction/payloads endpoint. See Sending Transactions for the full flow.