-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9a1e92b
commit 985904c
Showing
18 changed files
with
1,604 additions
and
1,818 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
TypeDoc added this file to prevent GitHub Pages from using Jekyll. You can turn off this behavior by setting the `githubPages` option to false. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,169 @@ | ||
@ordjs/runestone / [Exports](modules.md) | ||
|
||
<div align="center"><a name="readme-top"></a> | ||
|
||
<h1>@ordjs/runestone</h1> | ||
|
||
[Ordinals](https://ordinals.com/) runestone javascript implementation. | ||
|
||
This implementation is based on ord `0.18.3` (ordinals runestone `0.0.8`) | ||
|
||
[![NPM version][npm-image]][npm-url] | ||
[![MIT License][license-shield]][license-url] | ||
[![Stargazers][stars-shield]][stars-url] | ||
|
||
[![Contributors][contributors-shield]][contributors-url] | ||
[![Issues][issues-shield]][issues-url] | ||
[![Follow Twitter][twitter-image]][twitter-url] | ||
|
||
[Report Bug](https://github.com/jeasonstudio/runestone/issues/new) · [Pull Request](https://github.com/jeasonstudio/runestone/compare) | ||
|
||
![](https://raw.githubusercontent.com/andreasbm/readme/master/assets/lines/rainbow.png) | ||
|
||
[npm-image]: https://img.shields.io/npm/v/@ordjs/runestone?style=for-the-badge | ||
[npm-url]: http://npmjs.org/package/@ordjs/runestone | ||
|
||
[codecov-image]: https://img.shields.io/codecov/c/github/jeasonstudio/runestone/master.svg?style=for-the-badge | ||
[codecov-url]: https://codecov.io/gh/jeasonstudio/runestone/branch/master | ||
[license-shield]: https://img.shields.io/github/license/jeasonstudio/runestone.svg?style=for-the-badge | ||
[license-url]: https://github.com/jeasonstudio/runestone/blob/master/LICENSE | ||
|
||
[contributors-shield]: https://img.shields.io/github/contributors/jeasonstudio/runestone.svg?style=for-the-badge | ||
[contributors-url]: https://github.com/jeasonstudio/runestone/graphs/contributors | ||
[stars-shield]: https://img.shields.io/github/stars/jeasonstudio/runestone.svg?style=for-the-badge | ||
[stars-url]: https://github.com/jeasonstudio/runestone/stargazers | ||
[issues-shield]: https://img.shields.io/github/issues/jeasonstudio/runestone.svg?style=for-the-badge | ||
[issues-url]: https://github.com/jeasonstudio/runestone/issues | ||
[twitter-image]: https://img.shields.io/twitter/follow/jeasonstudio?style=for-the-badge&logo=x | ||
[twitter-url]: https://twitter.com/jeasonstudio | ||
|
||
</div> | ||
|
||
## Installation | ||
|
||
```bash | ||
$ npm install @ordjs/runestone | ||
``` | ||
|
||
> It will be `pnpm/yarn add @ordjs/runestone` if you use pnpm or yarn. | ||
## Usage | ||
|
||
### Runestone | ||
|
||
```javascript | ||
import { Runestone } from '@ordjs/runestone'; | ||
const fromHexString = (hexString) => | ||
Uint8Array.from(hexString.match(/.{1,2}/g).map((byte) => parseInt(byte, 16))); | ||
|
||
const toHexString = (bytes) => | ||
bytes.reduce((str, byte) => str + byte.toString(16).padStart(2, '0'), ''); | ||
|
||
// decipher | ||
// See https://mempool.space/tx/2bb85f4b004be6da54f766c17c1e855187327112c231ef2ff35ebad0ea67c69e | ||
const tx = { | ||
output: [{ | ||
// // OP_RETURN OP_PUSHNUM_13 ... | ||
script_pubkey: fromHexString('6a5d1f02010480bbb180c5ddf4ede90303a40805b5e9070680809dd085bedd031601'), | ||
value: 0, | ||
}], | ||
}; | ||
const runestone = Runestone.decipher(tx); | ||
console.log(JSON.stringify(runestone.toString())); | ||
/* | ||
{ | ||
"edicts": [], | ||
"etching": { | ||
"divisibility": 2, | ||
"premine": 11000000000, | ||
"rune": { | ||
"value": 67090369340599845000 | ||
}, | ||
"spacers": 7967, | ||
"symbol": "ᚠ", | ||
"terms": { | ||
"amount": 100, | ||
"cap": 1111111, | ||
"height": { | ||
"start": null, | ||
"end": null | ||
}, | ||
"offset": { | ||
"start": null, | ||
"end": null | ||
} | ||
}, | ||
"turbo": true | ||
}, | ||
"mint": null, | ||
"pointer": null | ||
} | ||
*/ | ||
|
||
// encipher | ||
console.log(toHexString(runestone.encipher())); | ||
// 6a5d21020704b5e1d8e1c8eeb788a3070102039f3e05a02d0680dc9afd280a6408c7e843 | ||
``` | ||
|
||
### Rune ID | ||
|
||
```javascript | ||
import { RuneId } from '@ordjs/runestone'; | ||
|
||
const runeId = new RuneId(840000n, 1); | ||
|
||
console.log('runeId:', runeId.toString(), runeId.block, runeId.tx); // 840000:1 840000n 1 | ||
console.log('delta:', runeId.delta(new RuneId(840001n, 10000)).start); // 1n | ||
console.log('next:', runeId.next(1n, 1).toString()); // 840001:1 | ||
console.log(RuneId.fromString('840000:1').toString()); // 840000:1 | ||
``` | ||
|
||
### Rune | ||
|
||
```javascript | ||
import { Rune } from '@ordjs/runestone'; | ||
|
||
const rune = new Rune(67090369340599840949n); | ||
|
||
console.log('value:', rune.value); // 67090369340599840949n | ||
console.log('isReserved:', rune.isReserved()); // false | ||
console.log('name:', rune.toString()); // ZZZZZFEHUZZZZZ | ||
console.log('commitment:', rune.commitment()); | ||
// Uint8Array(9) [181, 48, 54, 140, 116, 223, 16, 163, 3] | ||
|
||
console.log(Rune.firstRuneHeight('main')); // 840000 | ||
console.log(Rune.fromString('ZZZZZFEHUZZZZZ').value); // 67090369340599840949n | ||
``` | ||
|
||
### Spaced Rune | ||
|
||
```javascript | ||
import { SpacedRune, Rune } from '@ordjs/runestone'; | ||
|
||
const rune = new Rune(67090369340599840949n); | ||
const spacedRune = new SpacedRune(rune, 7967); | ||
|
||
console.log('spaced rune:', spacedRune.toString()); // Z•Z•Z•Z•Z•FEHU•Z•Z•Z•Z•Z | ||
console.log( | ||
'rune value:', | ||
SpacedRune.fromString('Z•Z•Z•Z•Z•FEHU•Z•Z•Z•Z•Z').rune.value // 67090369340599840949n | ||
); | ||
console.log( | ||
'rune spacers:', | ||
SpacedRune.fromString('Z•Z•Z•Z•Z•FEHU•Z•Z•Z•Z•Z').spacers // 7967 | ||
); | ||
``` | ||
|
||
## Use in Browser | ||
|
||
```html | ||
<script type="module"> | ||
import { Rune } from 'https://esm.sh/@ordjs/runestone@latest/bundle'; | ||
const rune = new Rune(1n); | ||
console.log(rune.toString()); | ||
</script> | ||
``` | ||
|
||
## License | ||
|
||
[MIT](./LICENSE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
[@ordjs/runestone](../README.md) / [Exports](../modules.md) / Edict | ||
|
||
# Class: Edict | ||
|
||
## Table of contents | ||
|
||
### Constructors | ||
|
||
- [constructor](Edict.md#constructor) | ||
|
||
### Properties | ||
|
||
- [amount](Edict.md#amount) | ||
- [id](Edict.md#id) | ||
- [output](Edict.md#output) | ||
|
||
### Methods | ||
|
||
- [free](Edict.md#free) | ||
- [toJSON](Edict.md#tojson) | ||
|
||
## Constructors | ||
|
||
### constructor | ||
|
||
• **new Edict**(`id`, `amount`, `output`): [`Edict`](Edict.md) | ||
|
||
#### Parameters | ||
|
||
| Name | Type | | ||
| :------ | :------ | | ||
| `id` | [`RuneId`](RuneId.md) | | ||
| `amount` | `bigint` | | ||
| `output` | `number` | | ||
|
||
#### Returns | ||
|
||
[`Edict`](Edict.md) | ||
|
||
#### Defined in | ||
|
||
index.d.ts:53 | ||
|
||
## Properties | ||
|
||
### amount | ||
|
||
• `Readonly` **amount**: `bigint` | ||
|
||
#### Defined in | ||
|
||
index.d.ts:60 | ||
|
||
___ | ||
|
||
### id | ||
|
||
• `Readonly` **id**: [`RuneId`](RuneId.md) | ||
|
||
#### Defined in | ||
|
||
index.d.ts:63 | ||
|
||
___ | ||
|
||
### output | ||
|
||
• `Readonly` **output**: `number` | ||
|
||
#### Defined in | ||
|
||
index.d.ts:66 | ||
|
||
## Methods | ||
|
||
### free | ||
|
||
▸ **free**(): `void` | ||
|
||
#### Returns | ||
|
||
`void` | ||
|
||
#### Defined in | ||
|
||
index.d.ts:47 | ||
|
||
___ | ||
|
||
### toJSON | ||
|
||
▸ **toJSON**(): `any` | ||
|
||
#### Returns | ||
|
||
`any` | ||
|
||
#### Defined in | ||
|
||
index.d.ts:57 |
Oops, something went wrong.