Node.js library for micropayments in Ether and ERC20 tokens over HTTP
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.

README.md

Machinomy Monorepo Build Status Coverage Status Greenkeeper badge Chat

Machinomy Lerna Monorepo repository.

Available sub-projects:

  • Machinomy is a Node.js library for micropayments in Ether over HTTP. It allows you to send and receive a minuscule amount of money instantly.
  • Contracts is a TypeScript interface for Ethereum contracts managed by Truffle used by Machinomy.
  • Examples is Machinomy examples.
  • Playground contains code of playground.machinomy.com
  • cli is Machinomy Command Line Interface.
  • logger is Machinomy Logger. Works in browser and Node.

Web site: machinomy.com. Twitter: @machinomy. Support/Discussion: Gitter. FAQ: GitHub Wiki Page.

Installation

Using yarn is mandatory (don't use npm!)

$ yarn add machinomy

The library supports mainnet, Ropsten, and Rinkeby networks.

Tinkering

It takes two to tango: a seller and a buyer. Seller is packages/examples/src/server.ts script. Build it or run through node-ts.

$ git clone https://github.com/machinomy/machinomy
$ cd machinomy && yarn install && yarn bootstrap && yarn build
$ node packages/examples/src/server.js

And then run client script:

$ node packages/examples/src/client.js

Usage

Buy

Using TypeScript

import Machinomy from 'machinomy'
const uri = 'http://localhost:3000/content'

const machinomy = new Machinomy(SENDER_ACCOUNT, web3)
const contents = await machinomy.buy({ receiver: RECEIVER_ACCOUNT, price: 100, gateway: 'http://localhost:3001/accept' })
console.log(contents)

Sell

The process is more convoluted than buying. Better consult packages/examples/src/server.ts file.

Sending payments through channels

$ git clone https://github.com/machinomy/machinomy
$ cd machinomy && yarn install && yarn bootstrap && yarn build && cd packages/examples
$ yarn run sender && yarn run receiver

Look at sender.ts and receiver.ts for more information.

Documentation

For more advanced documentation go to doc/ folder.

Contributing

Developers: Machinomy is for you. Feel free to use it, break it, fork it, and make the world better. The code is standard TypeScript, no special skills required:

$ yarn install && yarn bootstrap

Using yarn is mandatory (don't use npm!)

Apply migrations (eg. for PostgreSQL, refer packages/machinomy/database.json):

$ PGUSER=user PGPASSWORD=pass PGHOSTADDR=localhost PGDATABASE=dbname yarn migrate

Non-Developers: You are lovely. As a starter, help us spread the word! Tell a friend right now. If not enough, developers need flesh-world guidance. It starts with proper documentation and a pinch of fantasy. Really anything, whether it is a short post on a use case of IoT micropayments, addition to the documentation (code comments, yay!), or an elaborate analysis of machine economy implications. Do not hesitate to share any idea with us on Gitter.

License

Licensed under Apache License, Version 2.0.