Sign and send MCN
Prepare a native transfer online, sign it offline and broadcast the serialized transaction.
This guide uses Ethereum type 2 transactions with Chain ID 2325. It transfers native MCN to an account without code. Use a wallet or contract-specific implementation for contract interactions.
The example separates online preparation, offline signing and online broadcasting. Only the signing computer needs the encrypted keystore and its password. No key is sent to RPC.
1. Prepare the tools
Use Node.js 24. Download mcn-transfer.mjs and place it in a new working directory. Install ethers there:
npm init -y
npm install --save-exact ethers@6.17.0Prepare the same dependencies on the signing computer before disconnecting it from the network. Create an encrypted account keystore if you do not already have one. Back it up separately from its password. Fund the public sender address with native MCN.
2. Prepare the unsigned transaction online
Replace SENDER_ADDRESS and RECIPIENT_ADDRESS with your addresses. The amount 0.1 is in MCN.
node mcn-transfer.mjs prepare SENDER_ADDRESS RECIPIENT_ADDRESS 0.1 unsigned.jsonThe command checks Mainnet chain ID and genesis, reads the pending nonce, estimates gas and calculates type 2 fee fields. It adds 20% gas-limit headroom and uses twice the observed base fee plus the priority fee as maxFeePerGas. The priority fee is at least 1 gwei, matching the published node configuration. This is an example fee policy, not a fixed network charge.
It refuses zero-address recipients, recipients with code, non-positive amounts and a balance below the amount plus maximum gas budget. It writes unsigned.json without overwriting an existing file. The sender must have no other process independently assigning nonces.
For a local node, set the endpoint for online commands:
export MCN_RPC_URL=http://127.0.0.1:85453. Sign on the offline computer
Transfer unsigned.json to the signing computer. Review the sender, recipient, amount, nonce, Chain ID, gas limit and maximum fee budget independently of the online machine.
node mcn-transfer.mjs sign unsigned.json /secure/path/to/keystore.json signed.jsonThe command displays those fields, asks you to type SIGN, then prompts for the keystore password with hidden input. It checks that the keystore matches the sender and signs locally. It writes signed.json, containing the serialized transaction and its deterministic hash. The signing command creates no RPC connection.
Keep the keystore, password and recovery material on the signing side. A signed transaction can be broadcast by anyone holding it, so transfer it only through your intended workflow.
4. Broadcast online
Move only signed.json back to the online computer:
node mcn-transfer.mjs broadcast signed.jsonThe command checks the signed hash, transaction fields and RPC network identity, then uses eth_sendRawTransaction. Save the hash printed at signing time even if the broadcast times out.
Nonce and fee data can become stale between preparation and submission. If the sender has sent another transaction, reconcile its nonce before preparing a replacement. If the base fee exceeds the signed cap, the transaction may wait until it is eligible or be rejected by the node.
5. Check execution and finality
node mcn-transfer.mjs receipt TRANSACTION_HASH| Output | Interpretation |
|---|---|
state: "unresolved" | No receipt; pending, unknown, dropped or replaced remain possible |
state: "included" | Canonical receipt exists; wait for finality |
state: "finalized", success: true | Successful execution in a finalized block |
state: "finalized", success: false | Finalized execution failure; gas was charged |
The command checks the receipt against its canonical block and the finalized height. Re-run it to observe progression. feeMCN is the actual execution fee, calculated from gas used and effective gas price.
Broadcast errors
| Error | Next step |
|---|---|
| Timeout / connection lost | Query the known signed hash; do not create a second payment |
| Already known | Query the original hash and receipt |
| Nonce too low | Check included transactions and all replacements for that sender and nonce |
| Insufficient funds | Reconcile balance and reserved transaction budgets |
| Fee cap too low / underpriced | Review current fees; manage any replacement under the same payment request |
The example covers one manually coordinated transfer. An exchange needs durable nonce reservations and withdrawal reconciliation.