A marketplace smart contract with basic transactions. Admin is the owner of the contract and must approve store applications before stores appear in the marketplace. Sellers and buyers can create a store (which must be approved by admin) in the marketplace to sell digital assets and can browse the marketplace, withdraw Ether from sells made, perform CRUD operations on their listed digital assets.
Ganache recommended, download Ganache and launch the application. This will generate a blockchain running locally on port 7545.
Or you can use Ganache CLI by npm install -g ganache-cli
(if not already installed) and then ganache-cli <options>
, which will run on port 8545.
Install IPFS
ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["*"]' && ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods "[\"PUT\", \"POST\", \"GET\"]" && ipfs config --json API.HTTPHeaders.Access-Control-Allow-Credentials '["true"]' && ipfs daemon
In a new terminal window, do the following:
git clone git@github.com:sophiacodes/sweet.git
cd sweet
npm install -g truffle // If not already installed
npm i
truffle compile
truffle migrate
truffle test
Interact with the dApp in a browser is using MetaMask, a browser extension for both Chrome and Firefox.
Connect MetaMask to the local blockchain created by Ganache. Click the menu that shows "Main Network" and select Custom RPC. In the box titled "New RPC URL" enter http://127.0.0.1:7545
(if using Ganache Application) or enter http://127.0.0.1:8545
(if using Ganache-CLI) and click Save.
npm start
The dApp will automagically open in a new tab in your browser on http://localhost:3000
By default in MetaMask the first account will belong to admin, you'll need to import other accounts who will be buyers/sellers.
Image source CryptoKittes
This dApp is a demo which is WIP, thus incomplete and is NOT FOR PRODUCTION.