Skip to content
⚙️ Go library for sending Lisk transactions
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci
api
crypto
transactions
.gitignore
Gopkg.lock
Gopkg.toml
LICENSE.md
README.md
lint.json

README.md

Lisk-Go

Doc CircleCI License: GPL v3

Lisk-Go is a Golang library for Lisk - the cryptocurrency and blockchain application platform released by Lisk Ascend. It allows developers to create offline transactions and broadcast them onto the network. It also allows developers to interact with the core Lisk API, for retrieval of collections and single records of data located on the Lisk blockchain. Its main benefit is that it does not require a locally installed Lisk node, and instead utilizes the existing peers on the network.

Currently this library is in Beta and the API will experience changes.

Transaction and Crypto code have >95% test coverage and are extensively tested.


Features:

  • Support for the latest 1.0 Lisk API
  • 100% coverage of the API functions
  • Very detailed documentation
  • Usage of Go contexts for requests
  • Pretty printing of API errors + detailed errors for internal functions
  • Use of Go's native data types + a lot of helper structs
  • Modular layout
  • Full Test Coverage of Crypto
  • Full Test Coverage of Transaction Logic/Serialization
  • Full Test Coverage of API Wrapper

Install

$ go get github.com/liskascend/lisk-go

Usage

For detailed documentation consider the GoDoc linked above.

This project is consists of 3 modules/packages:

  • api - Module used to communicate with the Lisk 1.0 API
  • crypto - Module which implements the core cryptography functions required for using Lisk
  • transactions - Module which implements transaction and payload serialization and validation

Sending a simple transaction

The library offers comfortable util constructors for all supported transaction types.

They are in the transactions package and prefixed with New

The following example creates+signs a transaction and broadcasts it to the network.

// Create the client
client := api.NewClient()
// Create the transaction using the constructor utils
transaction, err := transactions.NewTransactionWithData("104666L", 0, "wagon stock borrow episode laundry kitten salute link globe zero feed marble", "", 0, "abc")
if err != nil {
	// handle error
	return
}
res, err := client.SendTransaction(context.Background(), transaction)
if err != nil {
	// handle error
	return
}

This is the equivalent but done manually:

// Create the client
client := api.NewClient()

timestamp := GetCurrentTimeWithOffset(0)

transaction := &Transaction{
	Type:        TransactionTypeNormal,
	Amount:      0,
	RecipientID: "104666L",
	Timestamp:   timestamp,
	Asset:       transactions.DataAsset("abc"),
}

secret := "wagon stock borrow episode laundry kitten salute link globe zero feed marble"

pubKey := crypto.GetPublicKeyFromSecret(secret)
transaction.SenderPublicKey = pubKey

privKey := crypto.GetPrivateKeyFromSecret(secret)
transaction.Sign(privKey)

res, err := client.SendTransaction(context.Background(), transaction)
if err != nil {
	// handle error
	return
}

Manual usage of the transaction struct + assets can be used for more complex use-cases.

This library offers intensive validation of the transaction which is automatically performed before serialization or when isValid() is called on transactions or assets.

Tests

go test -v ./...

Lint

gometalinter --config=lint.json ./...

Use this command to run the required linters.

Authors

You can’t perform that action at this time.