Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Final Project for ELEN 6883 #5

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions 6883-Final-Project/BlockChain-Final-Project/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
The MIT License (MIT)

Copyright (c) 2018 Truffle

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

116 changes: 116 additions & 0 deletions 6883-Final-Project/BlockChain-Final-Project/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
# NFT Marketplace Smart Contract Development
## Final Project for course ELEN 6883 Blockchain
### Overview

This is the Final Project for ELEN 6883 Blockchain. The NFT marketplace smart contract will allow users to create, buy, sell, and trade unique digital assets represented as NFTs. The project will involve creating an ERC-721 compliant smart contract, designing a user interface for the marketplace, and implementing additional features to ensure the marketplace's security and usability.

### Team member:

Jing Wu(jw4288), Xin Fang(xf2246) and Yueyang Ying(yy3267)

### Original project path

https://github.com/Ichigaya-Mio/BlockChain-Final-Project

### Documentation:
#### main contract:
NFTMarketplace.sol



### Installing

First, you will need to install the dependencies with: npm install.

Run the following command in your terminal after cloning the main repo:

```shell
$ npm install
```

Then, you will need to install Truffle globally by running the following command int your terminal:

```shell
$ npm install -g truffle
```

If you can not install suceefully, you could use:

```shell
$ sudo npm install -g truffle
```

### Running the Tests

First, you will have to compile the smart contracts by running the following command in your terminal:

```shell
$ truffle compile
```

Then you will have to install and run Ganache to run your blockchain locally:

https://www.trufflesuite.com/ganache

we provide two tests, one for local and one for online.

### Deployment on Local Blockchain and test it locally

Deploy the contracts on your Ganache local blockchain by running the following command:

```shell
$ truffle migrate --network development
```
The tests can be executed by running the following command:

```shell
$ truffle test ./test/NFT.test.js
```

### Deployment on Online platform and test it remotely

Before test online, you need to modify related part in truffle-config.js (Metamask wallet&API key)

then, you can run following two commands:

```shell
truffle migrate --network sepolia
```

```shell
truffle test ./test/NFTOnline.test.js --network sepolia
```

And the deployment status and the contract address will be shown in terminal. You can monitor the contracts, account information on Etherscan:

https://etherscan.io/


### User Interface Interact

You can interact with our user interface by using node. You need to change your current dictionary into

```shell
cd /frontend
```

first, and then run:

```shell
node app.js
```

Then, go to

http://localhost:3000

and the interface of NFT marketplace will appear in front of you.

### Contributions of Each Team Member

Jing Wu(jw4288) and Xin Fang(xf2246) are responsible for:
1. designing, implementing and testing the NFT marketplace smart contract locally.
2. UI designing and implementing.
3. Implementing additional features, such as access control and error handling, to ensure the contract is reliable.

Yueyang Ying(yy3267) is responsible for deploying and testing the smart contract online, to make sure that it works well not only locally but also remotely.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;

// A library is like a contract with reusable code, which can be called by other contracts.
// Deploying common code can reduce gas costs.
library ConvertLib{
function convert(uint amount, uint conversionRate) public pure returns (uint convertedAmount)
{
return amount * conversionRate;
}
}
35 changes: 35 additions & 0 deletions 6883-Final-Project/BlockChain-Final-Project/contracts/MetaCoin.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// SPDX-License-Identifier: MIT
// Tells the Solidity compiler to compile only from v0.8.13 to v0.9.0
pragma solidity ^0.8.13;

import "./ConvertLib.sol";

// This is just a simple example of a coin-like contract.
// It is not ERC20 compatible and cannot be expected to talk to other
// coin/token contracts.

contract MetaCoin {
mapping (address => uint) balances;

event Transfer(address indexed _from, address indexed _to, uint256 _value);

constructor() {
balances[tx.origin] = 10000;
}

function sendCoin(address receiver, uint amount) public returns(bool sufficient) {
if (balances[msg.sender] < amount) return false;
balances[msg.sender] -= amount;
balances[receiver] += amount;
emit Transfer(msg.sender, receiver, amount);
return true;
}

function getBalanceInEth(address addr) public view returns(uint){
return ConvertLib.convert(getBalance(addr),2);
}

function getBalance(address addr) public view returns(uint) {
return balances[addr];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;

contract Migrations {
address public owner;
uint public last_completed_migration;

constructor() {
owner = msg.sender;
}

modifier restricted() {
if (msg.sender == owner) _;
}

function setCompleted(uint completed) public restricted {
last_completed_migration = completed;
}

function upgrade(address new_address) public restricted {
Migrations upgraded = Migrations(new_address);
upgraded.setCompleted(last_completed_migration);
}
}
Loading