{"id":18972599,"url":"https://github.com/leionion/runelib","last_synced_at":"2026-01-07T10:49:08.408Z","repository":{"id":242021065,"uuid":"808233784","full_name":"leionion/runelib","owner":"leionion","description":"A Bitcoin Runes library written in TypeScript","archived":false,"fork":false,"pushed_at":"2024-05-30T23:29:02.000Z","size":86,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-16T11:03:41.031Z","etag":null,"topics":["bitcoin","runes","runestone","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leionion.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-30T16:43:30.000Z","updated_at":"2025-03-04T12:24:27.000Z","dependencies_parsed_at":"2024-05-31T07:40:16.321Z","dependency_job_id":"71a43cee-040d-4a83-bb11-aa32557a3a6d","html_url":"https://github.com/leionion/runelib","commit_stats":null,"previous_names":["atst4/runelib","leionion/runelib"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/leionion/runelib","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leionion%2Frunelib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leionion%2Frunelib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leionion%2Frunelib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leionion%2Frunelib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leionion","download_url":"https://codeload.github.com/leionion/runelib/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leionion%2Frunelib/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28234718,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2026-01-07T02:00:05.975Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bitcoin","runes","runestone","typescript"],"created_at":"2024-11-08T15:09:21.538Z","updated_at":"2026-01-07T10:49:08.391Z","avatar_url":"https://github.com/leionion.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RuneLib\n[runelib](https://www.npmjs.com/package/runelib) is a TypeScript library for Runes on Bitcoin. It enciphers and deciphers [Rune protocol messages](https://docs.ordinals.com/runes/specification.html#runestones) called \"runestones\", which are used to mint and etch Rune tokens.\n\nIt works in both node.js and browsers.\n\n## Installation\n``` bash\nnpm install runelib\n```\n\n\n# Decipher/Decode\n\n\n```ts\nconst mintRawTx = '02000000000101dc58870c48618a937cda4ea238587e17413dde50f8fb8de0e87144acea817bbb0100000000fdffffff030000000000000000086a5d0514d301140110270000000000002251207817a206d8fc43fe54a61a94dd4ff01ec7286826cf44526a59265bf9d3909c66f39b052a01000000225120675fad4019ca08cdc3cf8678af6faa6686b719389a930b0fa13c4ecf9ea7d08b0140f775e5e75ac8ed4d1556779525da619851a95d8328a78382c1c719cf28c76eaf550551643b9e92feba132f75595992d34babe1193ecfad03eb5d830b42da10c100000000'\n\nconst stone = Runestone.decipher(mintRawTx);\n```\n\n\n# Encipher/Encode\n\n```ts\nconst block = 2586233;\nconst txIndex = 1009;\nconst mintstone = new Runestone([], none(), some(new RuneId(block, txIndex)), some(1));\n\nconst buffer = mintstone.encipher();\n```\n\n\n# Mint\n\nThe following example code mints [UNCOMMON•GOODS](https://ordinals.com/rune/UNCOMMON%E2%80%A2GOODS).\n\n```ts\n\nasync function mint() {\n    const mintstone = new Runestone([], none(), some(new RuneId(1, 0)), some(1));\n\n    const keyPair = ECPair.fromWIF(\n        yourKey,\n        network\n    );\n\n    const { address, } = payments.p2wpkh({ pubkey: keyPair.publicKey, network })\n\n    console.log('address:', address)\n\n    const utxos = await waitUntilUTXO(address as string)\n    console.log(`Using UTXO ${utxos[0].txid}:${utxos[0].vout}`);\n\n    const psbt = new Psbt({ network });\n    psbt.addInput({\n        hash: utxos[0].txid,\n        index: utxos[0].vout,\n        witnessUtxo: { value: utxos[0].value, script: Address.toOutputScript(address as string, network) },\n    });\n\n    psbt.addOutput({\n        script: mintstone.encipher(),\n        value: 0\n    });\n\n    psbt.addOutput({\n        address: ord_address, // ord address\n        value: 10000\n    });\n\n    const fee = 5000;\n\n    const change = utxos[0].value - fee - 10000;\n\n    psbt.addOutput({\n        address: change_address, // change address\n        value: change\n    });\n\n    await signAndSend(keyPair, psbt, address as string);\n}\n```\n\n# Etch\n\nThe following example code etches a new token.\n\n```ts\n\n\nasync function etching() {\n    const name = \"CCCCCCCCCCCCCCCCCCNH\";\n\n    const keyPair = ECPair.fromWIF(\n        your_key,\n        network\n    );\n\n    const ins = new EtchInscription()\n\n    ins.setContent(\"text/plain\", Buffer.from('scrypt is best', 'utf-8'))\n    ins.setRune(name)\n\n    const etching_script_asm = `${toXOnly(keyPair.publicKey).toString(\n        \"hex\"\n    )} OP_CHECKSIG`;\n    const etching_script = Buffer.concat([script.fromASM(etching_script_asm), ins.encipher()]);\n\n    const scriptTree: Taptree = {\n        output: etching_script,\n    }\n\n    const script_p2tr = payments.p2tr({\n        internalPubkey: toXOnly(keyPair.publicKey),\n        scriptTree,\n        network,\n    });\n\n    const etching_redeem = {\n        output: etching_script,\n        redeemVersion: 192\n    }\n\n\n    const etching_p2tr = payments.p2tr({\n        internalPubkey: toXOnly(keyPair.publicKey),\n        scriptTree,\n        redeem: etching_redeem,\n        network\n    });\n\n\n    const address = script_p2tr.address ?? \"\";\n    console.log(\"send coin to address\", address);\n\n    const utxos = await waitUntilUTXO(address as string)\n    console.log(`Using UTXO ${utxos[0].txid}:${utxos[0].vout}`);\n\n    const psbt = new Psbt({ network });\n\n\n    psbt.addInput({\n        hash: utxos[0].txid,\n        index: utxos[0].vout,\n        witnessUtxo: { value: utxos[0].value, script: script_p2tr.output! },\n        tapLeafScript: [\n            {\n                leafVersion: etching_redeem.redeemVersion,\n                script: etching_redeem.output,\n                controlBlock: etching_p2tr.witness![etching_p2tr.witness!.length - 1]\n            }\n        ]\n    });\n\n    const rune = Rune.fromName(name)\n\n    const amount = 1000;\n    const cap = 21000;\n    const terms = new Terms(amount, cap, new Range(none(), none()), new Range(none(), none()))\n    const symbol = \"$\"\n    const premine = none();\n    const divisibility = none();\n    const etching = new Etching(divisibility, premine, some(rune), none(), some(symbol), some(terms), true);\n\n    const stone = new Runestone([], some(etching), none(), none());\n\n    psbt.addOutput({\n        script: stone.encipher(),\n        value: 0\n    })\n\n\n    const fee = 5000;\n\n    const change = utxos[0].value - 546 - fee;\n\n    psbt.addOutput({\n        address: ord_address, // ord address\n        value: 546\n    });\n\n    psbt.addOutput({\n        address: change_address, // change address\n        value: change\n    });\n\n    await signAndSend(keyPair, psbt, address as string);\n}\n```\n\n---\n\n## Contributing\n\nAll contributions are welcome. Feel free to open PRs.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleionion%2Frunelib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleionion%2Frunelib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleionion%2Frunelib/lists"}