This helpful Boilerplates that allow you to focus on what makes your DApp unique; includes Solidity Smart Contracts & Libraries, Front-end Views and more.
App | Ganache Port | UI Port |
---|---|---|
Digital Identity | 8545 | 3333 |
Flight Delay | 8546 | 3332 |
Dapp | 8547 | 3331 |
- O2OProtocol Initial -
User Registry
Smart Contract - Development & Deployment Environment: local,ropsten,rinkeby,mainnet
- Standard EIP-20: ERC-20 Token Standard. TODO: ERC-233
- Coding best practices: safeMath
- Design Pattern:
Owned
,Controller
,Access Controll
,Database
,Ledger
,Oraclize
- Design Pattern:
New Policy
,Underwrite
,Payout
- Design Pattern
Sharing Economy
:Listing
,Purchase
- IPFS
- Web3 and JSON RPC
- O2O High-Level Architecture
- The ABI definition of the Smart Contract: "public" via etherscan + "private" via frontend.
- Testing using Ganache (TestRPC)
- servives/src/index.js --> o2oprotocol.js: listings, contractService, userRegistryService, ipfsService.
- Private Blockchains “Consortium Blockchains” using Geth to setup a “private” or “testnet” Ethereum blockchain. Note: Geth is suitable for building frontends for DApps --> Genesis block, Indentity, DataDir --> Externally Owned Accounts
EOA
&Contract Accounts
TODO - Develop eConomySharing:
Listing.sol
- Financial atomic processes & standards: payments, assets, data, identity, KYC, governance
contracts
├── contracts <- Solidity contracts
├── migrations <- Deployment Script
├── test <- Test contracts
├── truffle-config.js <- Truffle config
src <- O2O Service
├── ipfs-service <- IPFS service
├── contract-service <- Contract service
├── test <- Test services
README.md
Browser tests are automatically served at http://localhost:8081
when you run npm start
.
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
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).
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
This is still an alpha version which will evolve significantly before the main net release.
Sellers:
- Create Listings
- Update Listings
- Delete Listings
- Validate Listings
Buyers:
- Browse Listing
- Create Bookings
- Update Bookings
- Cancel Bookings
Note: to show the gas costs of each transaction during a test, set the enviroment variable GAS_TRACKING before launching truffle develop. For example, using bash: GAS_TRACKING=1 npx truffle develop
npm install o2oprotocol --save
yarn add o2oprotocol
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.)
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
import O2OProtocol from 'o2oprotocol'
const configOptions = {}
const { contractService, ipfsService, o2oService } = new O2OProtocol(configOptions)
Config options are passed into the O2OProtocol constructor at instantiation
const configOptions = {
option: 'value'
}
const o2o = new O2OProtocol(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: '8081',
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
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
- Unit tests passing, checking tests configuration (matching the configuration of main network);
- Compilator warnings;
- Race Conditions. Reentrancy. Cross-function Race Conditions. Pitfalls in Race Condition solutions;
- Possible delays in data delivery;
- Transaction-Ordering Dependence (front running);
- Timestamp Dependence;
- Integer Overflow and Underflow;
- DoS with (unexpected) Revert;
- DoS with Block Gas Limit;
- Call Depth Attack. Not relevant in modern ethereum network :)
- Methods execution permissions;
- Oracles calls;
- Economy model. It’s important to forecast scenarios when user is provided with additional economic motivation or faced with limitations. If application logic is based on incorrect economy model, the application would not function correctly and participants would incur financial losses. This type of issue is most often found in bonus rewards systems.
- The impact of the exchange rate on the logic;
- Private user data leaks. Needed
-
package.json
- "form-data": "^2.3.2",
- "ipfs-api": "^14.3.7",
-
actual gas cost by running web3.eth.getTransactionReceipt(txId)
-
Store IPFS and contract data separately
-
the upcoming version of web3 will work with truffle
-
Return custom objects instead of raw web3 transactions from API
-
Move logic out of
Listing
contract -
Discussion around how to do smart contract migrations
-
Listings expire 60 days after creation.
-
there are six events that affect transaction state, each caused by the action of a sole party, and two of them (5 & 6) being potentionally out of sequence:
Create listing (seller) Buy listing (buyer) - presumed to be the equivalent of sending money Fulfill order (seller) Receive order (buyer) Withdraw funds (seller) Provide feedback (buyer)
- Data verification for JSON schema listings