Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/studyzy/runestone
Bitcoin Ordinals Rune protocol golang implement
https://github.com/studyzy/runestone
bitcoin golang-library ordinals runes runestone
Last synced: 3 months ago
JSON representation
Bitcoin Ordinals Rune protocol golang implement
- Host: GitHub
- URL: https://github.com/studyzy/runestone
- Owner: studyzy
- License: apache-2.0
- Created: 2024-04-23T10:18:25.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-11-04T07:40:00.000Z (3 months ago)
- Last Synced: 2024-11-04T08:29:03.453Z (3 months ago)
- Topics: bitcoin, golang-library, ordinals, runes, runestone
- Language: Go
- Homepage:
- Size: 227 KB
- Stars: 30
- Watchers: 5
- Forks: 15
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Runestone Golang library
Bitcoin Rune protocol golang implement library.
## How to use
```go
go get github.com/studyzy/runestone@latest
```### Etching
Define a new Rune named *STUDYZY.GMAIL.COM*
```go
func testEtching() {
runeName := "STUDYZY.GMAIL.COM"
symbol := '曾'
myRune, err := runestone.SpacedRuneFromString(runeName)
if err != nil {
fmt.Println(err)
return
}
amt := uint128.From64(666666)
ca := uint128.From64(21000000)
etching := &runestone.Etching{
Rune: &myRune.Rune,
Spacers: &myRune.Spacers,
Symbol: &symbol,
Terms: &runestone.Terms{
Amount: &amt,
Cap: &ca,
},
}
r := runestone.Runestone{Etching: etching}
data, err := r.Encipher()
if err != nil {
fmt.Println(err)
}
fmt.Printf("Etching data: 0x%x\n", data)
dataString, _ := txscript.DisasmString(data)
fmt.Printf("Etching Script: %s\n", dataString)
}
```### Mint
```go
func testMint() {
runeIdStr := "2609649:946"
runeId, _ := runestone.RuneIdFromString(runeIdStr)
r := runestone.Runestone{Mint: runeId}
data, err := r.Encipher()
if err != nil {
fmt.Println(err)
}
fmt.Printf("Mint Rune[%s] data: 0x%x\n", runeIdStr, data)
dataString, _ := txscript.DisasmString(data)
fmt.Printf("Mint Script: %s\n", dataString)
}
```### Decode
```go
func testDecode() {
data, _ := hex.DecodeString("140114001600") //Mint UNCOMMON•GOODS
var tx wire.MsgTx
builder := txscript.NewScriptBuilder()
// Push opcode OP_RETURN
builder.AddOp(txscript.OP_RETURN)
// Push MAGIC_NUMBER
builder.AddOp(runestone.MAGIC_NUMBER)
// Push payload
builder.AddData(data)
pkScript, _ := builder.Script()
txOut := wire.NewTxOut(0, pkScript)
tx.AddTxOut(txOut)
r := &runestone.Runestone{}
artifact, err := r.Decipher(&tx)
if err != nil {
fmt.Println(err)
return
}
a, _ := json.Marshal(artifact)
fmt.Printf("Artifact: %s\n", string(a))
}
```### Reference:
* https://docs.ordinals.com/runes/specification.html
* https://github.com/ordinals/ord/