Help us shape the future of Go! Take the 2026 Go Developer Survey

goslp

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 20, 2026 License: MIT Imports: 4 Imported by: 0

README

goslp

Build Status

Golang packages for the Simple Ledger Protocol (SLP).

This is a copy of github.com/simpleledgerinc/goslp at commit 3c2e5f2ef33f, the version bchd used, taken from the Go module cache after the original repository was deleted. Its earlier history is not included.

go get github.com/gcash/goslp
v1parser - for parsing transaction metadata

This package is used for parsing SLP metadata from the scriptPubKey of the SLP transaction's first output.

// here is an example marshaled SLP message extracted from transaction's scriptPubKey.
scriptPubKey, err := hex.DecodeString("6a04534c500001010453454e4420c4b0d62156b3fa5c8f3436079b5394f7edc1bef5dc1cd2f9d0c4d46f82cca47908000000000000000108000000000000000408000000000000005a")
if err != nil {
    // handle the error ...
}

// get the unmarshalled slp message
slpMsg, err := v1parser.ParseSLP(scriptPubKey)

// do something ...

The gRPC server in bchd uses the unmarshalled SLP metadata object throughout, which makes it a good example of how to work with it.

Differential fuzzer testing has been performed with the slp-validate.js npm package, and can be reproduced following the instructions in the ./fuzz directory.

metadatamaker - for creating new transaction metadata

This package is used for creating marshaled SLP metadata for adding to a transaction's first output scriptPubKey. Helper methods are provided for Type 1, NFT Group, and NFT children transactions.

Genesis - use CreateOpReturnGenesis, NFT1GroupGenesis, or NFT1ChildGenesis

// put the mint baton on output 2, or pass nil for no baton
mintBatonVout := NewMintBatonVout(2)

scriptPubKey, err := CreateOpReturnGenesis(
      versionType,
      ticker,
      name,
      documentURL,
      documentHash,
      decimals,
      mintBatonVout,
      quantity,
)

Mint - use CreateOpReturnMint or NFT1GroupMint

// pass the baton on to output 2, or pass nil to end the minting
mintBatonVout := NewMintBatonVout(2)

scriptPubKey, err := CreateOpReturnMint(
    versionType,
    tokenID,
    mintBatonVout,
    quantity,
)

Send - use CreateOpReturnSend, NFT1GroupSend, or NFT1ChildSend

scriptPubKey, err := CreateOpReturnSend(
		1,
		tokenID,
		[]uint64{1, 2},
)

Documentation

Overview

Package goslp has helpers for Simple Ledger Protocol (SLP) token transactions that work across SLP versions and token types. Its v1parser package parses SLP metadata, and its metadatamaker package builds it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetSlpTokenID

func GetSlpTokenID(tx *wire.MsgTx) ([]byte, error)

GetSlpTokenID parses the SLP message in the first output of tx and returns its token ID, as GetSlpTokenIDFromMsg does.

func GetSlpTokenIDFromMsg

func GetSlpTokenIDFromMsg(tx *wire.MsgTx, slpMsg v1parser.ParseResult) ([]byte, error)

GetSlpTokenIDFromMsg returns the token ID of tx, whose first output ParseSLP parsed as slpMsg. A GENESIS creates a token whose ID is its own transaction hash, in the byte order MINT and SEND messages carry it in.

func GetSlpVersionType

func GetSlpVersionType(slpPkScript []byte) (*uint8, error)

GetSlpVersionType returns the token type of the SLP message in slpPkScript. It returns an error for any script ParseSLP rejects, which includes every token type other than 0x01, 0x41 and 0x81.

Types

This section is empty.

Directories

Path Synopsis
Package metadatamaker builds the OP_RETURN scripts that carry SLP metadata in the first output of type 1, NFT1 group and NFT1 child token transactions.
Package metadatamaker builds the OP_RETURN scripts that carry SLP metadata in the first output of type 1, NFT1 group and NFT1 child token transactions.
Package v1parser parses the SLP metadata that a version 1 SLP transaction carries in the OP_RETURN script of its first output.
Package v1parser parses the SLP metadata that a version 1 SLP transaction carries in the OP_RETURN script of its first output.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL