GithubHelp home page GithubHelp logo

liskascend / lisk-go Goto Github PK

View Code? Open in Web Editor NEW
2.0 3.0 2.0 86 KB

⚙️ Go library for sending Lisk transactions

License: GNU General Public License v3.0

Go 100.00%
golang lisk cryptocurrency blockchain client

lisk-go's Introduction

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

lisk-go's People

Contributors

hendrikhofstadt avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

kplusq blocktree

lisk-go's Issues

Implement real SortModes

At the moment there are only 2 raw SortModes which do not work with the current API.

We need helper functions to create sort modes for specific fields like balance:asc

Test Coverage of API

API methods need test.

  • Test of logic (random host shuffle etc.)
  • Integration tests of Api methods

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.