Origin Protocol is a library of javascript code and Ethereum smart contracts which allow anyone to create decentralized marketplaces, including for fractional usage.
Please refer to our product brief and technical whitepaper for more detail.
This repo is under active development. We welcome your participation!
-
Listen in on our weekly engineering call on Google Hangouts. It happens every week and everyone is welcome to listen in and participate. Join us on Google Hangouts on Wednesdays at 9pm GMT (Add to Calendar):
Pacific | Mountain | Central | Eastern | GMT |
---|---|---|---|---|
Wed 1pm | Wed 2pm | Wed 3pm | Wed 4pm | Wed 9pm |
- Catch up on our meeting notes & weekly sprint planning docs (feel free to add comments):
- Read our simple contributing and style guide.
This library is an abstraction layer for developers who want to build DApps on Origin Protocol, and is also used to build the Origin Demo DApp.
The library will make it easy for sellers to do things like:
- Create listings
- Update listings
- Delete listings
- Validate listings
And buyers to:
- Browse listing
- Create bookings
- Update bookings
- Cancel bookings
Welcome to the origin.js documentation! origin.js is a Javascript library for interacting with the Origin protocol.
Using the library you can create new listings from your applications, purchase them, or update them from your own off-chain applications.
This is still an alpha version which will evolve significantly before the main net release.
A browser-compatible plain javascript file origin.js
is available in the "Releases" tab, and will soon be hosted on originprotocol.com. It can be generated locally via npm build
and will be placed in dist/origin.js
.
npm install @originprotocol/origin --save
yarn add @originprotocol/origin
-
git clone
your fork. Note that the latest commits will be on thedevelop
branch. So switch to that branch if you want to submit a PR or check out recently merged code. -
Install:dev (shortcut for
npm install && npm link
). Linking makes this available as a local npm package for local dapp development.npm run install:dev
-
Start the localblockchain and create the build. Code changes will trigger a live rebuild.
npm start
In order to conduct test transactions, you can create a new wallet using the following seed phrase (Mnemonic):
Be careful to back up the seed phrases and private keys for any existing wallets before creating a new one.
candy maple cake sugar pudding cream honey rich smooth crumble sweet treat
-
To develop against a working dapp and UI, see the instructions in our demo dapp.
import Origin from '@originprotocol/origin'
let configOptions = {}
let { contractService, ipfsService, originService } = new Origin(configOptions)
Config options are passed into the Origin constructor at instantiation.
let configOptions = {
option: 'value'
}
let origin = new Origin(configOptions)
Valid options:
ipfsDomain
ipfsApiPort
ipfsGatewayPort
ipfsGatewayProtocol
attestationServerUrl
If you are running a local IPFS daemon then set the following config options (see config options):
{
ipfsDomain: '127.0.0.1',
ipfsApiPort: '5001',
ipfsGatewayPort: '8080',
ipfsGatewayProtocol: '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"]'
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
Our full test suite can be run with:
npm run test
Note: you should not have the server running at this time, as these tests start their own local blockchain instance.
Our Solidity tests (which use Truffle) are located at contracts/test
.
npm run test:contracts
Note: you should not have the server running at this time, as these tests start their own local blockchain instance.
A subset of our tests can be run from the browser. These tests are automatically served at http://localhost:8081
when you run npm start
. These tests are automatically rerun when source or test code is changed.
Run a subset of these tests using the grep
query string parameter, for example: http://localhost:8081/?grep=IpfsService
Needed