Giter Site home page Giter Site logo

gadk's Introduction

GoDoc Build Status GitHub license

gadk

Client library for the ADK.

Install

You will need C compiler (gcc for linux, mingw for windows) to compile PoW routine in C.

Examples

import "github.com/AidosKuneen/gadk"

//Trits
tritsFrom:=[]int8{1,-1,1,0,1,1,0,-1,0}
trits,err:=gadk.ToTrits(tritsFrom)

//Trytes
trytes:=trits.Trytes()
trytesFrom:="ABCDEAAC9ACB9PO..."
trytes2,err:=gadk.ToTrytes(trytesFrom)

//Hash
hash:=trytes.Hash()

//API
api := gadk.NewAPI("http://localhost:14265", nil)
resp, err := api.FindTransactions([]Trytes{"DEXRPL...SJRU"})

///Address
index:=0
security:=2
adr,err:=gadk.NewAddress(trytes,index,seciruty) //without checksum.
adrWithChecksum := adr.WithChecksum() //adrWithChecksum is trytes type.

//transaction
tx,err:=gadk.NewTransaction(trytes)
if tx.HasValidNonce(){...}
trytes2:=tx.trytes()

//create signature
key := gadk.NewKey(seed, index, security)
norm := bundleHash.Normalize()
sign := gadk.Sign(norm[:27], key[:6561/3])

//validate signature
if gadk.ValidateSig(adr, []Trytes{sign}, bundleHash) {...}

//send
trs := []gadk.Transfer{
	gadk.Transfer{
		Address: "KTXF...QTIWOWTY",
		Value:   20,
		Tag: "MOUDAMEPO",
	},
}
_, pow := gadk.GetBestPow()
bdl, err = gadk.Send(api, seed, security, trs, pow)

PoW(Proof of Work) Benchmarking

You can benchmark PoWs(by C,Go,SSE) by

    $ go test -v -run Pow

or if you want to add OpenCL PoW,

    $ go test -tags=gpu -v -run Pow

then it outputs like:

	$ go test -tags=gpu -v -run Pow
=== RUN   TestPowC
--- PASS: TestPowC (15.93s)
	pow_c_test.go:50: 1550 kH/sec on C PoW
=== RUN   TestPowCL
--- PASS: TestPowCL (17.45s)
	pow_cl_test.go:49: 332 kH/sec on GPU PoW
=== RUN   TestPowGo
--- PASS: TestPowGo (21.21s)
	pow_go_test.go:50: 1164 kH/sec on Go PoW
=== RUN   TestPowSSE
--- PASS: TestPowSSE (13.41s)
	pow_sse_test.go:52: 2292 kH/sec on SSE PoW

gadk's People

Contributors

keep-looking avatar islamnader94 avatar mrmo99 avatar

Watchers

James Cloos avatar

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.