o2oprotocol
Smart Contracts (listing, purchase, controller) without directly interfacing with the Blockchain or IPFS.
Last updated 2 years ago by o2oprotocol .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install o2oprotocol 
SYNC missed versions from official npm registry.

O2OProtocol JS Documentation

Introduction

Welcome to the o2oprotocol.js documentation! o2oprotocol.js is a Javascript library for interacting with the O2O Protocol. Using the library you can create new listings from your applications, purchase them, or update them from your own off-chain applications.

More information can be found at O2OProtocol Platform Readme

Warning

This is still an alpha version which will evolve significantly before the main net release.

Install

NPM

npm install o2oprotocol --save

Yarn

yarn add o2oprotocol

Local

For developing on o2oprotocol.js, it is better to link the package rather than installing it. (Otherwise you would need to run npm build everytime you made a change to the package.)

In the directory ./packages/contracts/ run:

truffle compile

This will create the .json files for our solidity contracts.

In the directory ./packages/o2oprotocol.js run:

npm link

Now change tabs (or diectories) to the repo for your DApp (for example, the O2OProtocol eServices) run:

npm link o2oprotocol

This will create a symlink, direcly linking the dapp to your local o2oprotocol.js package.

Next, you will need to start your local development blockchain.

In the directory ./packages/contracts/ run:

truffle develop

Then in the console run:

migrate --reset

Import

import { contractService, ipfsService, o2oService } from 'o2oprotocol'

IPFS

If you are running a local IPFS daemon then set the following environment variables:

export IPFS_DOMAIN=127.0.0.1
export IPFS_API_PORT=5001
export IPFS_GATEWAY_PORT=8080
export IPFS_GATEWAY_PROTOCOL=http

Configure your local IPFS daemon with the following settings to avoid CORS errors:

ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["localhost:*"]'
ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods '["GET", "POST", "PUT"]'
ipfs config --json API.HTTPHeaders.Access-Control-Allow-Credentials '["true"]'

Troubleshooting

Python 3

If you have Python 3 installed, you may see this error when installing dependencies:

gyp ERR! stack Error: Python executable "/Users/aiham/.pyenv/shims/python" is v3.6.4, which is not supported by gyp.

Resolve this by configuring npm to use Python 2 (where python2.7 is a binary accessible from your $PATH):

npm config set python python2.7

Tests

When you begin developing, run npm test and keep it running while you develop.

View test results in your browser (with MetaMask installed and setup) at http://localhost:8081

Tests are automatically rerun when source or test code is changed.

Run a subset of tests using the grep query string parameter, for example: http://localhost:8081/?grep=IpfsService

Documentation

Needed

Current Tags

  • 0.0.25                                ...           latest (2 years ago)

24 Versions

  • 0.0.25                                ...           2 years ago
  • 0.0.24                                ...           2 years ago
  • 0.0.22                                ...           2 years ago
  • 0.0.21                                ...           2 years ago
  • 0.0.20                                ...           2 years ago
  • 0.0.19                                ...           2 years ago
  • 0.0.18                                ...           2 years ago
  • 0.0.17                                ...           2 years ago
  • 0.0.16                                ...           2 years ago
  • 0.0.15                                ...           2 years ago
  • 0.0.14                                ...           2 years ago
  • 0.0.13                                ...           2 years ago
  • 0.0.12                                ...           2 years ago
  • 0.0.11                                ...           2 years ago
  • 0.0.10                                ...           2 years ago
  • 0.0.9                                ...           2 years ago
  • 0.0.8                                ...           2 years ago
  • 0.0.7                                ...           2 years ago
  • 0.0.6                                ...           2 years ago
  • 0.0.5                                ...           2 years ago
  • 0.0.4                                ...           2 years ago
  • 0.0.3                                ...           2 years ago
  • 0.0.2                                ...           2 years ago
  • 1.0.0                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (9)
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |