-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 93dd71d
Showing
28 changed files
with
21,854 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.DS_Store | ||
*/node_modules/ | ||
.env | ||
cache/ | ||
artifacts/ | ||
backend/assets/ | ||
backend/contracts/web3dp-show.sol | ||
scripts/mint-nft.mjs | ||
scripts/store-assets.mjs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Contract based on https://docs.openzeppelin.com/contracts/4.x/erc721 | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.12; | ||
|
||
import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; | ||
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; | ||
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol"; | ||
import "@openzeppelin/contracts/utils/Counters.sol"; | ||
|
||
contract Web3DP is ERC721, ERC721Enumerable, ERC721URIStorage{ | ||
using Counters for Counters.Counter; | ||
Counters.Counter private _tokenIds; | ||
|
||
constructor() ERC721("Web3DP", "WP") {} | ||
|
||
function mintNFT(address recipient, string memory uri) | ||
public | ||
returns (uint256) | ||
{ | ||
_tokenIds.increment(); | ||
|
||
uint256 newItemId = _tokenIds.current(); | ||
_mint(recipient, newItemId); | ||
_setTokenURI(newItemId, uri); | ||
|
||
return newItemId; | ||
} | ||
|
||
// The following functions are overrides required by Solidity. | ||
|
||
function _beforeTokenTransfer(address from, address to, uint256 tokenIds) | ||
internal | ||
override(ERC721, ERC721Enumerable) | ||
{ | ||
super._beforeTokenTransfer(from, to, tokenIds); | ||
} | ||
|
||
function _burn(uint256 tokenIds) internal override(ERC721, ERC721URIStorage) { | ||
super._burn(tokenIds); | ||
} | ||
|
||
function tokenURI(uint256 tokenIds) | ||
public | ||
view | ||
override(ERC721, ERC721URIStorage) | ||
returns (string memory) | ||
{ | ||
return super.tokenURI(tokenIds); | ||
} | ||
|
||
function supportsInterface(bytes4 interfaceId) | ||
public | ||
view | ||
override(ERC721, ERC721Enumerable) | ||
returns (bool) | ||
{ | ||
return super.supportsInterface(interfaceId); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.12; | ||
|
||
contract Web3DPLabel{ | ||
struct Label { | ||
uint256 label_id; | ||
address user; | ||
string label; | ||
uint256 status; | ||
uint256 token_id; | ||
} | ||
|
||
// tokenID => Label[] | ||
mapping(uint256 => Label[]) public label_map; | ||
|
||
function addLabel(string memory label, uint256 token_id) public { | ||
Label memory newLabel = Label(label_map[token_id].length+1, msg.sender, label, 1, token_id); | ||
label_map[token_id].push(newLabel); | ||
} | ||
|
||
function removeLabel(string memory label, uint256 token_id) public { | ||
Label memory newLabel = Label(label_map[token_id].length+1, msg.sender, label, 0, token_id); | ||
label_map[token_id].push(newLabel); | ||
} | ||
|
||
function getLabels(uint256 token_id) public view returns (Label[] memory) { | ||
return label_map[token_id]; | ||
} | ||
|
||
function getLabel(uint256 token_id, uint256 label_id) public view returns (string memory) { | ||
return label_map[token_id][label_id-1].label; | ||
} | ||
|
||
function getLabelUser(uint256 token_id, uint256 label_id) public view returns (address) { | ||
return label_map[token_id][label_id-1].user; | ||
} | ||
|
||
function getLabelStatus(uint256 token_id, uint256 label_id) public view returns (uint256) { | ||
return label_map[token_id][label_id-1].status; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* @type import('hardhat/config').HardhatUserConfig | ||
*/ | ||
require("@nomiclabs/hardhat-ethers"); | ||
require('dotenv').config(); | ||
const { PRIVATE_KEY } = process.env; | ||
module.exports = { | ||
defaultNetwork: "PolygonMumbai", | ||
networks: { | ||
hardhat: { | ||
}, | ||
PolygonMumbai : { | ||
url: "https://rpc-mumbai.maticvigil.com", | ||
accounts: [PRIVATE_KEY] | ||
} | ||
}, | ||
solidity: { | ||
version: "0.8.12", | ||
settings: { | ||
optimizer: { | ||
enabled: true, | ||
runs: 200 | ||
} | ||
} | ||
}, | ||
} |
Oops, something went wrong.