While many people have a dusty guitar, saxophone, or other instruments lying around in their homes, others would like to rent these very same instruments for a while - maybe to refresh their skills, to get a simple idea if they like the instrument at all... or simply as a different way to use their time for a while. The musical instruments rental service is ideal for that. ;-)
https://schultzl.github.io/blockchain-developer-bootcamp-final-project/
https://www.loom.com/share/78730d59c2bf4289ac28ac9e3f09dd0a
0x27072aEa00D4df1c451033F27B886A4C32f181Fa
- Node.js (v16.13.0)
- Truffle and Ganache (truffle v5.4.18, solc v0.8.0)
- Web3.js (v1.5.3)
Tipp: Run yarn install
in the root of the project directory to install dependencies
contracts
: smart contracts (deployed to the Rinkeby testnet)migrations
: migration scriptstest
: tests for smart contracts in/contracts
truffle-config.js
: configuration file for truffledapp.js
index.html
Note:
- You should be in the root of the project directory to run the commands listed below
- Remember to start ganache (should run on port 8545; command
ganache-cli
), and open a different terminal window in order to run the commands "truffle migrate" (local testnet) and "truffle test" as listed below.
-
To compile: truffle compile
-
To migrate to local testnet: truffe migrate
-
To run tests: truffle test
-
To migrate to a public testnet (e.g. rinkeby): truffe migrate --network <testnet_name>
Note:
-
If you choose to redeploy this contract, you need to create an .env file and add your infura key (INFURA_API_KEY) and mnemonic (MNEMONIC) to it. Alternatively, you can deploy it locally (to dev). In this case, the contract address needs to be updated in file dapp.js (variable
ssAddress
) -
To run the frontend locally, it is recommended to use a live server (Live Server, "Ritwick Dey", v5.6.1)
- In VS code, right-click on the index.html file --> "Open with Live Server"
- Instrument owners have to upload information about the instrument(s) they want to make available for rent
- Leasers enter the website and register with Metamask
- Leasers browse the instruments
- Leasers select the item rent
- Leasers select the shipment method desired
- The contract becomes valid for the agreed period of time after the transaction has been approved
- The instrument is sent to the leaser
- The leaser returns the instrument to the owner after use
-
truffle migrate
-
truffle console
-
let instance = await InstrumentRental.deployed()
-
Use functions, e.g.
... to add an instrument:
instance.addInstrument("flute", "XXXXX", "https://pictureofaflute.jpg", web3.utils.toWei('0.003'), 3, 100)
... to fetch an instrument that has been added to the contract
instance.fetchItem(0)
- Confirmation that the leaser received the instrument
- Confirmation that the owner received the instrument back after renting it
- Methods to check if instrument has been returned in good shape or if damage occurred
- A method to check (and if so, enforce some penalty) if the leaser exceeds the time he/she was given allowance to keep the rented instrument