Before there is an official tool to directly generate an offline transaction with the standard mina-generate-keypair
generated private key, we can instead convert the key to the client-sdk compatible format and then use the client-sdk to generate the transaction.
A while ago I shared this idea with @nholland94, who in turn made a script that I then tweaked to use Docker and created this one. Thanks @nholland94 !
@nholland94's script minimizes the time that the private key is unencrypted by immediately creating the transaction as soon as the key is dumped.
- Install NodeJS and yarn on your system
On MacOS in a Terminal session (Terminal.app):
brew install node
npm install -g yarn
-
Install docker on your system
-
Download this gist as a zip file and unzip and enter this directory in your Terminal.app
-
Pull the latest version of the client-sdk (tested with 1.0.1)
yarn add @o1labs/client-sdk
- Copy in your private key
Put a keys/
folder containing your (password protected) private key with chmod 700
permissions (this should already be set properly if you generated your keys using the minaprotocol.com docs) in this directory.
- Edit the
make-transaction.js
to point to your key
Change the line in main()
to set the privateKeyPath
to your key. Keep the leading /
at the beginning.
- Edit the
make-transaction.js
to form your transaction
Change these fields as appropriate for your transaction
{
to: 'B62qoozSJ5Zjz8m3LtRnmoejs425H38LfU6kYTrsoPPVy9hzrLc5HBM', // the receiver of the payment
amount: 10**9, // 1.0 mina -- in nanonmina (1 billion = 1.0 mina)
fee: 1 * 10**7, // 0.01 mina -- in nanonmina (1 billion = 1.0 mina)
nonce: 0 // the number of transactions you've made on this account already. you can find this in minaexplorer.com
}
- Open a new terminal session
On MacOS, this is the Terminal.app
program (or your favorite)
- Export your private key password as an environment variable
Change mypassword
below with your password
export CODA_PRIVKEY_PASS='mypassword'
- Run the script generating the transaction in that Terminal.app session
node make-transaction.js
This will make the transaction in a file called my-txn.json
in this directory. You can view it with cat
:
cat my-txn.json
- Broadcast using your favorite tool
For example, https://minaexplorer.com/broadcast-tx