/go-client

Go implementation of the Nimiq RPC client specs.

Primary LanguageGoApache License 2.0Apache-2.0

Nimiq Go RPC Client

Report card GoDoc

Go implementation of the Nimiq RPC client specs.

About

A Nimiq RPC client library in Go. This client library implements the Nimiq RPC specification. This client uses the jsonrpc library to handle JSON-RPC 2.0 requests and responses. For more information about this library see the jsonrpc documentation

Usage

This library is fully Go module compatible. See the full documentation on GoDoc An example of using this library can be found below:

client := nimiqrpc.NewClient("address.to.nimiqnode.com")
balance, _ := client.GetBalance("NQ52 V4BF 52J3 0PM6 BG4M 9QY1 RUYS UAL6 CJD2")
fmt.Println("Balance: ", balance)

Testing

This library provides several tests to guarantee API consistency. Several tests require an RPC server to test the RPC requests. In order to run theses tests, arguments need to be provided to the go test command. The following arguments are supported:

  • node-addr [address] Sets the address of the Nimiq RPC server
  • auth Enables the use of authentication to the RPC server
  • username [username] Sets the username of the client
  • password [password] Sets the password of the client

For example:

go test --cover --node-addr "http://seed.nimiq.example:8443" --auth --username "username"  --password "this is an example password: the higher the entropy the better the password"

Contributions

This implementation was originally contributed by redmaner.

Please send your contributions as pull requests. Refer to the issue tracker for ideas.

License

Apache 2.0