All Projects → iotaledger → Iota.go

iotaledger / Iota.go

Licence: mit
IOTA Go API Library. Find documentation on https://docs.iota.org/

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Iota.go

Iota.py
PyOTA: The IOTA Python API Library
Stars: ✭ 337 (+5.64%)
Mutual labels:  api, cryptocurrency, iota, internet-of-things
Iota.lib.cpp
IOTA C++ Library
Stars: ✭ 84 (-73.67%)
Mutual labels:  api, cryptocurrency, iota, internet-of-things
Iota Java
IOTA Java API Library. Find documentation on
Stars: ✭ 137 (-57.05%)
Mutual labels:  api, cryptocurrency, iota, internet-of-things
Cryptocurrency Cli
💰 Cryptocurrency Portfolio On The Command Line 💰
Stars: ✭ 99 (-68.97%)
Mutual labels:  api, cryptocurrency, iota
Coinbase Pro Node
Coinbase Pro API written in TypeScript and covered by tests.
Stars: ✭ 116 (-63.64%)
Mutual labels:  api, cryptocurrency
Binance.api.csharp.client
C#.NET client for Binance Exchange API.
Stars: ✭ 98 (-69.28%)
Mutual labels:  api, cryptocurrency
Bittrex.net
A C# .Net wrapper for the Bittrex web API including all features easily accessible and usable
Stars: ✭ 131 (-58.93%)
Mutual labels:  api, cryptocurrency
Coingecko Api
A Node.js wrapper for the CoinGecko API with no dependencies.
Stars: ✭ 159 (-50.16%)
Mutual labels:  api, cryptocurrency
Cryptocurrency Portfolio
Google Sheets automatic creation with Google Apps Script (GAS) for managing a cryptocurrency tracking spreadsheet with multi exchanges
Stars: ✭ 134 (-57.99%)
Mutual labels:  api, cryptocurrency
Huobi java
Java SDK for Huobi Spot API
Stars: ✭ 180 (-43.57%)
Mutual labels:  api, cryptocurrency
Php Bitcoinrpc
Fully unit-tested Bitcoin JSON-RPC client based on GuzzleHttp.
Stars: ✭ 231 (-27.59%)
Mutual labels:  api, cryptocurrency
Python Binance Chain
Binance Chain Exchange API python implementation for automated trading
Stars: ✭ 96 (-69.91%)
Mutual labels:  api, cryptocurrency
Ccxt Rest
Open Source Unified REST API of 100+ Crypto Exchange Sites (18k+ docker pulls) - https://ccxt-rest.io/
Stars: ✭ 210 (-34.17%)
Mutual labels:  api, cryptocurrency
Python Binance
Binance Exchange API python implementation for automated trading
Stars: ✭ 4,114 (+1189.66%)
Mutual labels:  api, cryptocurrency
Cryptolist
Curated collection of blockchain & cryptocurrency resources.
Stars: ✭ 3,501 (+997.49%)
Mutual labels:  api, cryptocurrency
Ccxt.net
CCXT.NET – CryptoCurrency eXchange Trading Library for .NET
Stars: ✭ 89 (-72.1%)
Mutual labels:  api, cryptocurrency
giotan
The CLI Tool for IOTA in Go
Stars: ✭ 30 (-90.6%)
Mutual labels:  internet-of-things, iota
Huobi golang
Go SDK for Huobi Spot API
Stars: ✭ 76 (-76.18%)
Mutual labels:  api, cryptocurrency
Waves Api
Waves API library for Node.js and browser
Stars: ✭ 78 (-75.55%)
Mutual labels:  api, cryptocurrency
Binance
A .NET Standard Binance API library.
Stars: ✭ 199 (-37.62%)
Mutual labels:  api, cryptocurrency


The official Go client library for interacting with the Tangle

Developer documentation portal

Auto-generated docs Discord StackExchange MIT license Supported IRI API endpoints Code quality Build status

AboutPrerequisitesInstallationGetting startedAPI referenceExamplesSupporting the projectJoining the discussion


About

This is the official Go client library, which allows you to do the following:

  • Create transactions
  • Read transactions
  • Sign transactions
  • Generate addresses

This is beta software, so there may be performance and stability issues. Please report any issues in our issue tracker.

Prerequisites

To install the IOTA Go client library and its dependencies, we recommend that you use vgo modules (since Go 1.11) to manage dependencies in your project.

Installation

To download the IOTA Go client library and its dependencies, do the following:

  1. In any directory outside of GOPATH, initiate your project:

    $ go mod init <your-module-path>
    

Note: Change the placeholder to your chosen path such as github.com/me/awesome-project.

  1. Download the library:

    $ go get github.com/iotaledger/iota.go/api
    

This command downloads the latest version of the IOTA Go client library and writes the version into the go.mod file (vgo is go get agnostic).

Getting started

After you've downloaded the library, you can connect to an IRI node to send transactions to it and interact with the ledger. An extended guide can be found on our documentation portal, we strongly recommend you to go here for starting off. A quick starting tutorial is shown below.

  1. To connect to a local IRI node, do the following:

    package main
    
    import (
        . "github.com/iotaledger/iota.go/api"
        "fmt"
    )
    
    var endpoint = "<node-url>"
    
    func main() {
    	// compose a new API instance
    	api, err := ComposeAPI(HTTPClientSettings{URI: endpoint})
    	must(err)
    
    	nodeInfo, err := api.GetNodeInfo()
    	must(err)
    
    	fmt.Println("latest milestone index:", nodeInfo.LatestMilestoneIndex)
    }
    
    func must(err error) {
    	if err != nil {
    		panic(err)
    	}
    }
    

API reference

For details on all available API methods, see the API folder.

Examples

We have a list of test cases in the examples directory that you can use as a reference when developing apps with IOTA.

Here's how you could send a zero-value transaction, using the library. For the guide, see the documentation portal.

var node = "https://nodes.devnet.thetangle.org"

// Define a seed and an address.
// These do not need to belong to anyone or have IOTA tokens.
// They must only contain a maximum of 81 trytes
// or 90 trytes with a valid checksum
const seed = trinary.Trytes("JBN9ZRCOH9YRUGSWIQNZWAIFEZUBDUGTFPVRKXWPAUCEQQFS9NHPQLXCKZKRHVCCUZNF9CZZWKXRZVCWQ")
const address = trinary.Trytes("XBN9ZRCOH9YRUGSWIQNZWAIFEZUBDUGTFPVRKXWPAUCEQQFS9NHPQLXCKZKRHVCCUZNF9CZZWKXRZVCWQMZOCAHYPD")

// Define a message to send.
// This message must include only ASCII characters.
var data = "{'message' : 'Hello world'}"

const minimumWeightMagnitude = 9
const depth = 3

func main() {
    // compose a new API instance, we provide no PoW function so this uses remote PoW
    api, err := ComposeAPI(HTTPClientSettings{URI: node})
    must(err)

    // Convert the message to trytes
    message, err := converter.ASCIIToTrytes(data)
    must(err)

    // Define a zero-value transaction object
    // that sends the message to the address
    transfers := bundle.Transfers{
        {
            Address: address,
            Value: 0,
            Message: message,
        },
    }
    // Use the default options
    prepTransferOpts := PrepareTransfersOptions{}

    trytes, err := api.PrepareTransfers(seed, transfers, prepTransferOpts)
    must(err)
    
    // Create a bundle from the `transfers` object
    // and send the transaction to the node
    myBundle, err := api.SendTrytes(trytes, depth, minimumWeightMagnitude)
    must(err)

    fmt.Println("Bundle hash: " + myBundle[0].Bundle)
}

func must(err error) {
    if err != nil {
        panic(err)
    }
}

Native code and PoW

If the library is compiled with CGO enabled, certain functions such as Curl's transform() method will run native C code for increased speed.

Certain PoW implementations are enabled if the correct flags are passed while compiling your program:

  • pow_avx for AVX based PoW
  • pow_sse for SSE based PoW
  • pow_c128 for C int128 based using PoW
  • pow_arm_c128 for ARM64 int128 C based PoW
  • pow_c for C based PoW

If you want to use local PoW, make sure you define LocalProofOfWorkFunc in your provider settings such as HTTPClientSettings.

Supporting the project

We thank everyone for their contributions. In order for your pull requests to be accepted, they must fulfill the following criteria:

  • You must write tests for your additions with Ginkgo
  • You must write example code that desribes the parameters and the functionality of your additions
  • Your pull request must pass the continuous integration configuration

See the contributing guidelines for more information.

Writing tests with Ginkgo

Before your pull requests can be accepted, you must test your code in Ginkgo.

  1. Download Ginkgo:

    $ go get github.com/onsi/ginkgo/ginkgo
    $ go get github.com/onsi/gomega/...
    
  2. If you've written a new package, generate a corresponding test-suite file:

    $ cd <dir-of-your-package>
    $ ginkgo bootstrap
    
  3. Generate a new testing file:

    $ ginkgo generate <package-name>
    

After creating a testing file, you'll have following two files:

  • _suite_test.go
  • _test.go

Note: You can use the existing tests as a reference on how to write Ginkgo tests or you can read the documentation.

  1. Run your tests:

    $ go test -v
    === RUN   TestAddress
    Running Suite: Address Suite
    ============================
    Random Seed: 1542616006
    Will run 11 of 11 specs
    
    •••••••••••
    Ran 11 of 11 Specs in 0.261 seconds
    SUCCESS! -- 11 Passed | 0 Failed | 0 Pending | 0 Skipped
    --- PASS: TestAddress (0.26s)
    PASS
    ok  	github.com/iotaledger/iota.go/address	0.264s
    

Writing documentation and example code

While godoc.org gives a good enough documentation of the package already, the IOTA Foundation's documentation portal needs additional information, such as parameter description, examples and so on.

  1. If non existent, add a .examples directory in your newly created package

  2. Create a new file with the following convention: <package-name>_examples_test.go inside the .examples directory

  3. Write examples in the following schema:

// i req: s, The ASCII string to convert to Trytes.
// o: Trytes, The Trytes representation of the input ASCII string.
// o: error, Returned for non ASCII string inputs.
func ExampleASCIIToTrytes() {
	trytes, err := converter.ASCIIToTrytes("IOTA")
	if err != nil {
		// handle error
		return
	}
	fmt.Println(trytes) // output: "SBYBCCKB"
}
Symbol Description
i req Describes a parameter to the function.
i Describes an optional parameter to the function.
o Describes a return value of the function.

Syntax:

  • For parameters: <symbol>: <parameter_name>, <description>.
  • For return values: <symbol>: <type>, <description>.
  • Example function: Example<OriginFunctionName>

Joining the discussion

If you want to get involved in the community, need help with getting setup, have any issues related with the library or just want to discuss blockchain, distributed ledgers, and IoT with other people, feel free to join our Discord.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].