Address Contract Verified
Address
0xD75b68b4e39056B3aF02AebDD9AeEFE0DcaBe585
Balance
0 ETH
Nonce
1
Code Size
4291 bytes
Creator
0x747751d1...783C at tx 0xb9cb90c2...aa03e1
Indexed Transactions
Index loading...
Contract Bytecode
4291 bytes
0x608060405234801561000f575f5ffd5b5060043610610148575f3560e01c8063883b137f116100bf578063b3edb5be11610079578063b3edb5be14610325578063bd6375801461034c578063c290d6911461035f578063d547741f14610372578063d96a094a14610385578063e9fca28314610398575f5ffd5b8063883b137f146102885780638d859f3e146102af5780638e6bee97146102d657806391d14854146102e9578063a217fddf146102fc578063ad65651014610303575f5ffd5b806336568abe1161011057806336568abe146102205780633f4ba83a146102335780634cd1729c1461023b5780635c975abb1461024e5780637c0b8de2146102595780638456cb5914610280575f5ffd5b806301ffc9a71461014c578063057707a014610174578063248a9ca3146101a95780632d2c5565146101cc5780632f2ff15d1461020b575b5f5ffd5b61015f61015a366004610f22565b6103ab565b60405190151581526020015b60405180910390f35b61019b7f000000000000000000000000000000000000000000000000000000000000ea6081565b60405190815260200161016b565b61019b6101b7366004610f50565b5f908152600160208190526040909120015490565b6101f37f00000000000000000000000097b4e7a5f1e82eb38edbc96d4df83878b8a8043f81565b6040516001600160a01b03909116815260200161016b565b61021e610219366004610f67565b6103e1565b005b61021e61022e366004610f67565b61040c565b61021e610444565b61021e610249366004610f50565b610459565b60025460ff1661015f565b6101f37f00000000000000000000000050e6722656d88cf3750dd9e05cbcaa2c01cd3e9f81565b61021e6104c1565b6101f37f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec781565b61019b7f00000000000000000000000000000000000000000000000000000000000186a081565b61021e6102e4366004610fa0565b6104d3565b61015f6102f7366004610f67565b6104fa565b61019b5f81565b61015f610311366004610f50565b60036020525f908152604090205460ff1681565b61019b7f00000000000000000000000000000000000000000000000000000000000f424081565b61021e61035a366004610f50565b610524565b61021e61036d366004610f50565b61058f565b61021e610380366004610f67565b6105b2565b61021e610393366004610f50565b6105d7565b61021e6103a6366004610fa0565b6105f1565b5f6001600160e01b03198216637965db0b60e01b14806103db57506301ffc9a760e01b6001600160e01b03198316145b92915050565b5f82815260016020819052604090912001546103fc8161060b565b6104068383610615565b50505050565b6001600160a01b03811633146104355760405163334bd91960e11b815260040160405180910390fd5b61043f828261068b565b505050565b5f61044e8161060b565b6104566106f6565b50565b5f6104638161060b565b8161048157604051633303523160e11b815260040160405180910390fd5b5f82815260036020526040808220805460ff191690555183917f48e917e70e4d8d51a0b5ac08813766e013d5755af087a5225a08c0c76de0757f91a25050565b5f6104cb8161060b565b610456610748565b6104db610785565b6104e36107e1565b6104ed8282610829565b6104f660015f55565b5050565b5f9182526001602090815260408084206001600160a01b0393909316845291905290205460ff1690565b5f61052e8161060b565b8161054c57604051633303523160e11b815260040160405180910390fd5b5f82815260036020526040808220805460ff191660011790555183917fb441f89dd806d4d80989a9c9612dd71f092b57d692a2e81bb8359e3dfe7effc591a25050565b610597610785565b61059f6107e1565b6105a9815f610829565b61045660015f55565b5f82815260016020819052604090912001546105cd8161060b565b610406838361068b565b6105df610785565b6105e76107e1565b6105a9815f61088d565b6105f9610785565b6106016107e1565b6104ed828261088d565b61045681336108d1565b5f61062083836104fa565b610684575f8381526001602081815260408084206001600160a01b0387168086529252808420805460ff19169093179092559051339286917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9190a45060016103db565b505f6103db565b5f61069683836104fa565b15610684575f8381526001602090815260408083206001600160a01b0386168085529252808320805460ff1916905551339286917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45060016103db565b6106fe61090a565b6002805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b6107506107e1565b6002805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25861072b3390565b60025f54036107db5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064015b60405180910390fd5b60025f55565b60025460ff16156108275760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b60448201526064016107d2565b565b815f036108495760405163d7ba92d360e01b815260040160405180910390fd5b5f61085382610953565b90505f6108608285610fd4565b9050805f036108825760405163162908e360e11b815260040160405180910390fd5b6104068185856109c3565b815f036108ad5760405163162908e360e11b815260040160405180910390fd5b5f6108b782610953565b90505f6108c48483610ff3565b90506104068482856109c3565b6108db82826104fa565b6104f65760405163e2517d3f60e01b81526001600160a01b0382166004820152602481018390526044016107d2565b60025460ff166108275760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b60448201526064016107d2565b5f811580159061097057505f8281526003602052604090205460ff165b1561099c57507f000000000000000000000000000000000000000000000000000000000000ea60919050565b507f00000000000000000000000000000000000000000000000000000000000186a0919050565b5f6109cd83610c9b565b90505f6109d984610d3d565b90508315610bbb576040516370a0823160e01b81526001600160a01b037f00000000000000000000000097b4e7a5f1e82eb38edbc96d4df83878b8a8043f811660048301525f917f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec7909116906370a0823190602401602060405180830381865afa158015610a69573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610a8d919061100a565b9050610ae47f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec76001600160a01b0316337f00000000000000000000000097b4e7a5f1e82eb38edbc96d4df83878b8a8043f88610e5f565b6040516370a0823160e01b81526001600160a01b037f00000000000000000000000097b4e7a5f1e82eb38edbc96d4df83878b8a8043f81166004830152869183917f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec716906370a0823190602401602060405180830381865afa158015610b6c573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610b90919061100a565b610b9a9190611021565b1015610bb957604051631e9acf1760e31b815260040160405180910390fd5b505b604051630fb7f65560e21b81525f907f00000000000000000000000050e6722656d88cf3750dd9e05cbcaa2c01cd3e9f6001600160a01b031690633edfd95490610c119033908a908a9089908990600401611034565b6020604051808303815f875af1158015610c2d573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610c51919061100a565b60408051888152602081018890529192508291339187917f2c5e43ace7d69fbd6d05b6e7e56d117ddaac254c733761bfebc56a5ec96315e3910160405180910390a4505050505050565b5f7f00000000000000000000000000000000000000000000000000000000000f4240610cc9816103e8610ff3565b831015610cda57506101f492915050565b610ce681612710610ff3565b831015610cf757506103e892915050565b610d0481620186a0610ff3565b831015610d1557506105dc92915050565b610d2281620f4240610ff3565b831015610d3357506109c492915050565b50610fa092915050565b60607f00000000000000000000000000000000000000000000000000000000000f4240610d6c816103e8610ff3565b831015610d9557505060408051808201909152600481526324b937b760e11b6020820152919050565b610da181612710610ff3565b831015610dcc57505060408051808201909152600681526521b7b83832b960d11b6020820152919050565b610dd981620186a0610ff3565b831015610e0457505060408051808201909152600681526529b4b63b32b960d11b6020820152919050565b610e1181620f4240610ff3565b831015610e3a57505060408051808201909152600481526311dbdb1960e21b6020820152919050565b5050604080518082019091526007815266111a585b5bdb9960ca1b6020820152919050565b604080516001600160a01b038581166024830152841660448201526064808201849052825180830390910181526084909101909152602080820180516001600160e01b03166323b872dd60e01b178152825161040693889390925f9283929183919082885af180610ed5576040513d5f823e3d81fd5b50505f513d91508115610eec578060011415610ef9565b6001600160a01b0384163b155b1561040657604051635274afe760e01b81526001600160a01b03851660048201526024016107d2565b5f60208284031215610f32575f5ffd5b81356001600160e01b031981168114610f49575f5ffd5b9392505050565b5f60208284031215610f60575f5ffd5b5035919050565b5f5f60408385031215610f78575f5ffd5b8235915060208301356001600160a01b0381168114610f95575f5ffd5b809150509250929050565b5f5f60408385031215610fb1575f5ffd5b50508035926020909101359150565b634e487b7160e01b5f52601160045260245ffd5b5f82610fee57634e487b7160e01b5f52601260045260245ffd5b500490565b80820281158282048414176103db576103db610fc0565b5f6020828403121561101a575f5ffd5b5051919050565b818103818111156103db576103db610fc0565b60018060a01b038616815284602082015283604082015282606082015260a060808201525f82518060a0840152806020850160c085015e5f60c0828501015260c0601f19601f830116840101915050969550505050505056fea26469706673582212209bc4b4eabe5c9f41954b092d4f93988489ef7c68b1b0b44ecac299db1d7ed50e64736f6c634300081c0033
Verified Source Code Full Match
Compiler: v0.8.28+commit.7893614a
EVM: cancun
Optimization: Yes (200 runs)
ManusDrop.sol 237 lines
// SPDX-License-Identifier: MIT
pragma solidity =0.8.28;
import { Context } from "@openzeppelin/contracts/utils/Context.sol";
import { AccessControl } from "@openzeppelin/contracts/access/AccessControl.sol";
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { IERC20Metadata } from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import { Pausable } from "@openzeppelin/contracts/security/Pausable.sol";
import { ReentrancyGuard } from "@openzeppelin/contracts/security/ReentrancyGuard.sol";
/// @title IMintableNFT
/// @author ProtoKit
/// @notice Minimal interface for minting voucher NFTs.
interface IMintableNFT {
/// @notice Mints an NFT to the recipient with the given metadata.
/// @param to Recipient address.
/// @param amount Amount recorded in the NFT metadata.
/// @param cost Cost recorded in the NFT metadata.
/// @param apr APR recorded in the NFT metadata.
/// @param material Material recorded in the NFT metadata.
/// @return tokenId Newly minted token id.
function mint(
address to,
uint256 amount,
uint256 cost,
uint256 apr,
string memory material
)
external
returns (uint256);
}
/// @title ManusDrop
/// @author ProtoKit
/// @notice Fixed-price voucher NFT sale contract.
contract ManusDrop is Context, ReentrancyGuard, AccessControl, Pausable {
using SafeERC20 for IERC20;
// ---------------- APR Tiers (bps) ----------------
uint256 private constant APR_IRON = 500;
uint256 private constant APR_COPPER = 1000;
uint256 private constant APR_SILVER = 1500;
uint256 private constant APR_GOLD = 2500;
uint256 private constant APR_DIAMOND = 4000;
error InvalidNFT();
error InvalidPayment();
error InvalidTreasury();
error InvalidPrice();
error InvalidDiscountPrice();
error InvalidAmount();
error InvalidCost();
error InvalidCode();
error InsufficientBalance();
error TransferFailed();
/// @notice NFT contract that mints the voucher tokens.
IMintableNFT public immutable NFT;
/// @notice ERC20 token used for payment.
IERC20 public immutable PAYMENT;
/// @notice Treasury that receives payments and residual ETH on destroy.
address public immutable TREASURY;
/// @notice Price per unit of amount, denominated in the payment token.
uint256 public immutable PRICE;
/// @notice Discounted price per unit for whitelisted codes.
uint256 public immutable DISCOUNT_PRICE;
/// @notice Payment token unit (10 ** decimals).
uint256 public immutable PAYMENT_UNIT;
/// @notice Whitelisted invitation codes for discounted purchases.
mapping(bytes32 => bool) public codes;
/// @notice Emitted when a purchase succeeds.
/// @param code Optional invitation code.
/// @param buyer Buyer address.
/// @param tokenId Minted NFT token id.
/// @param amount Amount recorded in the NFT metadata.
/// @param cost Total payment cost.
event Buy(bytes32 indexed code, address indexed buyer, uint256 indexed tokenId, uint256 amount, uint256 cost);
event CodeWhitelisted(bytes32 indexed code);
event CodeRemoved(bytes32 indexed code);
/// @notice Initializes the drop configuration.
/// @param nft_ Address of the NFT contract.
/// @param payment_ Address of the ERC20 payment token.
/// @param treasury_ Address that receives payments and ETH sweeps.
/// @param price_ Unit price per amountOut.
/// @param discountPrice_ Discounted unit price for whitelisted codes.
constructor(address nft_, address payment_, address treasury_, uint256 price_, uint256 discountPrice_) {
if (nft_ == address(0)) revert InvalidNFT();
if (payment_ == address(0)) revert InvalidPayment();
if (treasury_ == address(0)) revert InvalidTreasury();
if (price_ == 0) revert InvalidPrice();
if (discountPrice_ == 0 || discountPrice_ > price_) revert InvalidDiscountPrice();
NFT = IMintableNFT(nft_);
PAYMENT = IERC20(payment_);
TREASURY = treasury_;
PRICE = price_;
DISCOUNT_PRICE = discountPrice_;
PAYMENT_UNIT = 10 ** uint256(IERC20Metadata(payment_).decimals());
_grantRole(DEFAULT_ADMIN_ROLE, _msgSender());
}
/// @notice Adds an invitation code to the discount whitelist.
function addCode(bytes32 code) external onlyRole(DEFAULT_ADMIN_ROLE) {
if (code == bytes32(0)) revert InvalidCode();
codes[code] = true;
emit CodeWhitelisted(code);
}
/// @notice Removes an invitation code from the discount whitelist.
function removeCode(bytes32 code) external onlyRole(DEFAULT_ADMIN_ROLE) {
if (code == bytes32(0)) revert InvalidCode();
codes[code] = false;
emit CodeRemoved(code);
}
/// @notice Pauses purchases.
function pause() external onlyRole(DEFAULT_ADMIN_ROLE) {
_pause();
}
/// @notice Unpauses purchases.
function unpause() external onlyRole(DEFAULT_ADMIN_ROLE) {
_unpause();
}
/// @notice Buys a voucher NFT with the given amount.
/// @param amount Amount of tokens represented by the NFT.
function buy(uint256 amount) external nonReentrant whenNotPaused {
_buy(amount, bytes32(0));
}
/// @notice Buys a voucher NFT with an optional invitation code.
/// @param amount Amount of tokens represented by the NFT.
/// @param code Optional invitation code.
function buy(uint256 amount, bytes32 code) external nonReentrant whenNotPaused {
_buy(amount, code);
}
/// @notice Buys a voucher NFT using a payment amount.
/// @param cost Amount of PAYMENT tokens to spend.
function pay(uint256 cost) external nonReentrant whenNotPaused {
_pay(cost, bytes32(0));
}
/// @notice Buys a voucher NFT using a payment amount with an optional invitation code.
/// @param cost Amount of PAYMENT tokens to spend.
/// @param code Optional invitation code.
function pay(uint256 cost, bytes32 code) external nonReentrant whenNotPaused {
_pay(cost, code);
}
/// @notice Performs the purchase flow.
/// @param amount Amount of tokens represented by the NFT.
/// @param code Optional invitation code.
function _buy(uint256 amount, bytes32 code) internal {
if (amount == 0) revert InvalidAmount();
uint256 p = _priceForCode(code);
uint256 cost = p * amount;
_execute(amount, cost, code);
}
/// @notice Performs the purchase flow using a payment amount.
/// @param cost Amount of PAYMENT tokens to spend.
/// @param code Optional invitation code.
function _pay(uint256 cost, bytes32 code) internal {
if (cost == 0) revert InvalidCost();
uint256 p = _priceForCode(code);
uint256 amount = cost / p;
if (amount == 0) revert InvalidAmount();
_execute(amount, cost, code);
}
function _execute(uint256 amount, uint256 cost, bytes32 code) internal {
uint256 apr = _apr(cost);
string memory material = _material(cost);
if (cost > 0) {
uint256 bal = PAYMENT.balanceOf(TREASURY);
PAYMENT.safeTransferFrom(_msgSender(), TREASURY, cost);
if (PAYMENT.balanceOf(TREASURY) - bal < cost) {
revert InsufficientBalance();
}
}
uint256 id = NFT.mint(_msgSender(), amount, cost, apr, material);
emit Buy(code, _msgSender(), id, amount, cost);
}
function _priceForCode(bytes32 code) internal view returns (uint256) {
if (code != bytes32(0) && codes[code]) {
return DISCOUNT_PRICE;
}
return PRICE;
}
function _apr(uint256 cost) internal view returns (uint256) {
uint256 unit = PAYMENT_UNIT;
if (cost < 1000 * unit) {
return APR_IRON;
}
if (cost < 10_000 * unit) {
return APR_COPPER;
}
if (cost < 100_000 * unit) {
return APR_SILVER;
}
if (cost < 1_000_000 * unit) {
return APR_GOLD;
}
return APR_DIAMOND;
}
function _material(uint256 cost) internal view returns (string memory) {
uint256 unit = PAYMENT_UNIT;
if (cost < 1000 * unit) {
return "Iron";
}
if (cost < 10_000 * unit) {
return "Copper";
}
if (cost < 100_000 * unit) {
return "Silver";
}
if (cost < 1_000_000 * unit) {
return "Gold";
}
return "Diamond";
}
}
ReentrancyGuard.sol 77 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)
pragma solidity ^0.8.0;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor() {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be _NOT_ENTERED
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
return _status == _ENTERED;
}
}
Pausable.sol 105 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which allows children to implement an emergency stop
* mechanism that can be triggered by an authorized account.
*
* This module is used through inheritance. It will make available the
* modifiers `whenNotPaused` and `whenPaused`, which can be applied to
* the functions of your contract. Note that they will not be pausable by
* simply including this module, only once the modifiers are put in place.
*/
abstract contract Pausable is Context {
/**
* @dev Emitted when the pause is triggered by `account`.
*/
event Paused(address account);
/**
* @dev Emitted when the pause is lifted by `account`.
*/
event Unpaused(address account);
bool private _paused;
/**
* @dev Initializes the contract in unpaused state.
*/
constructor() {
_paused = false;
}
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/
modifier whenNotPaused() {
_requireNotPaused();
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*
* Requirements:
*
* - The contract must be paused.
*/
modifier whenPaused() {
_requirePaused();
_;
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view virtual returns (bool) {
return _paused;
}
/**
* @dev Throws if the contract is paused.
*/
function _requireNotPaused() internal view virtual {
require(!paused(), "Pausable: paused");
}
/**
* @dev Throws if the contract is not paused.
*/
function _requirePaused() internal view virtual {
require(paused(), "Pausable: not paused");
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
}
SafeERC20.sol 212 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
import {IERC1363} from "../../../interfaces/IERC1363.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC-20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
/**
* @dev An operation with an ERC-20 token failed.
*/
error SafeERC20FailedOperation(address token);
/**
* @dev Indicates a failed `decreaseAllowance` request.
*/
error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
}
/**
* @dev Variant of {safeTransfer} that returns a bool instead of reverting if the operation is not successful.
*/
function trySafeTransfer(IERC20 token, address to, uint256 value) internal returns (bool) {
return _callOptionalReturnBool(token, abi.encodeCall(token.transfer, (to, value)));
}
/**
* @dev Variant of {safeTransferFrom} that returns a bool instead of reverting if the operation is not successful.
*/
function trySafeTransferFrom(IERC20 token, address from, address to, uint256 value) internal returns (bool) {
return _callOptionalReturnBool(token, abi.encodeCall(token.transferFrom, (from, to, value)));
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
forceApprove(token, spender, oldAllowance + value);
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
* value, non-reverting calls are assumed to be successful.
*
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
unchecked {
uint256 currentAllowance = token.allowance(address(this), spender);
if (currentAllowance < requestedDecrease) {
revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
}
forceApprove(token, spender, currentAllowance - requestedDecrease);
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
* to be set to zero before setting it to a non-zero value, such as USDT.
*
* NOTE: If the token implements ERC-7674, this function will not modify any temporary allowance. This function
* only sets the "standard" allowance. Any temporary allowance will remain active, in addition to the value being
* set here.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Performs an {ERC1363} transferAndCall, with a fallback to the simple {ERC20} transfer if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
safeTransfer(token, to, value);
} else if (!token.transferAndCall(to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} transferFromAndCall, with a fallback to the simple {ERC20} transferFrom if the target
* has no code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferFromAndCallRelaxed(
IERC1363 token,
address from,
address to,
uint256 value,
bytes memory data
) internal {
if (to.code.length == 0) {
safeTransferFrom(token, from, to, value);
} else if (!token.transferFromAndCall(from, to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} approveAndCall, with a fallback to the simple {ERC20} approve if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* NOTE: When the recipient address (`to`) has no code (i.e. is an EOA), this function behaves as {forceApprove}.
* Opposedly, when the recipient address (`to`) has code, this function only attempts to call {ERC1363-approveAndCall}
* once without retrying, and relies on the returned value to be true.
*
* Reverts if the returned value is other than `true`.
*/
function approveAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
forceApprove(token, to, value);
} else if (!token.approveAndCall(to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturnBool} that reverts if call fails to meet the requirements.
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
uint256 returnSize;
uint256 returnValue;
assembly ("memory-safe") {
let success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
// bubble errors
if iszero(success) {
let ptr := mload(0x40)
returndatacopy(ptr, 0, returndatasize())
revert(ptr, returndatasize())
}
returnSize := returndatasize()
returnValue := mload(0)
}
if (returnSize == 0 ? address(token).code.length == 0 : returnValue != 1) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturn} that silently catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
bool success;
uint256 returnSize;
uint256 returnValue;
assembly ("memory-safe") {
success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
returnSize := returndatasize()
returnValue := mload(0)
}
return success && (returnSize == 0 ? address(token).code.length > 0 : returnValue == 1);
}
}
IERC20Metadata.sol 26 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity >=0.6.2;
import {IERC20} from "../IERC20.sol";
/**
* @dev Interface for the optional metadata functions from the ERC-20 standard.
*/
interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}
IERC20.sol 79 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC20/IERC20.sol)
pragma solidity >=0.4.16;
/**
* @dev Interface of the ERC-20 standard as defined in the ERC.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 value) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 value) external returns (bool);
}
AccessControl.sol 207 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (access/AccessControl.sol)
pragma solidity ^0.8.20;
import {IAccessControl} from "./IAccessControl.sol";
import {Context} from "../utils/Context.sol";
import {IERC165, ERC165} from "../utils/introspection/ERC165.sol";
/**
* @dev Contract module that allows children to implement role-based access
* control mechanisms. This is a lightweight version that doesn't allow enumerating role
* members except through off-chain means by accessing the contract event logs. Some
* applications may benefit from on-chain enumerability, for those cases see
* {AccessControlEnumerable}.
*
* Roles are referred to by their `bytes32` identifier. These should be exposed
* in the external API and be unique. The best way to achieve this is by
* using `public constant` hash digests:
*
* ```solidity
* bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
* ```
*
* Roles can be used to represent a set of permissions. To restrict access to a
* function call, use {hasRole}:
*
* ```solidity
* function foo() public {
* require(hasRole(MY_ROLE, msg.sender));
* ...
* }
* ```
*
* Roles can be granted and revoked dynamically via the {grantRole} and
* {revokeRole} functions. Each role has an associated admin role, and only
* accounts that have a role's admin role can call {grantRole} and {revokeRole}.
*
* By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
* that only accounts with this role will be able to grant or revoke other
* roles. More complex role relationships can be created by using
* {_setRoleAdmin}.
*
* WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
* grant and revoke this role. Extra precautions should be taken to secure
* accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}
* to enforce additional security measures for this role.
*/
abstract contract AccessControl is Context, IAccessControl, ERC165 {
struct RoleData {
mapping(address account => bool) hasRole;
bytes32 adminRole;
}
mapping(bytes32 role => RoleData) private _roles;
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/**
* @dev Modifier that checks that an account has a specific role. Reverts
* with an {AccessControlUnauthorizedAccount} error including the required role.
*/
modifier onlyRole(bytes32 role) {
_checkRole(role);
_;
}
/// @inheritdoc IERC165
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) public view virtual returns (bool) {
return _roles[role].hasRole[account];
}
/**
* @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`
* is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.
*/
function _checkRole(bytes32 role) internal view virtual {
_checkRole(role, _msgSender());
}
/**
* @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`
* is missing `role`.
*/
function _checkRole(bytes32 role, address account) internal view virtual {
if (!hasRole(role, account)) {
revert AccessControlUnauthorizedAccount(account, role);
}
}
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {
return _roles[role].adminRole;
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleGranted} event.
*/
function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {
_grantRole(role, account);
}
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleRevoked} event.
*/
function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {
_revokeRole(role, account);
}
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been revoked `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `callerConfirmation`.
*
* May emit a {RoleRevoked} event.
*/
function renounceRole(bytes32 role, address callerConfirmation) public virtual {
if (callerConfirmation != _msgSender()) {
revert AccessControlBadConfirmation();
}
_revokeRole(role, callerConfirmation);
}
/**
* @dev Sets `adminRole` as ``role``'s admin role.
*
* Emits a {RoleAdminChanged} event.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
bytes32 previousAdminRole = getRoleAdmin(role);
_roles[role].adminRole = adminRole;
emit RoleAdminChanged(role, previousAdminRole, adminRole);
}
/**
* @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.
*
* Internal function without access restriction.
*
* May emit a {RoleGranted} event.
*/
function _grantRole(bytes32 role, address account) internal virtual returns (bool) {
if (!hasRole(role, account)) {
_roles[role].hasRole[account] = true;
emit RoleGranted(role, account, _msgSender());
return true;
} else {
return false;
}
}
/**
* @dev Attempts to revoke `role` from `account` and returns a boolean indicating if `role` was revoked.
*
* Internal function without access restriction.
*
* May emit a {RoleRevoked} event.
*/
function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {
if (hasRole(role, account)) {
_roles[role].hasRole[account] = false;
emit RoleRevoked(role, account, _msgSender());
return true;
} else {
return false;
}
}
}
Context.sol 28 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}
IERC1363.sol 86 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC1363.sol)
pragma solidity >=0.6.2;
import {IERC20} from "./IERC20.sol";
import {IERC165} from "./IERC165.sol";
/**
* @title IERC1363
* @dev Interface of the ERC-1363 standard as defined in the https://eips.ethereum.org/EIPS/eip-1363[ERC-1363].
*
* Defines an extension interface for ERC-20 tokens that supports executing code on a recipient contract
* after `transfer` or `transferFrom`, or code on a spender contract after `approve`, in a single transaction.
*/
interface IERC1363 is IERC20, IERC165 {
/*
* Note: the ERC-165 identifier for this interface is 0xb0202a11.
* 0xb0202a11 ===
* bytes4(keccak256('transferAndCall(address,uint256)')) ^
* bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)')) ^
* bytes4(keccak256('approveAndCall(address,uint256)')) ^
* bytes4(keccak256('approveAndCall(address,uint256,bytes)'))
*/
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferAndCall(address to, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @param data Additional data with no specified format, sent in call to `to`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param from The address which you want to send tokens from.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferFromAndCall(address from, address to, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param from The address which you want to send tokens from.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @param data Additional data with no specified format, sent in call to `to`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferFromAndCall(address from, address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function approveAndCall(address spender, uint256 value) external returns (bool);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
* @param data Additional data with no specified format, sent in call to `spender`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool);
}
ERC165.sol 25 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (utils/introspection/ERC165.sol)
pragma solidity ^0.8.20;
import {IERC165} from "./IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC-165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*/
abstract contract ERC165 is IERC165 {
/// @inheritdoc IERC165
function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
IAccessControl.sol 98 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (access/IAccessControl.sol)
pragma solidity >=0.8.4;
/**
* @dev External interface of AccessControl declared to support ERC-165 detection.
*/
interface IAccessControl {
/**
* @dev The `account` is missing a role.
*/
error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);
/**
* @dev The caller of a function is not the expected one.
*
* NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.
*/
error AccessControlBadConfirmation();
/**
* @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
*
* `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
* {RoleAdminChanged} not being emitted to signal this.
*/
event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
/**
* @dev Emitted when `account` is granted `role`.
*
* `sender` is the account that originated the contract call. This account bears the admin role (for the granted role).
* Expected in cases where the role was granted using the internal {AccessControl-_grantRole}.
*/
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Emitted when `account` is revoked `role`.
*
* `sender` is the account that originated the contract call:
* - if using `revokeRole`, it is the admin role bearer
* - if using `renounceRole`, it is the role bearer (i.e. `account`)
*/
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) external view returns (bool);
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {AccessControl-_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) external view returns (bytes32);
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `callerConfirmation`.
*/
function renounceRole(bytes32 role, address callerConfirmation) external;
}
IERC165.sol 25 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (utils/introspection/IERC165.sol)
pragma solidity >=0.4.16;
/**
* @dev Interface of the ERC-165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[ERC].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
IERC165.sol 6 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC165.sol)
pragma solidity >=0.4.16;
import {IERC165} from "../utils/introspection/IERC165.sol";
IERC20.sol 6 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC20.sol)
pragma solidity >=0.4.16;
import {IERC20} from "../token/ERC20/IERC20.sol";
Read Contract
DEFAULT_ADMIN_ROLE 0xa217fddf → bytes32
DISCOUNT_PRICE 0x057707a0 → uint256
NFT 0x7c0b8de2 → address
PAYMENT 0x883b137f → address
PAYMENT_UNIT 0xb3edb5be → uint256
PRICE 0x8d859f3e → uint256
TREASURY 0x2d2c5565 → address
codes 0xad656510 → bool
getRoleAdmin 0x248a9ca3 → bytes32
hasRole 0x91d14854 → bool
paused 0x5c975abb → bool
supportsInterface 0x01ffc9a7 → bool
Write Contract 11 functions
These functions modify contract state and require a wallet transaction to execute.
addCode 0xbd637580
bytes32 code
buy 0xd96a094a
uint256 amount
buy 0xe9fca283
uint256 amount
bytes32 code
grantRole 0x2f2ff15d
bytes32 role
address account
pause 0x8456cb59
No parameters
pay 0x8e6bee97
uint256 cost
bytes32 code
pay 0xc290d691
uint256 cost
removeCode 0x4cd1729c
bytes32 code
renounceRole 0x36568abe
bytes32 role
address callerConfirmation
revokeRole 0xd547741f
bytes32 role
address account
unpause 0x3f4ba83a
No parameters
Recent Transactions
Transaction index is loading. Only unfinalized transactions are shown while the index starts up.