Inscribe from the command line
The xmr721 command is a Monero wallet of its own that inscribes on the ledger. A file becomes an NFT, owned by the wallet or by any Monero address you name. It pays only the Monero network fee.
#What you need
- macOS or Linux and Node.js 22 or newer.
- A synchronized Monero node of your own (
monerod) with unrestricted RPC. The wallet takes its decoys from it and sends through it. A public restricted node will not do. - Rust, once, to build the wallet's transaction tool.
- Git.
#Install
git clone https://github.com/xmr20project/xmr721
cd xmr721
npm install
sh reader/carrier/build.shThe last line builds reader/bin/mordinals-carrier, the tool that builds and signs the wallet's transactions.
#Make a wallet
node cli/xmr721.mjs wallet createThis prints the wallet's address and makes the wallet folder ~/.xmr721/wallet. Its keys are in that folder: back it up.
Send the wallet a little XMR. One inscription costs only the network fee, about 0.00004 XMR at normal fee levels, so 0.01 XMR lasts a long time. A coin can pay 10 blocks after it arrives (about 20 minutes).
node cli/xmr721.mjs wallet balance#Inscribe one NFT
Always start with a dry run. It says whether minting is open to you, what would be inscribed, the record's id and the text that would be signed. It builds and sends nothing.
node cli/xmr721.mjs wallet inscribe --file moon.png --name "Moon" --to <your Monero address> --dry-runThen inscribe:
node cli/xmr721.mjs wallet inscribe --file moon.png --name "Moon" --to <your Monero address>
node cli/xmr721.mjs wallet inscriptions--tomakes the NFT belong to that address from the start, so a normal wallet (Feather, Cake Wallet, the XMR20 wallet) can send and sell it by signing a message. Without--to, thexmr721wallet owns it.--typenames the content type when the file ending does not:png,jpeg,webp,gif,text,json,mp4,art.- Size. A record is at most 1,000 bytes: up to 824 bytes of name and content, 759 with
--to.
wallet inscriptions lists what the wallet built and where each transaction is now: waiting for a block, in a block, on the ledger, refused by the ledger and why, or not with the node.
#Make a collection
node cli/xmr721.mjs wallet collection --name "Moon Rocks" --max 100 --dry-run
node cli/xmr721.mjs wallet collection --name "Moon Rocks" --max 100Once the collection is in a block, mint its editions by its id:
node cli/xmr721.mjs wallet inscribe --file rock-1.png --collection <collection id> --to <address>
node cli/xmr721.mjs wallet inscribe --file rock-2.png --collection <collection id> --to <address>Each mint takes the next free edition, or the one you name with --edition <n>. Only the wallet that made a collection can mint into it.
#Many at once
Each record rides on one coin of the wallet, and that coin's change can only be spent 10 blocks later. To send several records in the same block, split one larger coin first:
node cli/xmr721.mjs wallet split 5This makes 5 coins of 0.01 XMR (2 to 14 at a time). It needs one coin a little larger than the total: 0.06 XMR in one payment splits into five.
#Send an NFT the wallet owns
node cli/xmr721.mjs wallet send <nft id> <address> --dry-run
node cli/xmr721.mjs wallet send <nft id> <address>#When something goes wrong
Nothing is lost when a command fails. Every transaction the tool builds is written down and kept.
| Command | What it does |
|---|---|
wallet inscriptions | Where every transaction is now |
wallet resend | Hands the node, as the same transactions, what it does not have |
wallet forget <n> | Removes entry n: a transaction that was never sent, or one settled 100 blocks ago |
wallet rescan | Reads the wallet's coins anew, and frees coins of transactions that never got into a block |
wallet restore --height <n> | Writes the scan start for a folder that only has its keys |
A few more things worth knowing:
- A record counts once. The same file with the same name by the same wallet is the same record. Asked again, the command sends its transaction again or says where it is; it never pays twice.
- Stopping. Ctrl-C stops the command at once, unless a transaction is being built or handed to the node; then that one step is finished and written down first. Three times Ctrl-C stops it regardless.
- A node that does not answer. If the node gives no answer while a transaction is handed over, nobody knows whether it took it. The wallet counts it as sent, and
wallet resendhands it over again if the node does not have it. - Moving leftover XMR. The command cannot send XMR out. To move what is left, restore a wallet from keys in the Monero CLI (
--generate-from-keys) with the address fromwallet receive, the two keys incarrier.keys.jsonand thestartblock inwallet.jsonas restore height.
#Which reader it asks
Before it makes a record, the command asks a reader for the ledger's state: the next free edition, an NFT's counter, a collection's name, and whether minting is open to you. By default it asks https://api.xmr20.org/xmr721.
A reader that lied could make the wallet pay for a record the ledger refuses. A reader also sees which transactions you ask about. Run your own reader and point the command at it to avoid both:
node cli/xmr721.mjs wallet inscribe --file moon.png --reader http://127.0.0.1:18951 --dry-runWhere a transaction is, the wallet always takes from your node alone.
#What is public
The wallet's own address is written into every record as the creator, and the --to address as the owner. Both are public for good.
#Stagenet
Try everything on stagenet first with --network stagenet, a stagenet node (--node, default port 38081), and --reader and --domain of a stagenet ledger of your own.
Every command and option is in the command reference, or run node cli/xmr721.mjs --help.