This was originally written for my final project for the ConsenSys Academy's 2018 Developer Program. Currently it is a workable prototype that uses ERC721 tokens to link bicycles by their serial numbers onto the blockchain.
I really enjoyed building this project and will most likely continue to poke and prod at it until I get it into a state that I deem worthy to be on the Ethereum mainnet. Currently, the main smart contract is sitting on the Rinkeby testnet, so you will need to get some test Ether and use the MetaMask plugin to play with it.
The VeloLedger is an Ethereum Decentralized Application that enables bicycle lovers to register their most loved item on the Blockchain. Once registered, they will receive a unique cryptotoken called the VELO that is attached to the serial number of their bicycle.
Each VELO token has a landing page that displays the serial number and current Ethereum address assigned to that token. Each token is controlled by the user and can be transferred to other users.
The VeloLedger is one of the world’s first open register for cyclists to be built on blockchain technology—the same breakthrough that makes things like Bitcoin and Ethereum possible.
Bitcoin and Ether are cryptocurrencies but the VELO token is a cryptocollectible. You can buy, sell, or trade your VELO tokens like it was a traditional collectible, secure in the knowledge that blockchain will track ownership securely.
There is a small donation 0.002 Ether to the main contract to help fund the following:
- VPS costs
- Funding grants for those that cannot afford the registration feeEveryone should be able to register a bicycle on the blockchain. In locations where the donation fee is sometimes more than a month's salary, The VeloLedger will donate to those individuals in need.
- Truffle Suite for contract deployment and management
- ReactJS and NextJS for frontend display
- Semantic UI for React theme
- PM2 for Node server management
- Infura.io for backend Ethereum blockchain connectivity.
Ethereum Patterns used
Measures taken to ensure that the smart contracts are not susceptible to common attacks
- OpenZeppelin for smart contract imports
- ERC721 token standards for NFT deployment
- Ownable contract for main smart contract management
- Self-destruct for emergency stop, or to kill the contract
- Consensys security best practices
- Smart contract code commented using best practices
- Build the frontend - 98% DoneFix stupid React/NextJS/MetaMask bugs
- Drink Beer - Done
Future extra features I would like to add before moving to Ethereum Mainnet:
- Oracle to get ETH/USD priceSet Bicycle registration donation fee to ~$0.99 worth of ETHThis seems like an overly complex solution, and not really worth the trouble though.
- Add WITHDRAW function to the contract for the contract owner - Done
- Add KILL function to the contract for the contract owner - Done
- Add a Bicycle picture upload to IPFS, and store IPFS hash in contractThen display the bicycle picture on the show.js component
- Some kind of smart contract written in Vyper?Thinking of removing the random number generator and building it in Vyper.
- Deploy to Status.im dapp storeRebuid frontend with Embark
- Integrate uPort for user accounts and linked assets
- Rebuild frontend with Web3.py and Flask
Dapp Setup Instructions
Install Node, NPM, and Truffle on your system
Clone the repo and then change to the cloned repo directory.
Install OpenZeppelin Contracts via NPM
Fire up a local blockchain to play with.
I use the -s argument to keep the same mnemonic, and 8000000 for gas
ganache-cli -s words -l 8000000
Compile, and Migrate the contracts
Run some tests
Contract: VeloLedger Token Tests ✓ [TEST 1] Deploys the contract ✓ [TEST 2] Owner can create 1 token. (72ms) ✓ [TEST 3] Can read token ID. (43ms) ✓ [TEST 4] Other accounts can create tokens. (66ms) ✓ [TEST 5] Account 1 can transfer tokens to Account 2 (165ms) ✓ [TEST 6] Account 2 should have 2 tokens ✓ [TEST 7] totalSupply should be 2 tokens 7 passing (450ms)
Install, setup and build the client
Install React, Next, and other NPM modules
Link the contract's build directory to the client lib directory
npm run link-contracts
Run it in dev mode first to test.
npm run dev
open your web browser to
Build it for real.
npm run build
[OPTIONAL] Migrate contracts to Rinkeby network
truffle migrate --network rinkeby
pm2 and run
pm2 start server.js on the server.
Main Dapp page
Add new Bike
Might be hitting this bug on page refresh: https://github.com/ethereum/web3.js/issues/1629
Hit this bug multiple times [Locked WEB3 to 1.0.0-beta.30 in order to get it "stable"]:https://github.com/ethereum/web3.js/issues/966