Giter Site home page Giter Site logo

runestone's Introduction

Runestone Golang library

Bitcoin Rune protocol golang implement library.

How to use

go get github.com/bxelab/runestone@latest

Etching

Define a new Rune named STUDYZY.GMAIL.COM

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

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

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:

runestone's People

Contributors

studyzy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

runestone's Issues

Create and sign an etching transaction

Hi. I'm trying to use your library to etch a new rune, but seems like it returns error:

Error validating transaction: witness script detected in tx without witness data.

I think the error occurs because I'm using taproot address. can you write an example about create and sign a tx in rune? many thanks and appriciate.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.