GithubHelp home page GithubHelp logo

iota.js's Introduction

iota.js

IOTA Client Reference Implementation in Javascript

Build Status NSP Status GitHub license Discord


Getting started

Installation

Install using npm:

npm install @iota/core

or using yarn:

yarn add @iota/core

Connecting to network

import { composeAPI } from '@iota/core'

const iota = composeAPI({
    provider: 'http://localhost:14265'
})

iota.getNodeInfo()
    .then(info => console.log(info))
    .catch(err => {})

Composing custom client methods with network provider:

  1. Install an IRI http client:
npm install @iota/http-client
  1. Create an api method with custom provider:
import { createHttpClient } from '@iota/http-client'
import { createGetNodeInfo } from '@iota/core'

const client = createHttpClient({
    provider: 'http://localhost:14265'
})

const getNodeInfo = createGetNodeInfo(client)

Creating & broadcasting transactions

Publish transfers by calling prepareTransfers and piping the prepared trytes to sendTrytes command.

Feel free to use devnet and take advatage of PoWbox as well as IOTA faucet during development.

// must be truly random & 81-trytes long
const seed = ' your seed here '

// Array of transfers which defines transfer recipients and value transferred in IOTAs.
const transfers = [{
    address: ' recipient address here ',
    value: 1000, // 1Ki
    tag: '', // optional tag of `0-27` trytes
    message: '' // optional message in trytes
}]

// Depth or how far to go for tip selection entry point
const depth = 3 

// Difficulty of Proof-of-Work required to attach transaction to tangle.
// Minimum value on mainnet & spamnet is `14`, `9` on devnet and other testnets.
const minWeightMagnitude = 14

iota.prepareTransfers(seed, transfers)
    .then(trytes => iota.sendTrytes(trytes, depth, minWeightMagnitude))
    .then(bundle => {
        console.log(`Published transaction with tail hash: ${bundle[0].hash}`)
        console.log(`Bundle: ${bundle}`)
    })
    .catch(err => {
        // catch any errors
    })

Documentation

For details on all available API methods please see the reference page.

Documentation of IOTA protocol and IRI http API can be found on docs.iota.works.

Contributing

We thank everyone for their contributions. Here is quick guide to get started with iota.js monorepo:

Clone and bootstrap

  1. Fork the repo with Fork button at top right corner.
  2. Clone your fork locally and cd in it.
  3. Bootstrap your environment with:
npm run init

This will install all dependencies, build and link the packages together. iota.js uses Lerna to manage multiple packages. You can re-bootstrap your setup at any point with lerna bootstrap command.

Run the tests

Make your changes on a single or across multiple packages and test the system in integration. Run from the root directory:

npm test

To run tests of specific package just cd to the package directory and run npm test from there.

You may also want to configure your editor to build the source uppon save and watch the tests running. Once building on save is setup, you can start watching tests with npm test --watch from each package directory.

Updating documentation

Please update the documention when needed by editing JSDoc annotations and running npm run docs from the root directory.

Reporting Issues

Please report any problems you encouter during development by opening an issue.

Join the discussion

Suggestions and discussion around specs, standardization and enhancements are highly encouraged. You are invited to join the discussion on IOTA Discord.

iota.js's People

Contributors

chrisdukakis avatar th0br0 avatar laumair avatar paulhandy avatar alon-e avatar anyong avatar robertkowalski avatar mark-bradshaw avatar atypicalprogrammer avatar nicoschtein avatar gpanosxp avatar felhe avatar techworkerzandura avatar cvarley100 avatar h34d avatar he-la avatar umpc avatar glumb avatar nur-azhar avatar rajivshah3 avatar rvanasa avatar tenghuanhe avatar vivekmarakana avatar christian-bromann avatar thisredone 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.