Address Contract Verified
Address
0xA87709Fa414310af99B178cE5aE71C4870024B75
Balance
0 ETH
Nonce
1
Code Size
1498 bytes
Creator
0x9299DBA9...E8e5 at tx 0xc9bbd1b2...cf91df
Indexed Transactions
0
Contract Bytecode
1498 bytes
0x608060405234801561001057600080fd5b50600436106100575760003560e01c8063598b8e711461005c57806368bbc75c146100715780636dad56e5146100b55780638d859f3e146100dc578063983d95ce146100fc575b600080fd5b61006f61006a366004610461565b61010f565b005b6100987f00000000000000000000000028c3501fd8a248c6ac334c065fe7907062953cfd81565b6040516001600160a01b0390911681526020015b60405180910390f35b6100987f000000000000000000000000bc4ca0eda7647a8ab7c2061c2e118a18a936f13d81565b6100ee6a52b7d2dcc80cd2e400000081565b6040519081526020016100ac565b61006f61010a366004610461565b6102b3565b60005b81518110156101d057600082828151811061012f5761012f61051f565b60209081029190910101516040516323b872dd60e01b8152336004820152306024820152604481018290529091506001600160a01b037f000000000000000000000000bc4ca0eda7647a8ab7c2061c2e118a18a936f13d16906323b872dd90606401600060405180830381600087803b1580156101ab57600080fd5b505af11580156101bf573d6000803e3d6000fd5b505060019093019250610112915050565b5060006a52b7d2dcc80cd2e400000082516101eb9190610535565b6040516340c10f1960e01b8152336004820152602481018290529091507f00000000000000000000000028c3501fd8a248c6ac334c065fe7907062953cfd6001600160a01b0316906340c10f1990604401600060405180830381600087803b15801561025657600080fd5b505af115801561026a573d6000803e3d6000fd5b50505050336001600160a01b03167fff409334d2645d660e7cfa41a637aa21f45a79ecb9660a6931aa923bf75577c7836040516102a79190610560565b60405180910390a25050565b60005b81518110156103745760008282815181106102d3576102d361051f565b60209081029190910101516040516323b872dd60e01b8152306004820152336024820152604481018290529091506001600160a01b037f000000000000000000000000bc4ca0eda7647a8ab7c2061c2e118a18a936f13d16906323b872dd90606401600060405180830381600087803b15801561034f57600080fd5b505af1158015610363573d6000803e3d6000fd5b5050600190930192506102b6915050565b5060006a52b7d2dcc80cd2e4000000825161038f9190610535565b604051632770a7eb60e21b8152336004820152602481018290529091507f00000000000000000000000028c3501fd8a248c6ac334c065fe7907062953cfd6001600160a01b031690639dc29fac90604401600060405180830381600087803b1580156103fa57600080fd5b505af115801561040e573d6000803e3d6000fd5b50505050336001600160a01b03167f67e9df8b3c7743c9f1b625ba4f2b4e601206dbd46ed5c33c85a1242e4d23a2d1836040516102a79190610560565b634e487b7160e01b600052604160045260246000fd5b6000602080838503121561047457600080fd5b823567ffffffffffffffff8082111561048c57600080fd5b818501915085601f8301126104a057600080fd5b8135818111156104b2576104b261044b565b8060051b604051601f19603f830116810181811085821117156104d7576104d761044b565b6040529182528482019250838101850191888311156104f557600080fd5b938501935b82851015610513578435845293850193928501926104fa565b98975050505050505050565b634e487b7160e01b600052603260045260246000fd5b808202811582820484141761055a57634e487b7160e01b600052601160045260246000fd5b92915050565b6020808252825182820181905260009190848201906040850190845b818110156105985783518352928401929184019160010161057c565b5090969550505050505056fea2646970667358221220989325158a6aea63918d8409d1ab3fd43d40402a883ffddd5ce3c5587cead77b64736f6c63430008140033
Verified Source Code Full Match
Compiler: v0.8.20+commit.a1b79de6
EVM: paris
Optimization: Yes (200 runs)
BAYC.sol 55 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.20;
import {Owned} from "solmate/auth/Owned.sol";
import {ERC20} from "solmate/tokens/ERC20.sol";
/// @title BAYC memecoin
/// @notice This contract implements an ERC20 token with minting and burning capabilities.
/// @dev Inherits from ERC20 and Owned contracts.
contract BAYC is ERC20, Owned {
uint256 public constant MAX_SUPPLY = 1_000_000_000_000 * 10 ** 18;
/// @notice Address of the minter
address public minter;
/// @notice Event emitted when the minter is set
/// @param minter The address of the new minter
event MinterSet(address minter);
/// @notice Constructor to initialize the token and set the owner
/// @param _owner The address of the owner
constructor(address _owner) ERC20("BAYC", "BAYC", 18) Owned(_owner) {
emit Transfer(address(0), msg.sender, 0);
}
/// @notice Mints new tokens
/// @dev Only the minter can call this function
/// @param to The address to mint tokens to
/// @param amount The amount of tokens to mint
function mint(address to, uint256 amount) external {
require(msg.sender == minter, "UNAUTHORIZED");
require(totalSupply + amount <= MAX_SUPPLY, "MAX_SUPPLY_EXCEEDED");
_mint(to, amount);
}
/// @notice Burns tokens
/// @dev Only the minter can call this function
/// @param from The address to burn tokens from
/// @param amount The amount of tokens to burn
function burn(address from, uint256 amount) external {
require(msg.sender == minter, "UNAUTHORIZED");
_burn(from, amount);
}
/**
* Admin functions **
*/
/// @notice Sets the minter address
/// @dev Only the owner can call this function
/// @param _minter The address of the new minter
function setMinter(address _minter) external onlyOwner {
minter = _minter;
emit MinterSet(_minter);
}
}
BAYCExchange.sol 69 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.20;
import {ERC721} from "solmate/tokens/ERC721.sol";
import "./BAYC.sol";
contract BAYCExchange {
uint256 public constant PRICE = 100_000_000e18; // 100m BAYC coin
/// @notice The BAYC memecoin contract
BAYC public immutable BAYCMemecoin;
/// @notice The BAYC NFT contract
ERC721 public immutable BAYCNFT;
/// @notice Event emitted when an NFT is deposited
/// @param user The address of the user
/// @param tokenIds The IDs of the NFT
event Deposit(address indexed user, uint256[] tokenIds);
/// @notice Event emitted when an NFT is withdrawn
/// @param user The address of the user
/// @param tokenIds The IDs of the NFT
event Withdraw(address indexed user, uint256[] tokenIds);
/// @notice Constructor to initialize the contract
/// @param _BAYCMemecoin The address of the BAYC memecoin contract
/// @param _BAYCNFT The address of the BAYC NFT contract
constructor(address _BAYCMemecoin, address _BAYCNFT) {
BAYCMemecoin = BAYC(_BAYCMemecoin);
BAYCNFT = ERC721(_BAYCNFT);
}
/// @notice Deposits a list of NFTs and mints BAYC memecoin
/// @param tokenIds The IDs of the NFTs to deposit
function deposit(uint256[] memory tokenIds) public {
for (uint256 i = 0; i < tokenIds.length;) {
uint256 tokenId = tokenIds[i];
BAYCNFT.transferFrom(msg.sender, address(this), tokenId);
unchecked {
i++;
}
}
uint256 amount = tokenIds.length * PRICE;
BAYCMemecoin.mint(msg.sender, amount);
emit Deposit(msg.sender, tokenIds);
}
/// @notice Withdraws a list of NFTs and burns BAYC memecoin
/// @param tokenIds The ID of the NFT to withdraw
function withdraw(uint256[] memory tokenIds) public {
for (uint256 i = 0; i < tokenIds.length;) {
uint256 tokenId = tokenIds[i];
BAYCNFT.transferFrom(address(this), msg.sender, tokenId);
unchecked {
i++;
}
}
uint256 amount = tokenIds.length * PRICE;
BAYCMemecoin.burn(msg.sender, amount);
emit Withdraw(msg.sender, tokenIds);
}
}
Owned.sol 44 lines
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;
/// @notice Simple single owner authorization mixin.
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Owned.sol)
abstract contract Owned {
/*//////////////////////////////////////////////////////////////
EVENTS
//////////////////////////////////////////////////////////////*/
event OwnershipTransferred(address indexed user, address indexed newOwner);
/*//////////////////////////////////////////////////////////////
OWNERSHIP STORAGE
//////////////////////////////////////////////////////////////*/
address public owner;
modifier onlyOwner() virtual {
require(msg.sender == owner, "UNAUTHORIZED");
_;
}
/*//////////////////////////////////////////////////////////////
CONSTRUCTOR
//////////////////////////////////////////////////////////////*/
constructor(address _owner) {
owner = _owner;
emit OwnershipTransferred(address(0), _owner);
}
/*//////////////////////////////////////////////////////////////
OWNERSHIP LOGIC
//////////////////////////////////////////////////////////////*/
function transferOwnership(address newOwner) public virtual onlyOwner {
owner = newOwner;
emit OwnershipTransferred(msg.sender, newOwner);
}
}
ERC20.sol 206 lines
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;
/// @notice Modern and gas efficient ERC20 + EIP-2612 implementation.
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC20.sol)
/// @author Modified from Uniswap (https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol)
/// @dev Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it.
abstract contract ERC20 {
/*//////////////////////////////////////////////////////////////
EVENTS
//////////////////////////////////////////////////////////////*/
event Transfer(address indexed from, address indexed to, uint256 amount);
event Approval(address indexed owner, address indexed spender, uint256 amount);
/*//////////////////////////////////////////////////////////////
METADATA STORAGE
//////////////////////////////////////////////////////////////*/
string public name;
string public symbol;
uint8 public immutable decimals;
/*//////////////////////////////////////////////////////////////
ERC20 STORAGE
//////////////////////////////////////////////////////////////*/
uint256 public totalSupply;
mapping(address => uint256) public balanceOf;
mapping(address => mapping(address => uint256)) public allowance;
/*//////////////////////////////////////////////////////////////
EIP-2612 STORAGE
//////////////////////////////////////////////////////////////*/
uint256 internal immutable INITIAL_CHAIN_ID;
bytes32 internal immutable INITIAL_DOMAIN_SEPARATOR;
mapping(address => uint256) public nonces;
/*//////////////////////////////////////////////////////////////
CONSTRUCTOR
//////////////////////////////////////////////////////////////*/
constructor(
string memory _name,
string memory _symbol,
uint8 _decimals
) {
name = _name;
symbol = _symbol;
decimals = _decimals;
INITIAL_CHAIN_ID = block.chainid;
INITIAL_DOMAIN_SEPARATOR = computeDomainSeparator();
}
/*//////////////////////////////////////////////////////////////
ERC20 LOGIC
//////////////////////////////////////////////////////////////*/
function approve(address spender, uint256 amount) public virtual returns (bool) {
allowance[msg.sender][spender] = amount;
emit Approval(msg.sender, spender, amount);
return true;
}
function transfer(address to, uint256 amount) public virtual returns (bool) {
balanceOf[msg.sender] -= amount;
// Cannot overflow because the sum of all user
// balances can't exceed the max uint256 value.
unchecked {
balanceOf[to] += amount;
}
emit Transfer(msg.sender, to, amount);
return true;
}
function transferFrom(
address from,
address to,
uint256 amount
) public virtual returns (bool) {
uint256 allowed = allowance[from][msg.sender]; // Saves gas for limited approvals.
if (allowed != type(uint256).max) allowance[from][msg.sender] = allowed - amount;
balanceOf[from] -= amount;
// Cannot overflow because the sum of all user
// balances can't exceed the max uint256 value.
unchecked {
balanceOf[to] += amount;
}
emit Transfer(from, to, amount);
return true;
}
/*//////////////////////////////////////////////////////////////
EIP-2612 LOGIC
//////////////////////////////////////////////////////////////*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) public virtual {
require(deadline >= block.timestamp, "PERMIT_DEADLINE_EXPIRED");
// Unchecked because the only math done is incrementing
// the owner's nonce which cannot realistically overflow.
unchecked {
address recoveredAddress = ecrecover(
keccak256(
abi.encodePacked(
"\x19\x01",
DOMAIN_SEPARATOR(),
keccak256(
abi.encode(
keccak256(
"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"
),
owner,
spender,
value,
nonces[owner]++,
deadline
)
)
)
),
v,
r,
s
);
require(recoveredAddress != address(0) && recoveredAddress == owner, "INVALID_SIGNER");
allowance[recoveredAddress][spender] = value;
}
emit Approval(owner, spender, value);
}
function DOMAIN_SEPARATOR() public view virtual returns (bytes32) {
return block.chainid == INITIAL_CHAIN_ID ? INITIAL_DOMAIN_SEPARATOR : computeDomainSeparator();
}
function computeDomainSeparator() internal view virtual returns (bytes32) {
return
keccak256(
abi.encode(
keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"),
keccak256(bytes(name)),
keccak256("1"),
block.chainid,
address(this)
)
);
}
/*//////////////////////////////////////////////////////////////
INTERNAL MINT/BURN LOGIC
//////////////////////////////////////////////////////////////*/
function _mint(address to, uint256 amount) internal virtual {
totalSupply += amount;
// Cannot overflow because the sum of all user
// balances can't exceed the max uint256 value.
unchecked {
balanceOf[to] += amount;
}
emit Transfer(address(0), to, amount);
}
function _burn(address from, uint256 amount) internal virtual {
balanceOf[from] -= amount;
// Cannot underflow because a user's balance
// will never be larger than the total supply.
unchecked {
totalSupply -= amount;
}
emit Transfer(from, address(0), amount);
}
}
ERC721.sol 231 lines
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;
/// @notice Modern, minimalist, and gas efficient ERC-721 implementation.
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC721.sol)
abstract contract ERC721 {
/*//////////////////////////////////////////////////////////////
EVENTS
//////////////////////////////////////////////////////////////*/
event Transfer(address indexed from, address indexed to, uint256 indexed id);
event Approval(address indexed owner, address indexed spender, uint256 indexed id);
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/*//////////////////////////////////////////////////////////////
METADATA STORAGE/LOGIC
//////////////////////////////////////////////////////////////*/
string public name;
string public symbol;
function tokenURI(uint256 id) public view virtual returns (string memory);
/*//////////////////////////////////////////////////////////////
ERC721 BALANCE/OWNER STORAGE
//////////////////////////////////////////////////////////////*/
mapping(uint256 => address) internal _ownerOf;
mapping(address => uint256) internal _balanceOf;
function ownerOf(uint256 id) public view virtual returns (address owner) {
require((owner = _ownerOf[id]) != address(0), "NOT_MINTED");
}
function balanceOf(address owner) public view virtual returns (uint256) {
require(owner != address(0), "ZERO_ADDRESS");
return _balanceOf[owner];
}
/*//////////////////////////////////////////////////////////////
ERC721 APPROVAL STORAGE
//////////////////////////////////////////////////////////////*/
mapping(uint256 => address) public getApproved;
mapping(address => mapping(address => bool)) public isApprovedForAll;
/*//////////////////////////////////////////////////////////////
CONSTRUCTOR
//////////////////////////////////////////////////////////////*/
constructor(string memory _name, string memory _symbol) {
name = _name;
symbol = _symbol;
}
/*//////////////////////////////////////////////////////////////
ERC721 LOGIC
//////////////////////////////////////////////////////////////*/
function approve(address spender, uint256 id) public virtual {
address owner = _ownerOf[id];
require(msg.sender == owner || isApprovedForAll[owner][msg.sender], "NOT_AUTHORIZED");
getApproved[id] = spender;
emit Approval(owner, spender, id);
}
function setApprovalForAll(address operator, bool approved) public virtual {
isApprovedForAll[msg.sender][operator] = approved;
emit ApprovalForAll(msg.sender, operator, approved);
}
function transferFrom(
address from,
address to,
uint256 id
) public virtual {
require(from == _ownerOf[id], "WRONG_FROM");
require(to != address(0), "INVALID_RECIPIENT");
require(
msg.sender == from || isApprovedForAll[from][msg.sender] || msg.sender == getApproved[id],
"NOT_AUTHORIZED"
);
// Underflow of the sender's balance is impossible because we check for
// ownership above and the recipient's balance can't realistically overflow.
unchecked {
_balanceOf[from]--;
_balanceOf[to]++;
}
_ownerOf[id] = to;
delete getApproved[id];
emit Transfer(from, to, id);
}
function safeTransferFrom(
address from,
address to,
uint256 id
) public virtual {
transferFrom(from, to, id);
require(
to.code.length == 0 ||
ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, "") ==
ERC721TokenReceiver.onERC721Received.selector,
"UNSAFE_RECIPIENT"
);
}
function safeTransferFrom(
address from,
address to,
uint256 id,
bytes calldata data
) public virtual {
transferFrom(from, to, id);
require(
to.code.length == 0 ||
ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, data) ==
ERC721TokenReceiver.onERC721Received.selector,
"UNSAFE_RECIPIENT"
);
}
/*//////////////////////////////////////////////////////////////
ERC165 LOGIC
//////////////////////////////////////////////////////////////*/
function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
return
interfaceId == 0x01ffc9a7 || // ERC165 Interface ID for ERC165
interfaceId == 0x80ac58cd || // ERC165 Interface ID for ERC721
interfaceId == 0x5b5e139f; // ERC165 Interface ID for ERC721Metadata
}
/*//////////////////////////////////////////////////////////////
INTERNAL MINT/BURN LOGIC
//////////////////////////////////////////////////////////////*/
function _mint(address to, uint256 id) internal virtual {
require(to != address(0), "INVALID_RECIPIENT");
require(_ownerOf[id] == address(0), "ALREADY_MINTED");
// Counter overflow is incredibly unrealistic.
unchecked {
_balanceOf[to]++;
}
_ownerOf[id] = to;
emit Transfer(address(0), to, id);
}
function _burn(uint256 id) internal virtual {
address owner = _ownerOf[id];
require(owner != address(0), "NOT_MINTED");
// Ownership check above ensures no underflow.
unchecked {
_balanceOf[owner]--;
}
delete _ownerOf[id];
delete getApproved[id];
emit Transfer(owner, address(0), id);
}
/*//////////////////////////////////////////////////////////////
INTERNAL SAFE MINT LOGIC
//////////////////////////////////////////////////////////////*/
function _safeMint(address to, uint256 id) internal virtual {
_mint(to, id);
require(
to.code.length == 0 ||
ERC721TokenReceiver(to).onERC721Received(msg.sender, address(0), id, "") ==
ERC721TokenReceiver.onERC721Received.selector,
"UNSAFE_RECIPIENT"
);
}
function _safeMint(
address to,
uint256 id,
bytes memory data
) internal virtual {
_mint(to, id);
require(
to.code.length == 0 ||
ERC721TokenReceiver(to).onERC721Received(msg.sender, address(0), id, data) ==
ERC721TokenReceiver.onERC721Received.selector,
"UNSAFE_RECIPIENT"
);
}
}
/// @notice A generic interface for a contract which properly accepts ERC721 tokens.
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC721.sol)
abstract contract ERC721TokenReceiver {
function onERC721Received(
address,
address,
uint256,
bytes calldata
) external virtual returns (bytes4) {
return ERC721TokenReceiver.onERC721Received.selector;
}
}
Read Contract
BAYCMemecoin 0x68bbc75c → address
BAYCNFT 0x6dad56e5 → address
PRICE 0x8d859f3e → uint256
Write Contract 2 functions
These functions modify contract state and require a wallet transaction to execute.
deposit 0x598b8e71
uint256[] tokenIds
withdraw 0x983d95ce
uint256[] tokenIds
Recent Transactions
No transactions found for this address