|
1 | 1 |  |
2 | 2 |
|
| 3 | +  |
| 4 | + |
3 | 5 | # Origin Platform |
4 | 6 |
|
5 | | -Origin Protocol is a library of javascript code and Ethereum smart contracts which allow anyone to create decentralized marketplaces, including for fractional usage. |
| 7 | +Origin Protocol is a library of javascript code and Ethereum smart contracts which allow anyone to create decentralized marketplaces, including for fractional usage. |
6 | 8 |
|
7 | 9 | Please refer to our [product brief](https://www.originprotocol.com/product-brief) and [technical whitepaper](https://www.originprotocol.com/whitepaper) for more detail. |
8 | 10 |
|
9 | | - - [README for Javascript code](https://github.com/OriginProtocol/platform/tree/master/packages/origin.js) |
10 | | - - [README for Ethereum contracts](https://github.com/OriginProtocol/platform/tree/master/packages/contracts) |
| 11 | + - [README for Javascript code](#originjs-documentation) |
11 | 12 |
|
12 | 13 | ## Follow our progress and get involved |
13 | 14 |
|
14 | 15 | This repo is under active development. We welcome your participation! |
15 | 16 |
|
16 | 17 | 1. [Join our #engineering channel on Discord](http://www.originprotocol.com/discord). |
17 | 18 |
|
18 | | -2. 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](https://meet.google.com/pws-cgyd-tqp) at the following times: |
| 19 | +2. 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](https://meet.google.com/pws-cgyd-tqp) on Wednesdays at 9pm GMT ([Add to Calendar](https://calendar.google.com/event?action=TEMPLATE&tmeid=MHAyNHI3N2hzMjk5b3V2bjhoM2Q1ZWVzY2pfMjAxODA0MTFUMjAwMDAwWiBqb3NoQG9yaWdpbnByb3RvY29sLmNvbQ&tmsrc=josh%40originprotocol.com&scp=ALL)): |
19 | 20 |
|
20 | 21 | > | Pacific | Mountain | Central | Eastern | GMT | |
21 | 22 | > |---------|----------|---------|---------|-----| |
22 | 23 | > | Wed 1pm | Wed 2pm | Wed 3pm | Wed 4pm | Wed 9pm | |
23 | | - |
| 24 | +
|
24 | 25 | 3. Catch up on our meeting notes & weekly sprint planning docs (feel free to add comments): |
25 | 26 | - [Engineering meeting notes](https://docs.google.com/document/d/1aRcAk_rEjRgd1BppzxZJK9RXfDkbuwKKH8nPQk7FfaU/) |
26 | 27 | - [Weekly sprint doc](https://docs.google.com/document/d/1qJ3sem38ED8oRI72JkeilcvIs82oDq5IT3fHKBrhZIM) |
27 | 28 |
|
28 | | -# What we're building |
29 | | - |
30 | | -The main components of this repo are: |
| 29 | +4. Read our simple [contributing and style guide](CONTRIBUTING.md). |
31 | 30 |
|
32 | | - - [Origin.js](/packages/origin.js/) |
33 | | - - [Ethereum smart contracts](/packages/contracts/) |
34 | | - - Origin DApp that's built on top of origin.js (basically our current demo-dapp reworked to use origin.js) |
| 31 | +# What we're building |
35 | 32 |
|
36 | | -This library is an abstraction layer for developers who want to build DApps on Origin Protocol. |
| 33 | +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](https://github.com/OriginProtocol/demo-dapp). |
37 | 34 |
|
38 | 35 | The library will make it easy for sellers to do things like: |
39 | 36 |
|
40 | 37 | - Create listings |
41 | 38 | - Update listings |
42 | 39 | - Delete listings |
43 | 40 | - Validate listings |
44 | | - |
| 41 | + |
45 | 42 | And buyers to: |
46 | | - |
| 43 | + |
47 | 44 | - Browse listing |
48 | 45 | - Create bookings |
49 | 46 | - Update bookings |
50 | 47 | - Cancel bookings |
| 48 | + |
| 49 | + # origin.js Documentation |
| 50 | + |
| 51 | + ## Introduction |
| 52 | + |
| 53 | + Welcome to the origin.js documentation! origin.js is a Javascript library for interacting with the Origin protocol. |
| 54 | + |
| 55 | + Using the library you can create new listings from your applications, purchase them, or update them from your own off-chain applications. |
| 56 | + |
| 57 | + ### Warning |
| 58 | + This is still an alpha version which will evolve significantly before the main net release. |
| 59 | + |
| 60 | + ## Using origin.js in your project |
| 61 | + |
| 62 | + ### Plain javascript |
| 63 | + |
| 64 | + 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`. |
| 65 | + |
| 66 | + ## Install |
| 67 | + |
| 68 | + ### NPM |
| 69 | + ``` |
| 70 | + npm install @originprotocol/origin --save |
| 71 | + ``` |
| 72 | + |
| 73 | + ### Yarn |
| 74 | + ``` |
| 75 | + yarn add @originprotocol/origin |
| 76 | + ``` |
| 77 | + |
| 78 | + ### Local |
| 79 | + |
| 80 | +1. Clone |
| 81 | +``` |
| 82 | +git clone https://github.com/OriginProtocol/platform origin-platform && cd origin-platform |
| 83 | +``` |
| 84 | + |
| 85 | +2. Setup (shortcut for `npm install && npm link`). Linking makes this available as a local npm package for local dapp development. |
| 86 | + ``` |
| 87 | + npm run setup |
| 88 | + ``` |
| 89 | + |
| 90 | +3. Start the localblockchain and create the build. Code changes will trigger a live rebuild. |
| 91 | + ``` |
| 92 | + npm start |
| 93 | + ``` |
| 94 | + |
| 95 | + 4. To develop against a working dapp and UI, see [the instructions in our demo dapp](https://github.com/OriginProtocol/demo-dapp#developing-with-a-local-chain). |
| 96 | + |
| 97 | + ## Import |
| 98 | + |
| 99 | + ``` |
| 100 | + import Origin from '@originprotocol/origin' |
| 101 | +
|
| 102 | + let configOptions = {} |
| 103 | +
|
| 104 | + let { contractService, ipfsService, originService } = new Origin(configOptions) |
| 105 | + ``` |
| 106 | + |
| 107 | + ## Configuration Options |
| 108 | + |
| 109 | + Config options are passed into the Origin constructor at instantiation. |
| 110 | + |
| 111 | + ``` |
| 112 | + let configOptions = { |
| 113 | + option: 'value' |
| 114 | + } |
| 115 | + let origin = new Origin(configOptions) |
| 116 | + ``` |
| 117 | + |
| 118 | + Valid options: |
| 119 | + - `ipfsDomain` |
| 120 | + - `ipfsApiPort` |
| 121 | + - `ipfsGatewayPort` |
| 122 | + - `ipfsGatewayProtocol` |
| 123 | + |
| 124 | + ## IPFS |
| 125 | + |
| 126 | + If you are running a local IPFS daemon then set the following config options ([see config options](#configuration-options)): |
| 127 | + |
| 128 | + ``` |
| 129 | + { |
| 130 | + ipfsDomain: '127.0.0.1', |
| 131 | + ipfsApiPort: '5001', |
| 132 | + ipfsGatewayPort: '8080', |
| 133 | + ipfsGatewayProtocol: 'http' |
| 134 | + } |
| 135 | + ``` |
| 136 | + |
| 137 | + Configure your local IPFS daemon with the following settings to avoid CORS errors: |
| 138 | + |
| 139 | + ``` |
| 140 | + ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["localhost:*"]' |
| 141 | + ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods '["GET", "POST", "PUT"]' |
| 142 | + ipfs config --json API.HTTPHeaders.Access-Control-Allow-Credentials '["true"]' |
| 143 | + ``` |
| 144 | + |
| 145 | + ## Troubleshooting |
| 146 | + |
| 147 | + ### Python 3 |
| 148 | + |
| 149 | + If you have Python 3 installed, you may see this error when installing dependencies: |
| 150 | + |
| 151 | + ``` |
| 152 | + gyp ERR! stack Error: Python executable "/Users/aiham/.pyenv/shims/python" is v3.6.4, which is not supported by gyp. |
| 153 | + ``` |
| 154 | + |
| 155 | + Resolve this by configuring npm to use Python 2 (where python2.7 is a binary accessible from your $PATH): |
| 156 | + |
| 157 | + ``` |
| 158 | + npm config set python python2.7 |
| 159 | + ``` |
| 160 | + |
| 161 | + ## Tests |
| 162 | + |
| 163 | + Browser tests are automatically served at `http://localhost:8081` when you run `npm start`. |
| 164 | + |
| 165 | + Tests are automatically rerun when source or test code is changed. |
| 166 | + |
| 167 | + Run a subset of tests using the `grep` query string parameter, for example: http://localhost:8081/?grep=IpfsService |
| 168 | + |
| 169 | + We also have contract unit tests that are not run in the browser. These can be run with `npm run test:contracts` (you should *not* have the server running at this time, as these tests start their own local blockchain instance). |
| 170 | + |
| 171 | + ## Documentation |
| 172 | + |
| 173 | + Needed |
0 commit comments