Giter VIP home page Giter VIP logo

metacontract-script-decoder's Introduction

metacontract-script-decoder

Locking script decoder for Mvc Contract

解码锁定脚本,获得Mvc相关的字段数据。目前支持识别4种脚本类型(CodeType):

  1. NONE 普通脚本
  2. FT mvc FT合约脚本
  3. UNIQUE mvc unique合约脚本
  4. NFT mvc NFT合约脚本

使用方法

参见测试用例 decode_test.go

将对应的锁定脚本放置在test.txt 中,然后调用decode_test。打印解析出来的合约来测试解码结果

	import (
		scriptDecoder "github.com/metasv/metacontract-script-decoder"
	)

	d.ScriptType = scriptDecoder.GetLockingScriptType(d.Script)
	txo := scriptDecoder.ExtractPkScriptForTxo(d.Script, d.ScriptType)

	d.CodeType = txo.CodeType
	d.CodeHash = txo.CodeHash
	d.GenesisId = txo.GenesisId
	...

metacontract-script-decoder's People

Contributors

jiedo avatar kakeimei avatar

metacontract-script-decoder's Issues

mvcUnique support pushdata length more than 2**8

code in this block has restrict the data length < 2**8
https://github.com/mvc-labs/metacontract-script-decoder/blob/master/mvc_unique.go#L27

if !(pkScript[scriptLen-totalDataLen-1-1-1] == OP_RETURN &&
		pkScript[scriptLen-totalDataLen-1-1] == 0x4c &&
		pkScript[scriptLen-totalDataLen-1] == byte(totalDataLen)) {
		return false
	}

0x4c is op_pushdata1, there has 0x1-0x4b(data length: 1 ~ 0x4b), op_pushdata2(data length: 2**8 ~ 2**16), op_pushdata4(data length: 2**16~ 2**32)

fixed 256 bytes may be too small for some unique contracts

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.