文件 1 的 10:Context.sol
pragma solidity ^0.8.0;
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
文件 2 的 10:ERC20.sol
pragma solidity ^0.8.0;
import "./IERC20.sol";
import "./extensions/IERC20Metadata.sol";
import "../../utils/Context.sol";
contract ERC20 is Context, IERC20, IERC20Metadata {
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
function name() public view virtual override returns (string memory) {
return _name;
}
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
function decimals() public view virtual override returns (uint8) {
return 18;
}
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(
address sender,
address recipient,
uint256 amount
) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
uint256 currentAllowance = _allowances[sender][_msgSender()];
require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
unchecked {
_approve(sender, _msgSender(), currentAllowance - amount);
}
return true;
}
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
unchecked {
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
}
return true;
}
function _transfer(
address sender,
address recipient,
uint256 amount
) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
unchecked {
_balances[sender] = senderBalance - amount;
}
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
_afterTokenTransfer(sender, recipient, amount);
}
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
_balances[account] += amount;
emit Transfer(address(0), account, amount);
_afterTokenTransfer(address(0), account, amount);
}
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
unchecked {
_balances[account] = accountBalance - amount;
}
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
_afterTokenTransfer(account, address(0), amount);
}
function _approve(
address owner,
address spender,
uint256 amount
) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _beforeTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
function _afterTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
}
文件 3 的 10:ERC20Capped.sol
pragma solidity ^0.8.0;
import "../ERC20.sol";
abstract contract ERC20Capped is ERC20 {
uint256 private immutable _cap;
constructor(uint256 cap_) {
require(cap_ > 0, "ERC20Capped: cap is 0");
_cap = cap_;
}
function cap() public view virtual returns (uint256) {
return _cap;
}
function _mint(address account, uint256 amount) internal virtual override {
require(ERC20.totalSupply() + amount <= cap(), "ERC20Capped: cap exceeded");
super._mint(account, amount);
}
}
文件 4 的 10:IERC165.sol
pragma solidity ^0.8.0;
interface IERC165 {
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
文件 5 的 10:IERC20.sol
pragma solidity ^0.8.0;
interface IERC20 {
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address recipient, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
文件 6 的 10:IERC20Metadata.sol
pragma solidity ^0.8.0;
import "../IERC20.sol";
interface IERC20Metadata is IERC20 {
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function decimals() external view returns (uint8);
}
文件 7 的 10:IERC721.sol
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
interface IERC721 is IERC165 {
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
function balanceOf(address owner) external view returns (uint256 balance);
function ownerOf(uint256 tokenId) external view returns (address owner);
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
function approve(address to, uint256 tokenId) external;
function getApproved(uint256 tokenId) external view returns (address operator);
function setApprovalForAll(address operator, bool _approved) external;
function isApprovedForAll(address owner, address operator) external view returns (bool);
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata data
) external;
}
文件 8 的 10:IERC721Enumerable.sol
pragma solidity ^0.8.0;
import "../IERC721.sol";
interface IERC721Enumerable is IERC721 {
function totalSupply() external view returns (uint256);
function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId);
function tokenByIndex(uint256 index) external view returns (uint256);
}
文件 9 的 10:Ownable.sol
pragma solidity ^0.8.0;
import "../utils/Context.sol";
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor() {
_setOwner(_msgSender());
}
function owner() public view virtual returns (address) {
return _owner;
}
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
function renounceOwnership() public virtual onlyOwner {
_setOwner(address(0));
}
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_setOwner(newOwner);
}
function _setOwner(address newOwner) private {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
文件 10 的 10:sgld.sol
pragma solidity ^0.8.4;
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Capped.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol";
contract SwampGold is Ownable, ERC20Capped {
bool public paused;
mapping(uint256 => mapping(uint256 => bool)) toadzSeasonClaimedByTokenId;
mapping(uint256 => mapping(uint256 => bool)) flyzSeasonClaimedByTokenId;
mapping(uint256 => mapping(uint256 => bool)) polzSeasonClaimedByTokenId;
uint256 season = 0;
struct CyrptoContractInfo {
address lootContractAddress;
IERC721Enumerable lootContract;
uint256 tokenAmount;
uint256 tokenStartId;
uint256 tokenEndId;
}
CyrptoContractInfo toadz;
CyrptoContractInfo flyz;
CyrptoContractInfo polz;
uint256[] private _claimedToadz;
uint256[] private _claimedFlyz;
uint256[] private _claimedPolz;
function init() internal{
address toadzContractAddress = 0x1CB1A5e65610AEFF2551A50f76a87a7d3fB649C6;
address flyzContractAddress = 0xf8b0a49dA21e6381f1cd3CF43445800abe852179;
address polzContractAddress = 0x9aA03df95b6D3c6edFb53c09A4A8473d0D642D32;
toadz.lootContractAddress = toadzContractAddress;
toadz.lootContract = IERC721Enumerable(toadzContractAddress);
toadz.tokenAmount = 8500 * (10**decimals());
toadz.tokenStartId = 1;
toadz.tokenEndId = 7025;
flyz.lootContractAddress = flyzContractAddress;
flyz.lootContract = IERC721Enumerable(flyzContractAddress);
flyz.tokenAmount = 1500 * (10**decimals());
flyz.tokenStartId = 1;
flyz.tokenEndId = 7026;
polz.lootContractAddress = polzContractAddress;
polz.lootContract = IERC721Enumerable(polzContractAddress);
polz.tokenAmount = 1000 * (10**decimals());
polz.tokenStartId = 1;
polz.tokenEndId = 10000;
}
function setPaused(bool _paused) public onlyOwner {
paused = _paused;
}
function claimToadzById(uint256 tokenId) external {
require(paused == false, "Contract Paused");
require(
_msgSender() == toadz.lootContract.ownerOf(tokenId),
"MUST_OWN_TOKEN_ID"
);
_claimToadz(tokenId, _msgSender());
}
function claimFlyzById(uint256 tokenId) external {
require(paused == false, "Contract Paused");
require(
_msgSender() == flyz.lootContract.ownerOf(tokenId),
"MUST_OWN_TOKEN_ID"
);
_claimFlyz(tokenId, _msgSender());
}
function claimPolzById(uint256 tokenId) external {
require(paused == false, "Contract Paused");
require(
_msgSender() == polz.lootContract.ownerOf(tokenId),
"MUST_OWN_TOKEN_ID"
);
_claimPolz(tokenId, _msgSender());
}
function claimAllToadz() external {
require(paused == false, "Contract Paused");
uint256 tokenBalanceOwner = toadz.lootContract.balanceOf(_msgSender());
require(tokenBalanceOwner > 0, "NO_TOKENS_OWNED");
for (uint256 i = 0; i < tokenBalanceOwner; i++) {
_claimToadz(
toadz.lootContract.tokenOfOwnerByIndex(_msgSender(), i),
_msgSender()
);
}
}
function claimAllFlyz() external {
require(paused == false, "Contract Paused");
uint256 tokenBalanceOwner = flyz.lootContract.balanceOf(_msgSender());
require(tokenBalanceOwner > 0, "NO_TOKENS_OWNED");
for (uint256 i = 0; i < tokenBalanceOwner; i++) {
_claimFlyz(
flyz.lootContract.tokenOfOwnerByIndex(_msgSender(), i),
_msgSender()
);
}
}
function claimAllPolz() external {
require(paused == false, "Contract Paused");
uint256 tokenBalanceOwner = polz.lootContract.balanceOf(_msgSender());
require(tokenBalanceOwner > 0, "NO_TOKENS_OWNED");
for (uint256 i = 0; i < tokenBalanceOwner; i++) {
_claimPolz(
polz.lootContract.tokenOfOwnerByIndex(_msgSender(), i),
_msgSender()
);
}
}
function _claimToadz(uint256 tokenId, address tokenOwner) internal {
require(
tokenId >= toadz.tokenStartId && tokenId <= toadz.tokenEndId,
"TOKEN_ID_OUT_OF_RANGE"
);
require(
!toadzSeasonClaimedByTokenId[season][tokenId],
"GOLD_CLAIMED_FOR_TOKEN_ID"
);
toadzSeasonClaimedByTokenId[season][tokenId] = true;
_mint(tokenOwner, toadz.tokenAmount);
_claimedToadz.push(tokenId);
}
function _claimFlyz(uint256 tokenId, address tokenOwner) internal {
require(
tokenId >= flyz.tokenStartId && tokenId <= flyz.tokenEndId,
"TOKEN_ID_OUT_OF_RANGE"
);
require(
!flyzSeasonClaimedByTokenId[season][tokenId],
"GOLD_CLAIMED_FOR_TOKEN_ID"
);
flyzSeasonClaimedByTokenId[season][tokenId] = true;
_mint(tokenOwner, flyz.tokenAmount);
_claimedFlyz.push(tokenId);
}
function _claimPolz(uint256 tokenId, address tokenOwner) internal {
require(
tokenId >= polz.tokenStartId && tokenId <= polz.tokenEndId,
"TOKEN_ID_OUT_OF_RANGE"
);
require(
!polzSeasonClaimedByTokenId[season][tokenId],
"GOLD_CLAIMED_FOR_TOKEN_ID"
);
polzSeasonClaimedByTokenId[season][tokenId] = true;
_mint(tokenOwner, polz.tokenAmount);
_claimedPolz.push(tokenId);
}
function claimedToadz() public view returns (uint256[] memory) {
return _claimedToadz;
}
function claimedFlyz() public view returns (uint256[] memory) {
return _claimedFlyz;
}
function claimedPolz() public view returns (uint256[] memory) {
return _claimedPolz;
}
function DAOMint(uint256 amountDisplayValue) external onlyOwner {
require(paused == false, "Contract Paused");
_mint(owner(), amountDisplayValue * (10**decimals()));
}
constructor() public Ownable() ERC20("Swamp Gold", "SGLD") ERC20Capped(90000000 * (10**decimals())) {
init();
}
}
{
"compilationTarget": {
"contracts/sgld.sol": "SwampGold"
},
"evmVersion": "london",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": false,
"runs": 200
},
"remappings": []
}
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[{"internalType":"uint256","name":"amountDisplayValue","type":"uint256"}],"name":"DAOMint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"cap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claimAllFlyz","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"claimAllPolz","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"claimAllToadz","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"claimFlyzById","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"claimPolzById","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"claimToadzById","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"claimedFlyz","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claimedPolz","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claimedToadz","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_paused","type":"bool"}],"name":"setPaused","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}]