Skip to content

Files

Latest commit

7157f75 · Sep 6, 2024

History

History
This branch is 781 commits behind o1-labs/o1js:main.

mina-signer

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
May 2, 2024
Sep 6, 2024
Apr 28, 2023
Oct 30, 2023
Feb 21, 2024
Feb 18, 2024
Feb 17, 2024
Jan 9, 2023
May 2, 2024
Jan 11, 2023
Jun 28, 2024
Jun 28, 2024

Mina Signer

This is a NodeJS SDK that allows you to sign strings, payments, and delegations using Mina's key pairs for various specified networks.

Install

yarn add mina-signer
# or with npm:
npm install --save mina-signer

Usage

import Client from 'mina-signer';
const client = new Client({ network: 'mainnet' });

// Generate keys
let keypair = client.genKeys();

// Sign and verify message
let signed = client.signMessage('hello', keypair.privateKey);
if (client.verifyMessage(signed)) {
  console.log('Message was verified successfully');
}

// Sign and verify a payment
let signedPayment = client.signPayment(
  {
    to: keypair.publicKey,
    from: keypair.publicKey,
    amount: 1,
    fee: 1,
    nonce: 0,
  },
  keypair.privateKey
);
if (client.verifyPayment(signedPayment)) {
  console.log('Payment was verified successfully');
}

// Sign and verify a stake delegation
const signedDelegation = client.signStakeDelegation(
  {
    to: keypair.publicKey,
    from: keypair.publicKey,
    fee: '1',
    nonce: '0',
  },
  keypair.privateKey
);
if (client.verifyStakeDelegation(signedDelegation)) {
  console.log('Delegation was verified successfully');
}