This repo contains the demo code from the NFT marketplace application discussed on the blogs:
- Node.js
- An active AWS account
- AWS CLI (https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html)
Clone the repository and run the following commands to setup the code ($ is not part of the command):
$ npm install -g ganache-cli truffle
$ cd ShareToWinContract
$ npm install
$ ../cd ShareToWinRestApi
$ npm install
$ ../cd ShareToWinWeb
$ npm install
$ aws dynamodb create-table --table-name ShareToWin --attribute-definitions AttributeName=AssetID,AttributeType=N --key-schema AttributeName=AssetID,KeyType=HASH --provisioned-throughput ReadCapacityUnits=1,WriteCapacityUnits=1
Open four terminal windows.
- On the first terminal window make sure you are in the ShareToWinContract folder. Run the following command to start Ganache development server by running the ganache-cli
npx ganache-cli --acctKeys ../ShareToWinRestApi/ethaccounts.json
- On the second terminal window make sure you are in the ShareToWinContract folder. Run the following command to start truffle console.
truffle console --network development
Once connected to truffle console, issue the migrate command.
migrate
The migrate command will deploy the smart contract on ganache development network and display the deployed contract address
Deploying 'AssetToken'
transaction hash: 0xd20be4f8f7126f40ab66d11efac49ec260db251375bd11e729dd658373ecebe8
Blocks: 0 Seconds: 0
contract address: 0x0b10d5619d36aeF3ab9eD509196D7937F842a882
block number: 3
block timestamp: 1644449968
account: 0x3d46282D895a9e4Ba8Cb081fbcd6fA2Dd2844e62
balance: 99.91223912
gas used: 4096677 (0x3e82a5)
gas price: 20 gwei
value sent: 0 ETH
total cost: 0.08193354 ETH
- On the third terminal window make sure you are in the ShareToWinRestApi folder. Copy the contract address that is displayed on the second terminal when you ran the migrate truffle command into the envExport.sh file and run the following commands
source envExport.sh
npx nodemon --delay 1000ms index.js
This will start the express web server and listen on port 4080
- On the fourth window make sure you are in the ShareToWinWeb folder. Start the react web front end by entering the command
npm run start
This sample code is made available under a modified MIT license. See the LICENSE file.