Address Contract Partially Verified
Address
0x388d7bd34dd59F62bC93C5066ff6c468e68eaaA7
Balance
10.0782 ETH ($21439.76)
Nonce
1
Code Size
7409 bytes
Creator
0x04A040BB...1C70 at tx 0x95e79d2d...c29c37
Indexed Transactions
0 (1 on-chain, 0.8% indexed)
Contract Bytecode
7409 bytes
0x6080604052600436106101cd5760003560e01c806370a08231116100f7578063a457c2d711610095578063cd3293de11610064578063cd3293de146104fd578063dd62ed3e14610513578063df7ee13e14610559578063f2fde38b1461057957600080fd5b8063a457c2d714610488578063a9059cbb146104a8578063b4c28f7f146104c8578063b8dcba17146104e857600080fd5b80638da5cb5b116100d15780638da5cb5b146103fc57806395d89b41146104335780639a3824c614610448578063a3f5b5b81461046857600080fd5b806370a0823114610391578063715018a6146103c75780638761aeb8146103dc57600080fd5b8063380889831161016f57806349d1ef6f1161013e57806349d1ef6f1461033c578063587f5ed71461035157806359bf5d39146103675780635df45a371461037c57600080fd5b806338088983146102d257806339509351146102f25780633ccfd60b146103125780634610c7451461032957600080fd5b806318160ddd116101ab57806318160ddd1461025b57806323b872dd14610270578063313ce5671461029057806332cb6b0c146102bc57600080fd5b806306fdde03146101d2578063095ea7b3146101fd5780630f73f4b51461022d575b600080fd5b3480156101de57600080fd5b506101e7610599565b6040516101f49190611a6e565b60405180910390f35b34801561020957600080fd5b5061021d610218366004611a0c565b610627565b60405190151581526020016101f4565b34801561023957600080fd5b5061024d610248366004611a35565b61063e565b6040519081526020016101f4565b34801561026757600080fd5b5060035461024d565b34801561027c57600080fd5b5061021d61028b3660046119d1565b6106c7565b34801561029c57600080fd5b506006546102aa9060ff1681565b60405160ff90911681526020016101f4565b3480156102c857600080fd5b5061024d6103e881565b3480156102de57600080fd5b5061024d6102ed366004611a35565b6107bd565b3480156102fe57600080fd5b5061021d61030d366004611a0c565b6107e6565b34801561031e57600080fd5b5061032761081d565b005b61024d610337366004611a35565b610957565b34801561034857600080fd5b5061024d610bc6565b34801561035d57600080fd5b5061024d60095481565b34801561037357600080fd5b5060085461024d565b34801561038857600080fd5b5060095461024d565b34801561039d57600080fd5b5061024d6103ac366004611985565b6001600160a01b031660009081526001602052604090205490565b3480156103d357600080fd5b50610327610c2a565b3480156103e857600080fd5b5061024d6103f7366004611a35565b610c66565b34801561040857600080fd5b5060065461010090046001600160a01b03165b6040516001600160a01b0390911681526020016101f4565b34801561043f57600080fd5b506101e7610d57565b34801561045457600080fd5b5060075461041b906001600160a01b031681565b34801561047457600080fd5b5061024d610483366004611a35565b610d64565b34801561049457600080fd5b5061021d6104a3366004611a0c565b610df8565b3480156104b457600080fd5b5061021d6104c3366004611a0c565b610eaf565b3480156104d457600080fd5b5061024d6104e3366004611a4d565b610ebc565b3480156104f457600080fd5b5061024d611132565b34801561050957600080fd5b5061024d60085481565b34801561051f57600080fd5b5061024d61052e36600461199f565b6001600160a01b03918216600090815260026020908152604080832093909416825291909152205490565b34801561056557600080fd5b50610327610574366004611985565b61116a565b34801561058557600080fd5b50610327610594366004611985565b611203565b600480546105a690611c4f565b80601f01602080910402602001604051908101604052809291908181526020018280546105d290611c4f565b801561061f5780601f106105f45761010080835404028352916020019161061f565b820191906000526020600020905b81548152906001019060200180831161060257829003601f168201915b505050505081565b60006106343384846112a4565b5060015b92915050565b600061064960035490565b61065557506000919050565b60035482111561066757506000919050565b6000805b838110156106a85761068a8161068060035490565b6103f79190611c38565b6106949083611af6565b9150806106a081611c8a565b91505061066b565b5060646106b682605a611c19565b6106c09190611b0e565b9392505050565b60006106d48484846113c9565b6007546001600160a01b0316336001600160a01b0316146107b3576001600160a01b03841660009081526002602090815260408083203384529091529020548211156107785760405162461bcd60e51b815260206004820152602860248201527f45524332303a207472616e7366657220616d6f756e74206578636565647320616044820152676c6c6f77616e636560c01b60648201526084015b60405180910390fd5b6001600160a01b0384166000908152600260209081526040808320338085529252909120546107b39186916107ae908690611c38565b6112a4565b5060019392505050565b6000816107cc57506000919050565b60006107d783610c66565b905060646106b682605a611c19565b3360008181526002602090815260408083206001600160a01b038716845290915281205490916106349185906107ae908690611af6565b6006546001600160a01b0361010090910416331461084d5760405162461bcd60e51b815260040161076f90611ac1565b6007546000906001600160a01b0316156108b0576007546001600160a01b03166000908152600160205260408120549050600061088b600a546115ae565b90506000610898836115ae565b90506108a48282611c38565b600a9390935550909150505b6000816009546108c09190611af6565b6000600981905560405191925090339083908381818185875af1925050503d806000811461090a576040519150601f19603f3d011682016040523d82523d6000602084013e61090f565b606091505b50509050806109525760405162461bcd60e51b815260206004820152600f60248201526e15da5d1a191c985dc819985a5b1959608a1b604482015260640161076f565b505050565b60008082116109a85760405162461bcd60e51b815260206004820152601b60248201527f43616e2774206d696e74203020476f6c64656e205469636b6574730000000000604482015260640161076f565b6103e8826003546109b99190611af6565b1115610a255760405162461bcd60e51b815260206004820152603560248201527f54686174207175616e74697479206f66207469636b6574732074616b657320736044820152747570706c79206f766572206d617820737570706c7960581b606482015260840161076f565b6003546000805b84811015610a6a57610a4c610a42826001611af6565b6103f79085611af6565b610a569083611af6565b915080610a6281611c8a565b915050610a2c565b5080341015610ab05760405162461bcd60e51b8152602060048201526012602482015271496e73756666696369656e742066756e647360701b604482015260640161076f565b600084600354610ac09190611af6565b90506000805b86811015610af957610adb6102ed8285611c38565b610ae59083611af6565b915080610af181611c8a565b915050610ac6565b5080600854610b089190611af6565b6008556009548190610b1b908590611af6565b610b259190611c38565b600955610b323387611632565b610b3c833461171a565b337f6a8a13dd35d69038c7f519838d0a655a208337ebd88d0250dbf0eada6901659a8785610b6e6103f7876001611af6565b610b77876107bd565b87610b82888b611c38565b600854604080519788526020880196909652948601939093526060850191909152608084015260a083015260c082015260e00160405180910390a250949350505050565b60075460009081906001600160a01b031615610c25576007546001600160a01b031660009081526001602052604081205490506000610c06600a546115ae565b90506000610c13836115ae565b9050610c1f8282611c38565b93505050505b919050565b6006546001600160a01b03610100909104163314610c5a5760405162461bcd60e51b815260040161076f90611ac1565b610c6460006117bf565b565b60006103e8821115610cba5760405162461bcd60e51b815260206004820152601760248201527f4d6178696d756d20737570706c79206578636565646564000000000000000000604482015260640161076f565b60008211610d1c5760405162461bcd60e51b815260206004820152602960248201527f4d696e74696e67206120737570706c79206f662030207469636b6574732069736044820152681b89dd081d985b1a5960ba1b606482015260840161076f565b6000610d2a6004600a611b71565b9050610d368380611c19565b610d42906103e8611af6565b9150806106b683670de0b6b3a7640000611c19565b600580546105a690611c4f565b600080610d736004600a611b71565b60009250905081805b84811015610dd257610d8f816001611af6565b600354610d9c9190611af6565b9150610da88280611c19565b610db4906103e8611af6565b610dbe9085611af6565b935080610dca81611c8a565b915050610d7c565b5081610de684670de0b6b3a7640000611c19565b610df09190611b0e565b949350505050565b3360009081526002602090815260408083206001600160a01b0386168452909152812054821115610e795760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b606482015260840161076f565b3360008181526002602090815260408083206001600160a01b0388168452909152902054610634919085906107ae908690611c38565b60006106343384846113c9565b60035460009083811015610f075760405162461bcd60e51b8152602060048201526012602482015271135a5b881cdd5c1c1b1e481b9bdd081b595d60721b604482015260640161076f565b60008311610f575760405162461bcd60e51b815260206004820152601b60248201527f43616e2774206275726e203020476f6c64656e205469636b6574730000000000604482015260640161076f565b600354831115610fbb5760405162461bcd60e51b815260206004820152602960248201527f43616e2774206275726e206d6f7265207469636b657473207468616e20746f74604482015268616c20737570706c7960b81b606482015260840161076f565b6000805b84811015610ff257610fd46102ed8285611c38565b610fde9083611af6565b915080610fea81611c8a565b915050610fbf565b506000846003546110039190611c38565b9050816008546110139190611c38565b600855611020338661180f565b604051600090339084908381818185875af1925050503d8060008114611062576040519150601f19603f3d011682016040523d82523d6000602084013e611067565b606091505b50509050806110ae5760405162461bcd60e51b8152602060048201526013602482015272109d5c9b881c185e5b595b9d0819985a5b1959606a1b604482015260640161076f565b337f95af16053313cf7bcf1721b9a60024a79cde8e4a43b62898719ffcdc58935d3687856110ea6110df838a611c38565b6103f7906001611af6565b6110f3876107bd565b6008546040805195865260208601949094529284019190915260608301526080820186905260a082015260c00160405180910390a25095945050505050565b6007546000906001600160a01b031661114b5750600090565b506007546001600160a01b031660009081526001602052604090205490565b6006546001600160a01b0361010090910416331461119a5760405162461bcd60e51b815260040161076f90611ac1565b6007546001600160a01b0316156111e15760405162461bcd60e51b815260206004820152600b60248201526a105b1c9958591e481cd95d60aa1b604482015260640161076f565b600780546001600160a01b0319166001600160a01b0392909216919091179055565b6006546001600160a01b036101009091041633146112335760405162461bcd60e51b815260040161076f90611ac1565b6001600160a01b0381166112985760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161076f565b6112a1816117bf565b50565b6001600160a01b0383166113065760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b606482015260840161076f565b6001600160a01b0382166113675760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b606482015260840161076f565b6001600160a01b0383811660008181526002602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b6001600160a01b03831661142d5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b606482015260840161076f565b6001600160a01b03821661148f5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b606482015260840161076f565b6001600160a01b0383166000908152600160205260409020548111156115065760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b606482015260840161076f565b6001600160a01b03831660009081526001602052604090205461152a908290611c38565b6001600160a01b03808516600090815260016020526040808220939093559084168152205461155a908290611af6565b6001600160a01b0380841660008181526001602052604090819020939093559151908516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906113bc9085815260200190565b600060066115bd836002611c19565b6115c8906001611af6565b6115d3846001611af6565b6115dd9085611c19565b6115e79190611c19565b6115f2906009611c19565b6115fc9190611b0e565b61160c906509184e72a000611c19565b611617836009611c19565b61162890662386f26fc10000611c19565b6106389190611af6565b6001600160a01b0382166116885760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015260640161076f565b806003546116969190611af6565b6003556001600160a01b0382166000908152600160205260409020546116bd908290611af6565b6001600160a01b0383166000818152600160205260408082209390935591519091907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9061170e9085815260200190565b60405180910390a35050565b60006117268383611c38565b11156117bb576000336117398484611c38565b604051600081818185875af1925050503d8060008114611775576040519150601f19603f3d011682016040523d82523d6000602084013e61177a565b606091505b50509050806109525760405162461bcd60e51b815260206004820152600d60248201526c1499599d5b990819985a5b1959609a1b604482015260640161076f565b5050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6001600160a01b03821661186f5760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b606482015260840161076f565b6001600160a01b0382166000908152600160205260409020548111156118e25760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b606482015260840161076f565b6001600160a01b038216600090815260016020526040902054611906908290611c38565b6001600160a01b03831660009081526001602052604090205560035461192d908290611c38565b6003556040518181526000906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200161170e565b80356001600160a01b0381168114610c2557600080fd5b600060208284031215611996578081fd5b6106c08261196e565b600080604083850312156119b1578081fd5b6119ba8361196e565b91506119c86020840161196e565b90509250929050565b6000806000606084860312156119e5578081fd5b6119ee8461196e565b92506119fc6020850161196e565b9150604084013590509250925092565b60008060408385031215611a1e578182fd5b611a278361196e565b946020939093013593505050565b600060208284031215611a46578081fd5b5035919050565b60008060408385031215611a5f578182fd5b50508035926020909101359150565b6000602080835283518082850152825b81811015611a9a57858101830151858201604001528201611a7e565b81811115611aab5783604083870101525b50601f01601f1916929092016040019392505050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60008219821115611b0957611b09611ca5565b500190565b600082611b2957634e487b7160e01b81526012600452602481fd5b500490565b600181815b80851115611b69578160001904821115611b4f57611b4f611ca5565b80851615611b5c57918102915b93841c9390800290611b33565b509250929050565b60006106c08383600082611b8757506001610638565b81611b9457506000610638565b8160018114611baa5760028114611bb457611bd0565b6001915050610638565b60ff841115611bc557611bc5611ca5565b50506001821b610638565b5060208310610133831016604e8410600b8410161715611bf3575081810a610638565b611bfd8383611b2e565b8060001904821115611c1157611c11611ca5565b029392505050565b6000816000190483118215151615611c3357611c33611ca5565b500290565b600082821015611c4a57611c4a611ca5565b500390565b600181811c90821680611c6357607f821691505b60208210811415611c8457634e487b7160e01b600052602260045260246000fd5b50919050565b6000600019821415611c9e57611c9e611ca5565b5060010190565b634e487b7160e01b600052601160045260246000fdfea26469706673582212205628e0797f42ba200c054e93d8c206381bfb15dfd2d3591c518854139fd2351364736f6c63430008040033
Verified Source Code Partial Match
Compiler: v0.8.4+commit.c7e474f2
EVM: istanbul
Optimization: Yes (200 runs)
IERC20.sol 76 lines
pragma solidity >=0.8.0 <0.9.0;
//SPDX-License-Identifier: MIT
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) 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 `amount` 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 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @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);
}
Context.sol 23 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/*
* @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;
}
}
Ownable.sol 71 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_setOwner(_msgSender());
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_setOwner(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
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);
}
}
GoldenTicket.sol 550 lines
pragma solidity >=0.8.0 <0.9.0;
//SPDX-License-Identifier: MIT
import "./IERC20.sol";
import "./Context.sol";
import "./Ownable.sol";
/**
*
* GoldenTicket Contract - NFTR's special name token
* You need to spend (send to Registry Contract) one Golden Ticket
* in addition to 365RNM to choose a name from the special names list
* @dev Extends standard ERC20 contract
*/
contract GoldenTicket is Context, IERC20, Ownable {
// Constants
uint256 public constant MAX_SUPPLY = 1000;
// For bonding curve
uint256 constant a_times_sig = 1000;
uint256 constant SIG_DIGITS = 4;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string public name;
string public symbol;
uint8 public decimals;
address private _owner;
// NFTR Registry Contract address
address public nftrAddress;
// Funds reserved for burns
uint256 public reserve = 0;
// Accumulated mint fees (10% of every mint) that haven't been withdrawed
uint256 public accumulatedFees = 0;
// Number of tickets that have been used (sent, therefore locked in NFTR Contract) and whose "unclaimable reserves" / orphan funds have already been withdrawn
uint256 private numberTicketsFundsClaimedFor = 0;
// Events
/**
* @dev Emitted when a ticket is minted
*/
event GoldenTicketsMinted(
address indexed to,
uint256 numTickets,
uint256 pricePaid,
uint256 nextMintPrice,
uint256 nextBurnPrice,
uint256 ticketSupply,
uint256 mintFee,
uint256 newReserve
);
/**
* @dev Emitted when a ticket is burned
*/
event GoldenTicketsBurned(
address indexed to,
uint256 numTickets,
uint256 burnProceeds,
uint256 nextMintPrice,
uint256 nextBurnPrice,
uint256 ticketSupply,
uint256 newReserve
);
// Methods
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a value of 0 -- only whole tickets allowed. Sets the contract owner.
*
*
* All values except owner are immutable: they can only be set once during
* construction.
*/
constructor (address ownerin, string memory namein, string memory symbolin) {
name = namein;
symbol = symbolin;
_setupDecimals(0);
_owner = ownerin;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view override returns (address) {
return _owner;
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
decimals = decimals_;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address ownerin, address spender) public view virtual override returns (uint256) {
return _allowances[ownerin][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* Requirements:
*
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
// Approval check is skipped if the caller of transferFrom is the NFTRegistry contract. For better UX.
if (_msgSender() != nftrAddress) {
require(_allowances[sender][_msgSender()] >= amount,"ERC20: transfer amount exceeds allowance");
_approve(sender, _msgSender(), _allowances[sender][_msgSender()] - amount);
}
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
require(_allowances[_msgSender()][spender] >= subtractedValue, "ERC20: decreased allowance below zero");
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] - subtractedValue);
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
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);
require(_balances[sender] >= amount, "ERC20: transfer amount exceeds balance");
_balances[sender] = _balances[sender] - amount;
_balances[recipient] = _balances[recipient] + amount;
emit Transfer(sender, recipient, amount);
}
/**
* @dev Callable only once. It is manually set right after deployment and verified.
*/
function setNFTRegistryAddress(address _nftrAddress) public onlyOwner {
require(nftrAddress == address(0), "Already set");
nftrAddress = _nftrAddress;
}
/**
* @dev Get amount of ETH in reserve
*/
function getReserve() public view returns (uint256) {
return reserve;
}
/**
* @dev Get accumulated fees
*/
function getAccumulatedFees() public view returns (uint256) {
return accumulatedFees;
}
/**
* @dev Get number of used tickets (i.e. tickets in NFTR contract balance)
*/
function numberUsedTickets() public view returns (uint256 nftrTicketBalance) {
if(nftrAddress == address(0)) {
nftrTicketBalance = 0;
}
else {
nftrTicketBalance = balanceOf(nftrAddress);
}
}
/**
* @dev Get accumulated orphan ticket extractable funds
*/
function getOrphanedTicketFunds() public view returns (uint256) {
uint256 unclaimedOrphanFunds = 0;
if (nftrAddress != address(0)) { // NFTR contract has already been set and could have GTKs in its balance
uint256 nftrTicketBalance = balanceOf(nftrAddress);
uint256 orphanFundsWithdrawn = getOrphanFundsForUsedTicketNumber(numberTicketsFundsClaimedFor);
uint256 totalOrphanFunds = getOrphanFundsForUsedTicketNumber(nftrTicketBalance);
unclaimedOrphanFunds = totalOrphanFunds - orphanFundsWithdrawn;
}
return unclaimedOrphanFunds;
}
/**
* @dev Returns mint price of the mintNumber golden ticket in wei
*
*/
function getSingleMintPrice(uint256 mintNumber) public pure returns (uint256 price) {
require(mintNumber <= MAX_SUPPLY, "Maximum supply exceeded");
require(mintNumber > 0, "Minting a supply of 0 tickets isn't valid");
uint256 dec = 10 ** SIG_DIGITS;
price = a_times_sig + (mintNumber * (mintNumber));
price = price * (1 ether) / (dec);
}
/**
* @dev Returns mint price of the next golden ticket in wei
*/
function currentMintPrice(uint256 quantity) public view returns (uint256 price) {
uint256 dec = 10 ** SIG_DIGITS;
price = 0;
uint256 mintNumber;
for (uint i = 0; i < quantity; i++) {
mintNumber = totalSupply() + (i + 1);
price += a_times_sig + (mintNumber * (mintNumber));
}
price = price * (1 ether) / (dec);
}
/**
* @dev Function to get funds received when burned
* @param supply the golden ticket supply before buring. Ex. if there are 3 existing tickets, to get the funds
* received on burn, supply should be 3
*/
function getSingleBurnPrice(uint256 supply) public pure returns (uint256 price) {
if (supply == 0) return 0;
uint256 mintPrice = getSingleMintPrice(supply);
price = mintPrice * (90) / (100); // 90 % of mint price of last minted ticket (i.e. current supply)
}
/**
* @dev Function to get amount of funds received currently when ticket is burned
*/
function currentBurnPrice(uint256 quantity) public view returns (uint256 price) {
if (totalSupply() == 0) return 0;
if (quantity > totalSupply()) return 0;
uint256 mintPrice;
for (uint i = 0; i < quantity; i++) {
mintPrice += getSingleMintPrice(totalSupply() - i);
}
price = mintPrice * (90) / (100); // 90 % of mint price of last minted ticket (i.e. current supply)
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply + (amount);
_balances[account] = _balances[account] + (amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
require(_balances[account] >= amount, "ERC20: burn amount exceeds balance");
_balances[account] = _balances[account] - amount;
_totalSupply = _totalSupply - (amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address ownerin, address spender, uint256 amount) internal virtual {
require(ownerin != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[ownerin][spender] = amount;
emit Approval(ownerin, spender, amount);
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
/**
* @dev Hook that is called after any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* has been transferred to `to`.
* - when `from` is zero, `amount` tokens have been minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens have been burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _afterTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
/**
* @dev Mints *quantity* Golden Tickets to the address of the sender
* @param quantity The number of Golden Tickets to mint
*/
function mintTickets(uint256 quantity)
public
payable
returns (uint256)
{
require(quantity > 0, "Can't mint 0 Golden Tickets");
require(_totalSupply + quantity <= MAX_SUPPLY, "That quantity of tickets takes supply over max supply");
uint256 oldSupply = _totalSupply;
// Get price to mint *quantity* tickets
uint256 mintPrice = 0;
for (uint i = 0; i < quantity; i++) {
mintPrice += getSingleMintPrice(oldSupply + (i + 1));
}
require(msg.value >= mintPrice, "Insufficient funds");
uint256 newSupply = _totalSupply + (quantity);
// Update reserve - reserveCut == Price to burn next ticket
uint256 reserveCut = 0;
for (uint i = 0; i < quantity; i++) {
reserveCut += getSingleBurnPrice(newSupply - i);
}
reserve = reserve + (reserveCut);
accumulatedFees = accumulatedFees + (mintPrice) - (reserveCut);
// Mint token
_mint(msg.sender, quantity);
// If buyer sent extra ETH as padding in case another purchase was made they are refunded
_refundSender(mintPrice, msg.value);
emit GoldenTicketsMinted(msg.sender, quantity, mintPrice, getSingleMintPrice(newSupply + (1)), getSingleBurnPrice(newSupply), newSupply, mintPrice - (reserveCut), reserve);
return newSupply;
}
/**
* @dev If sender sends more Ether than necessary when minting, refunds the extra funds
*
*/
function _refundSender(uint256 mintPrice, uint256 msgValue) internal {
if (msgValue - (mintPrice) > 0) {
(bool success, ) =
msg.sender.call{value: msgValue - (mintPrice)}("");
require(success, "Refund failed");
}
}
/**
* @dev Function to burn a ticket
* @param minimumSupply The minimum token supply for burn to succeed, this is a way to set slippage.
* Set to 1 to allow burn to go through no matter what the price is.
* @param quantity The number of Golden Tickets to burn
*/
function burnTickets(uint256 minimumSupply, uint256 quantity) public returns (uint256) {
uint256 oldSupply = _totalSupply;
require(oldSupply >= minimumSupply, 'Min supply not met');
require(quantity > 0, "Can't burn 0 Golden Tickets");
require(quantity <= _totalSupply, "Can't burn more tickets than total supply");
uint256 burnPrice = 0;
for (uint i = 0; i < quantity; i++) {
burnPrice += getSingleBurnPrice(oldSupply - i);
}
uint256 newSupply = _totalSupply - (quantity);
// Update reserve
reserve = reserve - (burnPrice);
_burn(msg.sender, quantity);
// Disburse funds
(bool success, ) = msg.sender.call{value: burnPrice}("");
require(success, "Burn payment failed");
emit GoldenTicketsBurned(msg.sender, quantity, burnPrice, getSingleMintPrice(oldSupply - quantity + 1), getSingleBurnPrice(newSupply), newSupply, reserve);
return newSupply;
}
/**
* @dev Function that calculates previously reserved exit (burn) liquidity
* that will be claimed by burning since they have already been used to
* name (i.e. they have been transferred to the NFTR Contract)
*/
function getOrphanFundsForUsedTicketNumber(uint256 ticketNumber) internal pure returns (uint256 _orphanFunds) {
// Summing ticket mint prices from k = 1 to n, then multiplying by 9/10 (90%). Reduces to:
_orphanFunds = 9 * ticketNumber * 10 ** 16 + ticketNumber * (ticketNumber + 1) * (2 * ticketNumber + 1) * 9 / 6 * 10 ** 13;
}
/**
* @dev Withdraw treasury ETH
*/
function withdraw() public onlyOwner {
uint256 unclaimedOrphanFunds = 0;
if (nftrAddress != address(0)) { // NFTR contract has already been set and could have GTs in its balance
uint256 nftrTicketBalance = balanceOf(nftrAddress);
uint256 orphanFundsWithdrawn = getOrphanFundsForUsedTicketNumber(numberTicketsFundsClaimedFor);
uint256 totalOrphanFunds = getOrphanFundsForUsedTicketNumber(nftrTicketBalance);
unclaimedOrphanFunds = totalOrphanFunds - orphanFundsWithdrawn;
numberTicketsFundsClaimedFor = nftrTicketBalance;
}
uint256 withdrawableFunds = accumulatedFees + (unclaimedOrphanFunds);
accumulatedFees = 0;
(bool success, ) = msg.sender.call{value: withdrawableFunds}("");
require(success, "Withdraw failed");
}
}
Read Contract
MAX_SUPPLY 0x32cb6b0c → uint256
accumulatedFees 0x587f5ed7 → uint256
allowance 0xdd62ed3e → uint256
balanceOf 0x70a08231 → uint256
currentBurnPrice 0x0f73f4b5 → uint256
currentMintPrice 0xa3f5b5b8 → uint256
decimals 0x313ce567 → uint8
getAccumulatedFees 0x5df45a37 → uint256
getOrphanedTicketFunds 0x49d1ef6f → uint256
getReserve 0x59bf5d39 → uint256
getSingleBurnPrice 0x38088983 → uint256
getSingleMintPrice 0x8761aeb8 → uint256
name 0x06fdde03 → string
nftrAddress 0x9a3824c6 → address
numberUsedTickets 0xb8dcba17 → uint256
owner 0x8da5cb5b → address
reserve 0xcd3293de → uint256
symbol 0x95d89b41 → string
totalSupply 0x18160ddd → uint256
Write Contract 11 functions
These functions modify contract state and require a wallet transaction to execute.
approve 0x095ea7b3
address spender
uint256 amount
returns: bool
burnTickets 0xb4c28f7f
uint256 minimumSupply
uint256 quantity
returns: uint256
decreaseAllowance 0xa457c2d7
address spender
uint256 subtractedValue
returns: bool
increaseAllowance 0x39509351
address spender
uint256 addedValue
returns: bool
mintTickets 0x4610c745
uint256 quantity
returns: uint256
renounceOwnership 0x715018a6
No parameters
setNFTRegistryAddress 0xdf7ee13e
address _nftrAddress
transfer 0xa9059cbb
address recipient
uint256 amount
returns: bool
transferFrom 0x23b872dd
address sender
address recipient
uint256 amount
returns: bool
transferOwnership 0xf2fde38b
address newOwner
withdraw 0x3ccfd60b
No parameters
Recent Transactions
This address has 1 on-chain transactions, but only 0.8% of the chain is indexed. Transactions will appear as indexing progresses. View on Etherscan →