Forkchoice Ethereum Mainnet

Address Contract Verified

Address 0xa7DD3e9b0D65b559bDEEfFeb84fd453511538B64
Balance 0 ETH
Nonce 1
Code Size 8804 bytes
Indexed Transactions 0 (1 on-chain, 1.1% indexed)
External Etherscan · Sourcify

Contract Bytecode

8804 bytes
0x60406080815260049081361015610014575f80fd5b5f91823560e01c908162fdd58e146115e857816301ffc9a71461157a57816306ee82c51461155e5781630e89341c1461143a578163162094c41461127f5781632b9f025414610f1d5781632eb2c2d614610ba757816333f7617814610b885781634e1273f4146109e65781635d313295146109bd57838263715018a61461095c575081638da5cb5b146109345781638e15f47314610917578163999485ad146108fc578163a22cb4651461081a578163a4206115146107fe578163a6413a27146107d1578163a696cc9d146107b2578163bb4644f71461078a578163c49cc64514610761578163dfeae56c14610557578163e985e9c514610509578163f242432a14610250578163f2fde38b1461018857508063f431c0dc1461016a5763f597573f1461013f575f80fd5b3461016657816003193601126101665760075490516001600160a01b039091168152602090f35b5080fd5b5034610166578160031936011261016657602090600a549051908152f35b90503461024c57602036600319011261024c576101a3611611565b81546001600160a01b0380821693926101bd338614611834565b169384156101fb57506001600160a01b031916831790557f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08380a380f35b5162461bcd60e51b8152602081840152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608490fd5b8280fd5b90503461024c5760a036600319011261024c5761026b611611565b9161027461162b565b92604435906064359060843567ffffffffffffffff81116105055761029c90369087016117e3565b926001600160a01b039182169133831480156104e7575b15610492578716916102c683151561194b565b6102cf82611b58565b506102d984611b58565b5081895260209760018952868a20828b52895284878b20546102fd828210156119a5565b848c5260018b52888c20848d528b5203878b2055828a5260018952868a20848b528952868a2061032e868254611a04565b905583828851858152878c8201527fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f628a3392a43b61036a578880f35b918697989596949391868a946103b38a519788968795869463f23a6e6160e01b9c8d8752339087015260248601526044850152606484015260a0608484015260a4830190611641565b03925af1839181610463575b50610428575050506103cf611a7a565b6308c379a0146103f7575b5162461bcd60e51b8152915081906103f3908201611b03565b0390fd5b6103ff611a95565b8061040a57506103da565b6103f3915193849362461bcd60e51b85528401526024830190611641565b9194506001600160e01b03199091160361044a5750505f808080808080808880f35b5162461bcd60e51b8152915081906103f3908201611a31565b610484919250873d891161048b575b61047c81836116cb565b810190611a11565b905f6103bf565b503d610472565b855162461bcd60e51b8152602081890152602960248201527f455243313135353a2063616c6c6572206973206e6f74206f776e6572206e6f7260448201526808185c1c1c9bdd995960ba1b6064820152608490fd5b508289526002602052858920338a5260205260ff868a2054166102b3565b8780fd5b50503461016657806003193601126101665760ff81602093610529611611565b61053161162b565b6001600160a01b0391821683526002875283832091168252855220549151911615158152f35b8391506105633661173f565b600286949394541461071e576105949060028755606461058d6105868787612182565b9283611b93565b0490611a04565b6001600160a01b03918216949085151590816106ef575b6005546105b791611b93565b6105bf6120dc565b9081156106dc57048034106106aa5790816105dd6106099334611ba6565b976105ea87600a54611a04565b600a556105f988600b54611a04565b600b55899261068c575b50611ba6565b91600c541690811561065057602088600189896106318a8a61062b8b8b61202e565b33611be2565b80610640575b50555160018152f35b61064a903361202e565b84610637565b606490602089519162461bcd60e51b83528201526016602482015275149958d95a5d99481dd85b1b195d081b9bdd081cd95d60521b6044820152fd5b91506106a4606461069c83611b7d565b04809361202e565b8a610603565b885162461bcd60e51b8152602081850152600c60248201526b13195cdcc81c185e5b595b9d60a21b6044820152606490fd5b634e487b7160e01b895260128452602489fd5b605a810290808204605a149015171561070b57606490046105ab565b634e487b7160e01b885260118352602488fd5b865162461bcd60e51b8152602081870152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606490fd5b50503461016657816003193601126101665760065490516001600160a01b039091168152602090f35b90503461024c57602036600319011261024c5760209282913581526009845220549051908152f35b505034610166578160031936011261016657602090600b549051908152f35b8284346107fb57816003193601126107fb57506107f46020926024359035612182565b9051908152f35b80fd5b5050346101665781600319360112610166576020905160018152f35b9190503461024c578060031936011261024c57610835611611565b90602435918215158093036108f8576001600160a01b0316923384146108a45750338452600260205280842083855260205280842060ff1981541660ff8416179055519081527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3160203392a380f35b6020608492519162461bcd60e51b8352820152602960248201527f455243313135353a2073657474696e6720617070726f76616c20737461747573604482015268103337b91039b2b63360b91b6064820152fd5b8480fd5b50503461016657816003193601126101665751908152602090f35b5050346101665781600319360112610166576020906107f46120dc565b90503461024c578260031936011261024c575490516001600160a01b03909116815260209150f35b8091346109ba57816003193601126109ba5780546001600160a01b0381169190610987338414611834565b6001600160a01b03191690557f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a380f35b50fd5b505034610166578160031936011261016657600c5490516001600160a01b039091168152602090f35b90503461024c578160031936011261024c57803567ffffffffffffffff8082116108f857366023830112156108f8578183013590610a238261176d565b92610a30865194856116cb565b82845260209260248486019160051b83010191368311610b8457602401905b828210610b6157505050602435908111610b5d57610a709036908501611785565b928251845103610b0a5750815194610a878661176d565b95610a94865197886116cb565b808752610aa3601f199161176d565b0136838801375b8251811015610af457610aef90610adf6001600160a01b03610acc8387611923565b5116610ad88388611923565b519061187f565b610ae98289611923565b52611901565b610aaa565b845182815280610b0681850189611801565b0390f35b60849185519162461bcd60e51b8352820152602960248201527f455243313135353a206163636f756e747320616e6420696473206c656e677468604482015268040dad2e6dac2e8c6d60bb1b6064820152fd5b8580fd5b81356001600160a01b0381168103610b80578152908401908401610a4f565b8980fd5b8880fd5b5050346101665781600319360112610166576020906005549051908152f35b905082346107fb576003199260a03685011261016657610bc5611611565b91610bce61162b565b9467ffffffffffffffff93604435858111610f1957610bf09036908801611785565b6064358681116108f857610c079036908901611785565b956084359081116108f857610c1f90369089016117e3565b966001600160a01b03928316923384148015610efb575b15610e9d578251885103610e4957891693610c5285151561194b565b855b8351811015610cd75780610c6b610cd29286611923565b51610c76828c611923565b5190808a5260016020918183528c8c208a8d528352838d8d8c8282205492610ca0858510156119a5565b858352868852822091528552038d8d20558b5281528a8a2090898b5252610ccb8a8a20918254611a04565b9055611901565b610c54565b50949897909692959784878a518b81527f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb610d148d830188611801565b91808303602082015280610d2933948b611801565b0390a43b610d35578880f35b8798969751948593849363bc197c8160e01b98898652338c87015260248601526044850160a0905260a48501610d6a91611801565b82858203016064860152610d7d91611801565b90838203016084840152610d9091611641565b0381865a94602095f1839181610e29575b50610e0957505050610db1611a7a565b6308c379a014610dd5575b905162461bcd60e51b81529081906103f3908201611b03565b610ddd611a95565b80610de85750610dbc565b6103f3906020935193849362461bcd60e51b85528401526024830190611641565b9193916001600160e01b0319160361044a57505081808080808080808880f35b610e4291925060203d811161048b5761047c81836116cb565b9086610da1565b865162461bcd60e51b8152602081840152602860248201527f455243313135353a2069647320616e6420616d6f756e7473206c656e677468206044820152670dad2e6dac2e8c6d60c31b6064820152608490fd5b865162461bcd60e51b8152602081840152603260248201527f455243313135353a207472616e736665722063616c6c6572206973206e6f74206044820152711bdddb995c881b9bdc88185c1c1c9bdd995960721b6064820152608490fd5b50838652600260205286862033875260205260ff8787205416610c36565b8380fd5b90503461024c57610f4f61058d91610f343661173f565b610f4383859793949895612182565b90606494859183611b93565b6001600160a01b038281161515989189611251575b64e8d4a51000900498610f7987600a54611a04565b600a55610f8888600b54611a04565b600b5581600754169989519a636eb1769f60e11b8c5233888d01526024958c873091015260209c8d81604481865afa908115611247578791611216575b5083116111c857859385600c54161561118c5791878d94928f8b8a9998966110c7575b50505050508491610ff891611ba6565b61104f8d611041866007541696600c541695519384928301966323b872dd60e01b8852338c850160409194939294606082019560018060a01b0380921683521660208201520152565b03601f1981018352826116cb565b51925af161105b611bb3565b5015611076575050509061106f9133611be2565b5160018152f35b855162461bcd60e51b81529283018790526027908301527f546f6b656e207061796d656e7420666f72207061796d656e742077616c6c65746044830152660819985a5b195960ca1b90820152608490fd5b8996508695979899929161104161111f926110e18b611b7d565b9b516323b872dd60e01b938101938452339781019788526001600160a01b039095166020880152909a04604086018190529990948391606090910190565b51925af161112b611bb3565b5015611140578392918a915f87818f8b610fe8565b50885162461bcd60e51b81528087018b90526021818601527f546f6b656e207061796d656e7420666f7220726566657272616c206661696c656044820152601960fa1b81870152608490fd5b50508a5162461bcd60e51b81528089018d90526016818801527514185e5b595b9d081dd85b1b195d081b9bdd081cd95d60521b60448201528790fd5b5050895162461bcd60e51b81528088018c90526021818701527f4d616b65207375726520746f2061646420656e6f75676820616c6c6f77616e636044820152606560f81b8188015260849150fd5b90508d81813d8311611240575b61122d81836116cb565b8101031261123c57515f610fc5565b8680fd5b503d611223565b8d513d89823e3d90fd5b605a810290808204605a149015171561126c57849004610f64565b634e487b7160e01b835260118652602483fd5b8391503461016657826003193601126101665767ffffffffffffffff81356024358281116108f857366023820112156108f8576112c59036906024818701359101611709565b946112da60018060a01b038554163314611834565b8185526020916009835281862054156114045785526008825284209285519283116113f1575061130a83546121f6565b601f81116113ae575b5080601f831160011461134d5750839482939492611342575b50508160011b915f199060031b1c191617905580f35b01519050848061132c565b90601f198316958486528286209286905b8882106113965750508360019596971061137e575b505050811b01905580f35b01515f1960f88460031b161c19169055848080611373565b8060018596829496860151815501950193019061135e565b838552818520601f840160051c8101918385106113e7575b601f0160051c01905b8181106113dc5750611313565b8581556001016113cf565b90915081906113c6565b634e487b7160e01b855260419052602484fd5b815162461bcd60e51b8152808601849052601060248201526f125b9d985b1a59081d1bdad95b88125160821b6044820152606490fd5b9190503461024c5760209182600319360112610f195780359081855260088452611466838620546121f6565b1561152d5750835260088252808320815193849181815490611487826121f6565b928386526001928884821691825f146115035750506001146114c5575b8588610b06896114b6848a03856116cb565b51928284938452830190611641565b87945081939291528383205b8284106114eb57505050820101816114b6610b065f6114a4565b8054848a0186015288955087949093019281016114d1565b60ff19168882015294151560051b870190940194508593506114b69250610b0691505f90506114a4565b825162461bcd60e51b8152908101849052600b60248201526a155492481b9bdd081cd95d60aa1b6044820152606490fd5b50503461016657816003193601126101665760209051600a8152f35b90503461024c57602036600319011261024c57359063ffffffff60e01b821680920361024c5760209250636cdb3d1360e11b82149182156115d7575b82156115c6575b50519015158152f35b6301ffc9a760e01b1491505f6115bd565b6303a24d0760e21b811492506115b6565b5050346101665780600319360112610166576020906107f4611608611611565b6024359061187f565b600435906001600160a01b038216820361162757565b5f80fd5b602435906001600160a01b038216820361162757565b91908251928382525f5b84811061166b575050825f602080949584010152601f8019910116010190565b60208183018101518483018201520161164b565b6040810190811067ffffffffffffffff82111761169b57604052565b634e487b7160e01b5f52604160045260245ffd5b6020810190811067ffffffffffffffff82111761169b57604052565b90601f8019910116810190811067ffffffffffffffff82111761169b57604052565b67ffffffffffffffff811161169b57601f01601f191660200190565b929192611715826116ed565b9161172360405193846116cb565b829481845281830111611627578281602093845f960137010152565b60809060031901126116275760043590602435906044356001600160a01b0381168103611627579060643590565b67ffffffffffffffff811161169b5760051b60200190565b81601f820112156116275780359161179c8361176d565b926117aa60405194856116cb565b808452602092838086019260051b820101928311611627578301905b8282106117d4575050505090565b813581529083019083016117c6565b9080601f83011215611627578160206117fe93359101611709565b90565b9081518082526020808093019301915f5b828110611820575050505090565b835185529381019392810192600101611812565b1561183b57565b606460405162461bcd60e51b815260206004820152602060248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152fd5b6001600160a01b03169081156118a8575f52600160205260405f20905f5260205260405f205490565b60405162461bcd60e51b815260206004820152602b60248201527f455243313135353a2062616c616e636520717565727920666f7220746865207a60448201526a65726f206164647265737360a81b6064820152608490fd5b5f19811461190f5760010190565b634e487b7160e01b5f52601160045260245ffd5b80518210156119375760209160051b010190565b634e487b7160e01b5f52603260045260245ffd5b1561195257565b60405162461bcd60e51b815260206004820152602560248201527f455243313135353a207472616e7366657220746f20746865207a65726f206164604482015264647265737360d81b6064820152608490fd5b156119ac57565b60405162461bcd60e51b815260206004820152602a60248201527f455243313135353a20696e73756666696369656e742062616c616e636520666f60448201526939103a3930b739b332b960b11b6064820152608490fd5b9190820180921161190f57565b9081602091031261162757516001600160e01b0319811681036116275790565b60809060208152602860208201527f455243313135353a204552433131353552656365697665722072656a656374656040820152676420746f6b656e7360c01b60608201520190565b5f9060033d11611a8657565b905060045f803e5f5160e01c90565b5f60443d106117fe57604051600319913d83016004833e815167ffffffffffffffff918282113d602484011117611af257818401948551938411611afa573d85010160208487010111611af257506117fe929101602001906116cb565b949350505050565b50949350505050565b60809060208152603460208201527f455243313135353a207472616e7366657220746f206e6f6e20455243313135356040820152732932b1b2b4bb32b91034b6b83632b6b2b73a32b960611b60608201520190565b60405190611b658261167f565b60018252602082016020368237825115611937575290565b90600a820291808304600a149015171561190f57565b8181029291811591840414171561190f57565b9190820391821161190f57565b3d15611bdd573d90611bc4826116ed565b91611bd260405193846116cb565b82523d5f602084013e565b606090565b9190801580158091612025575b15611fe057611e28575b5080611c03575050565b6040918251611c11816116af565b5f808252906001600160a01b0383168015611dda57855194611c328661167f565b60019485875260209687810190883683375115611dc657869052611c5582611b58565b508585528587528785208386528752878520611c72838254611a04565b905582858951888152848a8201527fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f628b3392a43b611cb4575b50505050505050565b9185969795918493611cfb958a5180978195829463f23a6e6160e01b9b8c85523360048601528560248601526044850152606484015260a0608484015260a4830190611641565b03925af1909181611da7575b50611d6e57505050611d17611a7a565b6308c379a014611d3a575b505162461bcd60e51b8152806103f360048201611b03565b611d42611a95565b9081611d4e5750611d22565b6103f3835192839262461bcd60e51b845260048401526024830190611641565b919392506001600160e01b031990911603611d9057505f808080808080611cab565b5162461bcd60e51b8152806103f360048201611a31565b611dbf919250853d871161048b5761047c81836116cb565b905f611d07565b634e487b7160e01b86526032600452602486fd5b855162461bcd60e51b815260206004820152602160248201527f455243313135353a206d696e7420746f20746865207a65726f206164647265736044820152607360f81b6064820152608490fd5b604090815190611e37826116af565b5f8083526001600160a01b0386168015611f9257845193611e578561167f565b6001855260209485810190863683375115611f7e57839052611e7884611b58565b50828052600185528583208284528552858320611e96858254611a04565b90558183875181815286888201527fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62893392a4873b611eda575b5050505050611bf9565b93611f228392879a9896839a985195868094819363f23a6e6160e01b9a8b8452336004850152846024850152846044850152606484015260a0608484015260a4830190611641565b03925af1909181611f5f575b50611f3d578686611d17611a7a565b939592945090926001600160e01b03191603611d9057505f8080808080611ed0565b611f77919250873d891161048b5761047c81836116cb565b905f611f2e565b634e487b7160e01b84526032600452602484fd5b845162461bcd60e51b815260206004820152602160248201527f455243313135353a206d696e7420746f20746865207a65726f206164647265736044820152607360f81b6064820152608490fd5b60405162461bcd60e51b815260206004820152601a60248201527f4d757374206d696e74206174206c65617374206f6e65204e46540000000000006044820152606490fd5b50821515611bef565b814710612092575f918291829182916001600160a01b03165af1612050611bb3565b501561205857565b60405162461bcd60e51b81526020600482015260126024820152711155120814185e5b595b9d0819985a5b195960721b6044820152606490fd5b60405162461bcd60e51b815260206004820152600b60248201526a4c6f772062616c616e636560a81b6044820152606490fd5b519069ffffffffffffffffffff8216820361162757565b600654604051633fabe5a360e21b81529060a090829060049082906001600160a01b03165afa908115612177575f9161212b575b506402540be4009081810291818305149015171561190f5790565b9060a0823d821161216f575b8161214460a093836116cb565b810103126107fb5750612156816120c5565b506121686080602083015192016120c5565b505f612110565b3d9150612137565b6040513d5f823e3d90fd5b5f805260096020527fec8156718a8372b1db44bb411437d0870f3e3790d4a08526d024ce1b0b668f6b546117fe92916121f0916121be91611b93565b60015f5260096020527f92e85d02570a8092d09a6e3a57665bc3815a2699a4074001bf1ccabf660f5a36549092611b93565b90611a04565b90600182811c92168015612224575b602083101461221057565b634e487b7160e01b5f52602260045260245ffd5b91607f169161220556fea2646970667358221220eaa22e05957d236202c095608bc9ee1902fde88c6152e27dfacdaaf4328606b364736f6c63430008140033

Verified Source Code Full Match

Compiler: v0.8.20+commit.a1b79de6 EVM: shanghai Optimization: Yes (200 runs)
PaymentRouterMeganet.sol 204 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";

interface Aggregator {
    function latestRoundData()
        external
        view
        returns (
            uint80 roundId,
            int256 answer,
            uint256 startedAt,
            uint256 updatedAt,
            uint80 answeredInRound
        );
}

contract PaymentRouterMeganet is ReentrancyGuard, ERC1155, Ownable {
    uint256 public baseDecimals;
    Aggregator public aggregatorInterface;
    IERC20 public USDTInterface;
    mapping(uint256 => string) private _tokenURIs;
    mapping(uint256 => uint256) public pricePerRouter;
    uint256 public totalNovaMinted;
    uint256 public totalTitanMinted;

    address public receiveWallet;
    uint256 public constant TOKEN_ID_NOVA = 0;
    uint256 public constant TOKEN_ID_TITAN = 1;
    uint8 public constant PERCENTAGE_REFERRAl = 10;

    constructor(
        address _receiveWallet,
        address _oracle,
        address _usdt
    ) ERC1155("") {
        require(_receiveWallet != address(0), "Invalid admin wallet");
        require(_oracle != address(0), "Zero aggregator address");
        require(_usdt != address(0), "Zero USDT address");

        receiveWallet = _receiveWallet;
        baseDecimals = 10 ** 18;
        aggregatorInterface = Aggregator(_oracle);
        pricePerRouter[TOKEN_ID_NOVA] = 59 ether;
        pricePerRouter[TOKEN_ID_TITAN] = 199 ether;
        USDTInterface = IERC20(_usdt);
        _tokenURIs[
            TOKEN_ID_NOVA
        ] = "https://gold-wooden-wolverine-457.mypinata.cloud/ipfs/bafkreigmovgskfit7wsgjclk3npslkra3hcxmy4ierapgxieez4l2gopxa";
        _tokenURIs[
            TOKEN_ID_TITAN
        ] = "https://gold-wooden-wolverine-457.mypinata.cloud/ipfs/bafkreih3rsiv7sg2oq52bswiwixe6ojy43bkjb6sdszopdtpws5q4ifage";
        // totalNovaMinted = 0;
        // totalTitanMinted = 0;
    }

    function paymentWithEth(
        uint256 amountNova,
        uint256 amountTitan,
        address referral,
        uint256 tax
    ) external payable nonReentrant returns (bool) {
        uint256 usdPriceRaw = calculatePrice(amountNova, amountTitan);
        uint256 usdPrice = usdPriceRaw + (usdPriceRaw * tax) / 100;

        if (referral != address(0)) {
            usdPrice = (usdPrice * 90) / 100;
        }
        uint256 ethAmount = (usdPrice * baseDecimals) / getLatestPrice();
        require(msg.value >= ethAmount, "Less payment");

        uint256 excess = msg.value - ethAmount;
        totalNovaMinted += amountNova;
        totalTitanMinted += amountTitan;
        splitETHValue(ethAmount, referral);
        mintRouter(msg.sender, amountNova, amountTitan);
        if (excess > 0) sendValue(payable(_msgSender()), excess);
        return true;
    }

    function paymentWithUsdt(
        uint256 amountNova,
        uint256 amountTitan,
        address referral,
        uint256 tax
    ) external returns (bool) {
        uint256 usdPriceRaw = calculatePrice(amountNova, amountTitan);

        uint256 usdPrice = usdPriceRaw + (usdPriceRaw * tax) / 100;

        if (referral != address(0)) {
            usdPrice = (usdPrice * 90) / 100;
        }
        uint256 price = usdPrice / (10 ** 12);
        totalNovaMinted += amountNova;
        totalTitanMinted += amountTitan;

        uint256 ourAllowance = USDTInterface.allowance(
            _msgSender(),
            address(this)
        );

        require(price <= ourAllowance, "Make sure to add enough allowance");

        splitUSDTValue(price, referral);
        mintRouter(msg.sender, amountNova, amountTitan);
        return true;
    }

    function splitUSDTValue(uint256 _amount, address _referral) internal {
        uint256 referralReward = 0;
        require(receiveWallet != address(0), "Payment wallet not set");
        if (_referral != address(0)) {
            referralReward = (_amount * PERCENTAGE_REFERRAl) / 100;
            (bool successForRef, ) = address(USDTInterface).call(
                abi.encodeWithSignature(
                    "transferFrom(address,address,uint256)",
                    _msgSender(),
                    _referral,
                    referralReward
                )
            );
            require(successForRef, "Token payment for referral failed");
        }
        uint256 remainingAmount = _amount - referralReward;
        (bool success, ) = address(USDTInterface).call(
            abi.encodeWithSignature(
                "transferFrom(address,address,uint256)",
                _msgSender(),
                receiveWallet,
                remainingAmount
            )
        );
        require(success, "Token payment for payment wallet failed");
    }

    function splitETHValue(uint256 _amount, address _referral) internal {
        uint256 referralReward = 0;
        if (_referral != address(0)) {
            referralReward = (_amount * PERCENTAGE_REFERRAl) / 100;
            sendValue(payable(_referral), referralReward);
        }

        uint256 remainingAmount = _amount - referralReward;
        require(receiveWallet != address(0), "Receive wallet not set");
        sendValue(payable(receiveWallet), remainingAmount);
    }

    function mintRouter(
        address to,
        uint256 amountNova,
        uint256 amountTitan
    ) internal {
        require(
            amountNova > 0 || amountTitan > 0,
            "Must mint at least one NFT"
        );
        if (amountNova > 0) {
            _mint(to, TOKEN_ID_NOVA, amountNova, "");
        }

        if (amountTitan > 0) {
            _mint(to, TOKEN_ID_TITAN, amountTitan, "");
        }
    }

    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Low balance");
        (bool success, ) = recipient.call{value: amount}("");
        require(success, "ETH Payment failed");
    }

    function getLatestPrice() public view returns (uint256) {
        (, int256 price, , , ) = aggregatorInterface.latestRoundData();
        price = (price * (10 ** 10));
        return uint256(price);
    }

    function calculatePrice(
        uint256 amountNova,
        uint256 amountTitan
    ) public view returns (uint256 usdAmount) {
        usdAmount =
            (amountNova * pricePerRouter[TOKEN_ID_NOVA]) +
            (amountTitan * pricePerRouter[TOKEN_ID_TITAN]);
    }

    function setTokenURI(
        uint256 tokenId,
        string memory newUri
    ) external onlyOwner {
        require(pricePerRouter[tokenId] > 0, "Invalid token ID");
        _tokenURIs[tokenId] = newUri;
    }

    function uri(uint256 tokenId) public view override returns (string memory) {
        require(bytes(_tokenURIs[tokenId]).length > 0, "URI not set");
        return _tokenURIs[tokenId];
    }
}
ERC1155.sol 511 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC1155/ERC1155.sol)

pragma solidity ^0.8.0;

import "./IERC1155.sol";
import "./IERC1155Receiver.sol";
import "./extensions/IERC1155MetadataURI.sol";
import "../../utils/Address.sol";
import "../../utils/Context.sol";
import "../../utils/introspection/ERC165.sol";

/**
 * @dev Implementation of the basic standard multi-token.
 * See https://eips.ethereum.org/EIPS/eip-1155
 * Originally based on code by Enjin: https://github.com/enjin/erc-1155
 *
 * _Available since v3.1._
 */
contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI {
    using Address for address;

    // Mapping from token ID to account balances
    mapping(uint256 => mapping(address => uint256)) private _balances;

    // Mapping from account to operator approvals
    mapping(address => mapping(address => bool)) private _operatorApprovals;

    // Used as the URI for all token types by relying on ID substitution, e.g. https://token-cdn-domain/{id}.json
    string private _uri;

    /**
     * @dev See {_setURI}.
     */
    constructor(string memory uri_) {
        _setURI(uri_);
    }

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
        return
            interfaceId == type(IERC1155).interfaceId ||
            interfaceId == type(IERC1155MetadataURI).interfaceId ||
            super.supportsInterface(interfaceId);
    }

    /**
     * @dev See {IERC1155MetadataURI-uri}.
     *
     * This implementation returns the same URI for *all* token types. It relies
     * on the token type ID substitution mechanism
     * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP].
     *
     * Clients calling this function must replace the `\{id\}` substring with the
     * actual token type ID.
     */
    function uri(uint256) public view virtual override returns (string memory) {
        return _uri;
    }

    /**
     * @dev See {IERC1155-balanceOf}.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     */
    function balanceOf(address account, uint256 id) public view virtual override returns (uint256) {
        require(account != address(0), "ERC1155: balance query for the zero address");
        return _balances[id][account];
    }

    /**
     * @dev See {IERC1155-balanceOfBatch}.
     *
     * Requirements:
     *
     * - `accounts` and `ids` must have the same length.
     */
    function balanceOfBatch(address[] memory accounts, uint256[] memory ids)
        public
        view
        virtual
        override
        returns (uint256[] memory)
    {
        require(accounts.length == ids.length, "ERC1155: accounts and ids length mismatch");

        uint256[] memory batchBalances = new uint256[](accounts.length);

        for (uint256 i = 0; i < accounts.length; ++i) {
            batchBalances[i] = balanceOf(accounts[i], ids[i]);
        }

        return batchBalances;
    }

    /**
     * @dev See {IERC1155-setApprovalForAll}.
     */
    function setApprovalForAll(address operator, bool approved) public virtual override {
        _setApprovalForAll(_msgSender(), operator, approved);
    }

    /**
     * @dev See {IERC1155-isApprovedForAll}.
     */
    function isApprovedForAll(address account, address operator) public view virtual override returns (bool) {
        return _operatorApprovals[account][operator];
    }

    /**
     * @dev See {IERC1155-safeTransferFrom}.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 id,
        uint256 amount,
        bytes memory data
    ) public virtual override {
        require(
            from == _msgSender() || isApprovedForAll(from, _msgSender()),
            "ERC1155: caller is not owner nor approved"
        );
        _safeTransferFrom(from, to, id, amount, data);
    }

    /**
     * @dev See {IERC1155-safeBatchTransferFrom}.
     */
    function safeBatchTransferFrom(
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) public virtual override {
        require(
            from == _msgSender() || isApprovedForAll(from, _msgSender()),
            "ERC1155: transfer caller is not owner nor approved"
        );
        _safeBatchTransferFrom(from, to, ids, amounts, data);
    }

    /**
     * @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
     *
     * Emits a {TransferSingle} event.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - `from` must have a balance of tokens of type `id` of at least `amount`.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
     * acceptance magic value.
     */
    function _safeTransferFrom(
        address from,
        address to,
        uint256 id,
        uint256 amount,
        bytes memory data
    ) internal virtual {
        require(to != address(0), "ERC1155: transfer to the zero address");

        address operator = _msgSender();
        uint256[] memory ids = _asSingletonArray(id);
        uint256[] memory amounts = _asSingletonArray(amount);

        _beforeTokenTransfer(operator, from, to, ids, amounts, data);

        uint256 fromBalance = _balances[id][from];
        require(fromBalance >= amount, "ERC1155: insufficient balance for transfer");
        unchecked {
            _balances[id][from] = fromBalance - amount;
        }
        _balances[id][to] += amount;

        emit TransferSingle(operator, from, to, id, amount);

        _afterTokenTransfer(operator, from, to, ids, amounts, data);

        _doSafeTransferAcceptanceCheck(operator, from, to, id, amount, data);
    }

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_safeTransferFrom}.
     *
     * Emits a {TransferBatch} event.
     *
     * Requirements:
     *
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
     * acceptance magic value.
     */
    function _safeBatchTransferFrom(
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) internal virtual {
        require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
        require(to != address(0), "ERC1155: transfer to the zero address");

        address operator = _msgSender();

        _beforeTokenTransfer(operator, from, to, ids, amounts, data);

        for (uint256 i = 0; i < ids.length; ++i) {
            uint256 id = ids[i];
            uint256 amount = amounts[i];

            uint256 fromBalance = _balances[id][from];
            require(fromBalance >= amount, "ERC1155: insufficient balance for transfer");
            unchecked {
                _balances[id][from] = fromBalance - amount;
            }
            _balances[id][to] += amount;
        }

        emit TransferBatch(operator, from, to, ids, amounts);

        _afterTokenTransfer(operator, from, to, ids, amounts, data);

        _doSafeBatchTransferAcceptanceCheck(operator, from, to, ids, amounts, data);
    }

    /**
     * @dev Sets a new URI for all token types, by relying on the token type ID
     * substitution mechanism
     * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP].
     *
     * By this mechanism, any occurrence of the `\{id\}` substring in either the
     * URI or any of the amounts in the JSON file at said URI will be replaced by
     * clients with the token type ID.
     *
     * For example, the `https://token-cdn-domain/\{id\}.json` URI would be
     * interpreted by clients as
     * `https://token-cdn-domain/000000000000000000000000000000000000000000000000000000000004cce0.json`
     * for token type ID 0x4cce0.
     *
     * See {uri}.
     *
     * Because these URIs cannot be meaningfully represented by the {URI} event,
     * this function emits no events.
     */
    function _setURI(string memory newuri) internal virtual {
        _uri = newuri;
    }

    /**
     * @dev Creates `amount` tokens of token type `id`, and assigns them to `to`.
     *
     * Emits a {TransferSingle} event.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
     * acceptance magic value.
     */
    function _mint(
        address to,
        uint256 id,
        uint256 amount,
        bytes memory data
    ) internal virtual {
        require(to != address(0), "ERC1155: mint to the zero address");

        address operator = _msgSender();
        uint256[] memory ids = _asSingletonArray(id);
        uint256[] memory amounts = _asSingletonArray(amount);

        _beforeTokenTransfer(operator, address(0), to, ids, amounts, data);

        _balances[id][to] += amount;
        emit TransferSingle(operator, address(0), to, id, amount);

        _afterTokenTransfer(operator, address(0), to, ids, amounts, data);

        _doSafeTransferAcceptanceCheck(operator, address(0), to, id, amount, data);
    }

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_mint}.
     *
     * Requirements:
     *
     * - `ids` and `amounts` must have the same length.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
     * acceptance magic value.
     */
    function _mintBatch(
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) internal virtual {
        require(to != address(0), "ERC1155: mint to the zero address");
        require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");

        address operator = _msgSender();

        _beforeTokenTransfer(operator, address(0), to, ids, amounts, data);

        for (uint256 i = 0; i < ids.length; i++) {
            _balances[ids[i]][to] += amounts[i];
        }

        emit TransferBatch(operator, address(0), to, ids, amounts);

        _afterTokenTransfer(operator, address(0), to, ids, amounts, data);

        _doSafeBatchTransferAcceptanceCheck(operator, address(0), to, ids, amounts, data);
    }

    /**
     * @dev Destroys `amount` tokens of token type `id` from `from`
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `from` must have at least `amount` tokens of token type `id`.
     */
    function _burn(
        address from,
        uint256 id,
        uint256 amount
    ) internal virtual {
        require(from != address(0), "ERC1155: burn from the zero address");

        address operator = _msgSender();
        uint256[] memory ids = _asSingletonArray(id);
        uint256[] memory amounts = _asSingletonArray(amount);

        _beforeTokenTransfer(operator, from, address(0), ids, amounts, "");

        uint256 fromBalance = _balances[id][from];
        require(fromBalance >= amount, "ERC1155: burn amount exceeds balance");
        unchecked {
            _balances[id][from] = fromBalance - amount;
        }

        emit TransferSingle(operator, from, address(0), id, amount);

        _afterTokenTransfer(operator, from, address(0), ids, amounts, "");
    }

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_burn}.
     *
     * Requirements:
     *
     * - `ids` and `amounts` must have the same length.
     */
    function _burnBatch(
        address from,
        uint256[] memory ids,
        uint256[] memory amounts
    ) internal virtual {
        require(from != address(0), "ERC1155: burn from the zero address");
        require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");

        address operator = _msgSender();

        _beforeTokenTransfer(operator, from, address(0), ids, amounts, "");

        for (uint256 i = 0; i < ids.length; i++) {
            uint256 id = ids[i];
            uint256 amount = amounts[i];

            uint256 fromBalance = _balances[id][from];
            require(fromBalance >= amount, "ERC1155: burn amount exceeds balance");
            unchecked {
                _balances[id][from] = fromBalance - amount;
            }
        }

        emit TransferBatch(operator, from, address(0), ids, amounts);

        _afterTokenTransfer(operator, from, address(0), ids, amounts, "");
    }

    /**
     * @dev Approve `operator` to operate on all of `owner` tokens
     *
     * Emits a {ApprovalForAll} event.
     */
    function _setApprovalForAll(
        address owner,
        address operator,
        bool approved
    ) internal virtual {
        require(owner != operator, "ERC1155: setting approval status for self");
        _operatorApprovals[owner][operator] = approved;
        emit ApprovalForAll(owner, operator, approved);
    }

    /**
     * @dev Hook that is called before any token transfer. This includes minting
     * and burning, as well as batched variants.
     *
     * The same hook is called on both single and batched variants. For single
     * transfers, the length of the `id` and `amount` arrays will be 1.
     *
     * Calling conditions (for each `id` and `amount` pair):
     *
     * - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * of token type `id` will be  transferred to `to`.
     * - When `from` is zero, `amount` tokens of token type `id` will be minted
     * for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens of token type `id`
     * will be burned.
     * - `from` and `to` are never both zero.
     * - `ids` and `amounts` have the same, non-zero length.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(
        address operator,
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) internal virtual {}

    /**
     * @dev Hook that is called after any token transfer. This includes minting
     * and burning, as well as batched variants.
     *
     * The same hook is called on both single and batched variants. For single
     * transfers, the length of the `id` and `amount` arrays will be 1.
     *
     * Calling conditions (for each `id` and `amount` pair):
     *
     * - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * of token type `id` will be  transferred to `to`.
     * - When `from` is zero, `amount` tokens of token type `id` will be minted
     * for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens of token type `id`
     * will be burned.
     * - `from` and `to` are never both zero.
     * - `ids` and `amounts` have the same, non-zero length.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _afterTokenTransfer(
        address operator,
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) internal virtual {}

    function _doSafeTransferAcceptanceCheck(
        address operator,
        address from,
        address to,
        uint256 id,
        uint256 amount,
        bytes memory data
    ) private {
        if (to.isContract()) {
            try IERC1155Receiver(to).onERC1155Received(operator, from, id, amount, data) returns (bytes4 response) {
                if (response != IERC1155Receiver.onERC1155Received.selector) {
                    revert("ERC1155: ERC1155Receiver rejected tokens");
                }
            } catch Error(string memory reason) {
                revert(reason);
            } catch {
                revert("ERC1155: transfer to non ERC1155Receiver implementer");
            }
        }
    }

    function _doSafeBatchTransferAcceptanceCheck(
        address operator,
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) private {
        if (to.isContract()) {
            try IERC1155Receiver(to).onERC1155BatchReceived(operator, from, ids, amounts, data) returns (
                bytes4 response
            ) {
                if (response != IERC1155Receiver.onERC1155BatchReceived.selector) {
                    revert("ERC1155: ERC1155Receiver rejected tokens");
                }
            } catch Error(string memory reason) {
                revert(reason);
            } catch {
                revert("ERC1155: transfer to non ERC1155Receiver implementer");
            }
        }
    }

    function _asSingletonArray(uint256 element) private pure returns (uint256[] memory) {
        uint256[] memory array = new uint256[](1);
        array[0] = element;

        return array;
    }
}
Ownable.sol 76 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)

pragma solidity ^0.8.0;

import "../utils/Context.sol";

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() {
        _transferOwnership(_msgSender());
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
        _;
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}
IERC20.sol 82 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @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);
}
ReentrancyGuard.sol 63 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)

pragma solidity ^0.8.0;

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract ReentrancyGuard {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant _NOT_ENTERED = 1;
    uint256 private constant _ENTERED = 2;

    uint256 private _status;

    constructor() {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        // On the first call to nonReentrant, _notEntered will be true
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

        // Any calls to nonReentrant after this point will fail
        _status = _ENTERED;

        _;

        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = _NOT_ENTERED;
    }
}
IERC1155.sol 125 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC1155/IERC1155.sol)

pragma solidity ^0.8.0;

import "../../utils/introspection/IERC165.sol";

/**
 * @dev Required interface of an ERC1155 compliant contract, as defined in the
 * https://eips.ethereum.org/EIPS/eip-1155[EIP].
 *
 * _Available since v3.1._
 */
interface IERC1155 is IERC165 {
    /**
     * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`.
     */
    event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);

    /**
     * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all
     * transfers.
     */
    event TransferBatch(
        address indexed operator,
        address indexed from,
        address indexed to,
        uint256[] ids,
        uint256[] values
    );

    /**
     * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to
     * `approved`.
     */
    event ApprovalForAll(address indexed account, address indexed operator, bool approved);

    /**
     * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.
     *
     * If an {URI} event was emitted for `id`, the standard
     * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value
     * returned by {IERC1155MetadataURI-uri}.
     */
    event URI(string value, uint256 indexed id);

    /**
     * @dev Returns the amount of tokens of token type `id` owned by `account`.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     */
    function balanceOf(address account, uint256 id) external view returns (uint256);

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.
     *
     * Requirements:
     *
     * - `accounts` and `ids` must have the same length.
     */
    function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids)
        external
        view
        returns (uint256[] memory);

    /**
     * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,
     *
     * Emits an {ApprovalForAll} event.
     *
     * Requirements:
     *
     * - `operator` cannot be the caller.
     */
    function setApprovalForAll(address operator, bool approved) external;

    /**
     * @dev Returns true if `operator` is approved to transfer ``account``'s tokens.
     *
     * See {setApprovalForAll}.
     */
    function isApprovedForAll(address account, address operator) external view returns (bool);

    /**
     * @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
     *
     * Emits a {TransferSingle} event.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - If the caller is not `from`, it must be have been approved to spend ``from``'s tokens via {setApprovalForAll}.
     * - `from` must have a balance of tokens of type `id` of at least `amount`.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
     * acceptance magic value.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 id,
        uint256 amount,
        bytes calldata data
    ) external;

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
     *
     * Emits a {TransferBatch} event.
     *
     * Requirements:
     *
     * - `ids` and `amounts` must have the same length.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
     * acceptance magic value.
     */
    function safeBatchTransferFrom(
        address from,
        address to,
        uint256[] calldata ids,
        uint256[] calldata amounts,
        bytes calldata data
    ) external;
}
IERC1155Receiver.sol 58 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/IERC1155Receiver.sol)

pragma solidity ^0.8.0;

import "../../utils/introspection/IERC165.sol";

/**
 * @dev _Available since v3.1._
 */
interface IERC1155Receiver is IERC165 {
    /**
     * @dev Handles the receipt of a single ERC1155 token type. This function is
     * called at the end of a `safeTransferFrom` after the balance has been updated.
     *
     * NOTE: To accept the transfer, this must return
     * `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))`
     * (i.e. 0xf23a6e61, or its own function selector).
     *
     * @param operator The address which initiated the transfer (i.e. msg.sender)
     * @param from The address which previously owned the token
     * @param id The ID of the token being transferred
     * @param value The amount of tokens being transferred
     * @param data Additional data with no specified format
     * @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed
     */
    function onERC1155Received(
        address operator,
        address from,
        uint256 id,
        uint256 value,
        bytes calldata data
    ) external returns (bytes4);

    /**
     * @dev Handles the receipt of a multiple ERC1155 token types. This function
     * is called at the end of a `safeBatchTransferFrom` after the balances have
     * been updated.
     *
     * NOTE: To accept the transfer(s), this must return
     * `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))`
     * (i.e. 0xbc197c81, or its own function selector).
     *
     * @param operator The address which initiated the batch transfer (i.e. msg.sender)
     * @param from The address which previously owned the token
     * @param ids An array containing ids of each token being transferred (order and length must match values array)
     * @param values An array containing amounts of each token being transferred (order and length must match ids array)
     * @param data Additional data with no specified format
     * @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed
     */
    function onERC1155BatchReceived(
        address operator,
        address from,
        uint256[] calldata ids,
        uint256[] calldata values,
        bytes calldata data
    ) external returns (bytes4);
}
IERC1155MetadataURI.sol 22 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC1155/extensions/IERC1155MetadataURI.sol)

pragma solidity ^0.8.0;

import "../IERC1155.sol";

/**
 * @dev Interface of the optional ERC1155MetadataExtension interface, as defined
 * in the https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[EIP].
 *
 * _Available since v3.1._
 */
interface IERC1155MetadataURI is IERC1155 {
    /**
     * @dev Returns the URI for token type `id`.
     *
     * If the `\{id\}` substring is present in the URI, it must be replaced by
     * clients with the actual token type ID.
     */
    function uri(uint256 id) external view returns (string memory);
}
Address.sol 222 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)

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) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

    /**
     * @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 {
        require(address(this).balance >= amount, "Address: insufficient balance");

        (bool success, ) = recipient.call{value: amount}("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @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) {
        return functionCall(target, data, "Address: low-level call failed");
    }

    /**
     * @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) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @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) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @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) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        require(isContract(target), "Address: call to non-contract");

        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @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) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

    /**
     * @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) {
        require(isContract(target), "Address: static call to non-contract");

        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @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) {
        return functionDelegateCall(target, data, "Address: low-level delegate call failed");
    }

    /**
     * @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) {
        require(isContract(target), "Address: delegate call to non-contract");

        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly

                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}
Context.sol 24 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
}
ERC165.sol 29 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)

pragma solidity ^0.8.0;

import "./IERC165.sol";

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
 * for the additional interface id that will be supported. For example:
 *
 * ```solidity
 * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
 *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
 * }
 * ```
 *
 * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
 */
abstract contract ERC165 is IERC165 {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IERC165).interfaceId;
    }
}
IERC165.sol 25 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[EIP].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165 {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

Read Contract

PERCENTAGE_REFERRAl 0x06ee82c5 → uint8
TOKEN_ID_NOVA 0x999485ad → uint256
TOKEN_ID_TITAN 0xa4206115 → uint256
USDTInterface 0xf597573f → address
aggregatorInterface 0xc49cc645 → address
balanceOf 0x00fdd58e → uint256
balanceOfBatch 0x4e1273f4 → uint256[]
baseDecimals 0x33f76178 → uint256
calculatePrice 0xa6413a27 → uint256
getLatestPrice 0x8e15f473 → uint256
isApprovedForAll 0xe985e9c5 → bool
owner 0x8da5cb5b → address
pricePerRouter 0xbb4644f7 → uint256
receiveWallet 0x5d313295 → address
supportsInterface 0x01ffc9a7 → bool
totalNovaMinted 0xf431c0dc → uint256
totalTitanMinted 0xa696cc9d → uint256
uri 0x0e89341c → string

Write Contract 8 functions

These functions modify contract state and require a wallet transaction to execute.

paymentWithEth 0xdfeae56c
uint256 amountNova
uint256 amountTitan
address referral
uint256 tax
returns: bool
paymentWithUsdt 0x2b9f0254
uint256 amountNova
uint256 amountTitan
address referral
uint256 tax
returns: bool
renounceOwnership 0x715018a6
No parameters
safeBatchTransferFrom 0x2eb2c2d6
address from
address to
uint256[] ids
uint256[] amounts
bytes data
safeTransferFrom 0xf242432a
address from
address to
uint256 id
uint256 amount
bytes data
setApprovalForAll 0xa22cb465
address operator
bool approved
setTokenURI 0x162094c4
uint256 tokenId
string newUri
transferOwnership 0xf2fde38b
address newOwner

Recent Transactions

This address has 1 on-chain transactions, but only 1.1% of the chain is indexed. Transactions will appear as indexing progresses. View on Etherscan →