-
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
Arda Usman
authored and
Arda Usman
committed
May 25, 2022
1 parent
858dfc9
commit 7d53bd6
Showing
47 changed files
with
11,250 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,40 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
|
||
import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; | ||
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.sol"; | ||
import "@openzeppelin/contracts/access/AccessControl.sol"; | ||
import "@openzeppelin/contracts/utils/Counters.sol"; | ||
|
||
/** | ||
* @title DamnValuableNFT | ||
* @author Damn Vulnerable DeFi (https://damnvulnerabledefi.xyz) | ||
* @notice Implementation of a mintable and burnable NFT with role-based access controls | ||
*/ | ||
contract DamnValuableNFT is ERC721, ERC721Burnable, AccessControl { | ||
using Counters for Counters.Counter; | ||
|
||
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE"); | ||
Counters.Counter private _tokenIdCounter; | ||
|
||
constructor() ERC721("DamnValuableNFT", "DVNFT") { | ||
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender); | ||
_setupRole(MINTER_ROLE, msg.sender); | ||
} | ||
|
||
function safeMint(address to) public onlyRole(MINTER_ROLE) returns (uint256) { | ||
uint256 tokenId = _tokenIdCounter.current(); | ||
_safeMint(to, tokenId); | ||
_tokenIdCounter.increment(); | ||
return tokenId; | ||
} | ||
|
||
function supportsInterface(bytes4 interfaceId) | ||
public | ||
view | ||
override(ERC721, AccessControl) | ||
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,17 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.0; | ||
|
||
import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; | ||
|
||
/** | ||
* @title DamnValuableToken | ||
* @author Damn Vulnerable DeFi (https://damnvulnerabledefi.xyz) | ||
*/ | ||
contract DamnValuableToken is ERC20 { | ||
|
||
// Decimals are set to 18 by default in `ERC20` | ||
constructor() ERC20("DamnValuableToken", "DVT") { | ||
_mint(msg.sender, type(uint256).max); | ||
} | ||
} |
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,31 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.0; | ||
|
||
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Snapshot.sol"; | ||
|
||
/** | ||
* @title DamnValuableTokenSnapshot | ||
* @author Damn Vulnerable DeFi (https://damnvulnerabledefi.xyz) | ||
*/ | ||
contract DamnValuableTokenSnapshot is ERC20Snapshot { | ||
|
||
uint256 private lastSnapshotId; | ||
|
||
constructor(uint256 initialSupply) ERC20("DamnValuableToken", "DVT") { | ||
_mint(msg.sender, initialSupply); | ||
} | ||
|
||
function snapshot() public returns (uint256) { | ||
lastSnapshotId = _snapshot(); | ||
return lastSnapshotId; | ||
} | ||
|
||
function getBalanceAtLastSnapshot(address account) external view returns (uint256) { | ||
return balanceOfAt(account, lastSnapshotId); | ||
} | ||
|
||
function getTotalSupplyAtLastSnapshot() external view returns (uint256) { | ||
return totalSupplyAt(lastSnapshotId); | ||
} | ||
} |
Oops, something went wrong.