Overview The marketplace contract is located in the contracts folder, it inherits from openzeppellin’s ownable and safe math library. The contract takes charge of buying and selling of products. Once the contract is deployed, the owner (the account that deployed the contract) has the following duties
- Can add and remove admins
- Can add store owners
- Can toggle the contract functionalities’
- Can destroy the contract and remove it from the blockchain.
Directory structure:
- The build folder contains the artifacts of the compiled contracts
- The contract folder contains the solidity smart contract file (Marketplace. Sol)
- The test folder contains the tests written in JavaScript
- The migrations folder contains the file used to migrate the marketplace smart contract.
- The src folder contains the html, css and javascript file used for the smart contract’s frontend.
Dependencies
Truffle – to install truffle, simply run the command npm install -g truffle
To install project requirements, navigate to the project root directory and run npm install
How to deploy to a local network(ganache) Clone the contract to your local machine using git clone Run ganache and make sure it’s running on the port: 7545
To deploy the contract
Run truffle migrate –reset
Once it migrates successfully, we can test the contract by running truffle test
To run the web interface
Make sure you have metamask plugin installed, switch from the main Ethereum network to ropsten test network. You can get ropsten ether from the faucet. .
navigate to the project root directory on the command line and run npm run dev, A webpage should open automatically on port 3000,
if it doesn’t it simply go to the url localhost:3000 in your browser.
Start interacting with the contract.