├── .env
├── .eslintcache
├── .gitignore
├── README.md
├── contracts
├── MaticHeaven.sol
└── Migrations.sol
├── migrations
├── 1_initial_migration.js
└── 2_deploy_contracts.js
├── package-lock.json
├── package.json
├── public
├── .htaccess
├── PolygonLogo.png
├── favicon.ico
├── index.html
├── logo192.png
├── logo512.png
├── manifest.json
└── robots.txt
├── src
├── App.css
├── App.js
├── App.test.js
├── assets
│ ├── ClipboardText.png
│ ├── Extra Matic (1).zip
│ ├── LilitaOne-Regular.ttf
│ ├── PolygonLogo.png
│ ├── contract.sol
│ └── header.png
├── config
│ ├── abi.json
│ └── new.json
├── index.css
├── index.js
├── logo.svg
├── reportWebVitals.js
├── setupTests.js
└── utils
│ └── web3API.js
├── test
└── .gitkeep
└── truffle-config.js
/.env:
--------------------------------------------------------------------------------
1 | REACT_APP_CONTRACT_ADDRESS = 0xC5C36390F27ddE32246c771396c09b5352CD719e
2 | REACT_APP_WEB3_PROVIDER_ADDRESS = https://rpc-mumbai.maticvigil.com
3 | REACT_APP_WEB3_TERRIORY_WALLET = 0xea2e9D3739abE4Bc6fEB23e41785560A676b6c55
4 | REACT_APP_BASE_URI = localhost:3000
--------------------------------------------------------------------------------
/.eslintcache:
--------------------------------------------------------------------------------
1 | [{"E:\\Blockchain\\Task\\2022_3_11 PolygonReactSite\\polygon-matic\\src\\index.js":"1","E:\\Blockchain\\Task\\2022_3_11 PolygonReactSite\\polygon-matic\\src\\App.js":"2","E:\\Blockchain\\Task\\2022_3_11 PolygonReactSite\\polygon-matic\\src\\reportWebVitals.js":"3","E:\\Blockchain\\Task\\2022_3_11 PolygonReactSite\\polygon-matic\\src\\utils\\web3API.js":"4"},{"size":500,"mtime":499162500000,"results":"5","hashOfConfig":"6"},{"size":16405,"mtime":1647487374169,"results":"7","hashOfConfig":"6"},{"size":362,"mtime":499162500000,"results":"8","hashOfConfig":"6"},{"size":11197,"mtime":1647621984671,"results":"9","hashOfConfig":"6"},{"filePath":"10","messages":"11","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"yu5si8",{"filePath":"12","messages":"13","errorCount":0,"fatalErrorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":"14"},{"filePath":"15","messages":"16","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"17","messages":"18","errorCount":0,"fatalErrorCount":0,"warningCount":2,"fixableErrorCount":0,"fixableWarningCount":0,"source":"19"},"E:\\Blockchain\\Task\\2022_3_11 PolygonReactSite\\polygon-matic\\src\\index.js",[],"E:\\Blockchain\\Task\\2022_3_11 PolygonReactSite\\polygon-matic\\src\\App.js",["20"],"import React, {useEffect, useState} from \"react\";\nimport headerback from './assets/header.png';\nimport logo from './assets/PolygonLogo.png';\nimport contactIcon from './assets/ClipboardText.png'\nimport './App.css';\nimport {connectToWallet, web3_contact_balance , web3_total_deposit , web3_user_deposit_count , web3_user_total_withdraw , web3_user_total_deposit , web3_user_referral_bonus , web3_available_balance , stakeMATIC, reinvest , WithdrawFn , web3_referred_users} from './utils/web3API'\n\nfunction App() {\n const [ walletAddress, setWalletAddress ] = useState(\"\")\n const [contact_balance , setContactBalance ] = useState(0.000)\n const [total_deposit , setTotalDeposit] = useState(0)\n const [user_deposit_count , setUserDepositCount] = useState(0)\n const [user_total_deposit , setUserTotalDeposit] = useState(0.000)\n const [user_total_withdraw , setUserTotalWithdraw] = useState(0.000)\n const [user_referral_bonus , setUserReferralBonus] = useState(0.000)\n const [referred_user , setReferredUsers] = useState(0.000)\n const [amount_plan1, setAmountPlan1] = useState(0.000)\n const [amount_plan2, setAmountPlan2] = useState(0.000)\n const [referral_address, setReferralAddress] = useState(\"\")\n const [reinvest_show , setReinvestShow] = useState(\"\")\n const [available_balance , setAvailableBalance] = useState(0)\n // const reinvest_show = false\n useEffect(()=> {\n\n if(!walletAddress){ \n walletConnect()\n getContactBalance()\n getTotalDeposit()\n getUserDepositCount()\n getUserTotalDeposit()\n getUserTotalWithdraw()\n getUserReferralBonus()\n getReferredUsers()\n getUserAvailableBalance()\n }\n\n // getUSDValue()\n })\n\n const walletConnect = async () => {\n const res = await connectToWallet()//connect to metamask\n setWalletAddress(res)//set wallet adderess as the res\n }\n \n const getContactBalance = async () => {//get Contract balance\n const res = await web3_contact_balance()\n setContactBalance(parseFloat(res).toFixed(4))\n }\n const getTotalDeposit = async () => {//get Total deposit\n const res = await web3_total_deposit()\n console.log(res)\n setTotalDeposit(parseFloat(res).toFixed(4))\n }\n const getUserDepositCount = async () => {//get User deposit count\n const res = await web3_user_deposit_count()\n setUserDepositCount(res)\n }\n const getUserTotalDeposit = async () => {//get user total deposit\n const res = await web3_user_total_deposit()\n setUserTotalDeposit(parseFloat(res).toFixed(4))\n }\n const getUserTotalWithdraw = async () => {//get user total withdraw\n const res = await web3_user_total_withdraw()\n setUserTotalWithdraw(parseFloat(res).toFixed(4))\n }\n const getUserReferralBonus = async () => {//get user referral bonus\n const res = await web3_user_referral_bonus()\n setUserReferralBonus(res)\n }\n const getReferredUsers = async () => {//get referred users\n const res = await web3_referred_users()\n setReferredUsers(res)\n }\n const getUserAvailableBalance = async () => {\n const res = await web3_available_balance()\n setAvailableBalance(parseFloat(res).toFixed(4))\n }\n\n const formattedAddress = () => {\n if(walletAddress) {\n return `${walletAddress.slice(0,5)}...${walletAddress.slice(-5)}`\n }\n }\n const callStakePlan1 = async () => {\n var ref_add = document.getElementById('wallet_address').value\n const res = await stakeMATIC(ref_add , amount_plan1, 0)\n return res \n }\n const callStakePlan2 = async () => {\n var ref_add = document.getElementById('wallet_address').value\n const res = await stakeMATIC(ref_add , amount_plan2, 1)\n return res \n }\n const Reinvest_show = () => {\n if(reinvest_show === false)\n setReinvestShow(true)\n else setReinvestShow(false)\n console.log(reinvest_show)\n }\n const Reinvest = async (plan) => {\n const res = await reinvest(plan)\n return res\n }\n const Withdraw = async () => {\n const res = await WithdrawFn()\n return res\n }\n const PasteWalletAddress = async() => {\n const text = await navigator.clipboard.readText();\n console.log(text)\n document.getElementById('wallet_address').value = text\n }\n\n// const ipfsClient = require(\"ipfs-http-client\");\n// const ipfs = ipfsClient({\n// host: \"ipfs.infura.io\",\n// port: 5001,\n// protocol: \"https\",\n// });\n\n return (\n
\n
\n
\n \n \n \n \n
\n \n
\n
\n
\n
\n
\n
\n {contact_balance}\n
\n
\n Contract Balance\n
\n
\n
\n
\n
\n
\n {total_deposit}\n
\n
\n Total Deposit\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n 17% daily
for 8 days\n
\n
\n
\n total 136%\n
\n
\n {setAmountPlan1(e.target.value)}}>\n\n \n
\n
\n \n
\n
\n Minimum deposit 0.1 Matic\n
\n
\n \n
\n
\n
\n
\n
\n
\n 7% daily
for 60 days\n
\n
\n
\n total 420%\n
\n
{setAmountPlan2(e.target.value)}}>\n\n \n
\n \n
\n
\n Minimum deposit 0.1 Matic\n
\n
\n
\n
\n
\n \n
\n
\n
\n
\n
\n Personal Dashboard\n
\n
\n
\n
\n
\n
\n
\n
{available_balance}
\n
Available Balance
\n
\n
\n
\n
\n \n
\n
\n \n \n
\n
\n \n
\n
\n
\n

\n
\n
\n
\n
\n
- Minimum reinvest 0.1 MATIC, Get 5% reinvest bonus on 60 days plan.
\n
\n - Minimum withdrawal 1 MATIC, and 20% of each withdrawal will be converted to auto reinvest on 60 days plan with 5% reinvest bonus\n
\n
\n
\n
\n
\n
\n
{user_deposit_count}
\n
Deposit Count
\n
\n
\n
\n
\n
{user_total_deposit}
\n
Total Deposit
\n
\n
\n
\n
\n
\n
\n
{user_total_withdraw}
\n
Total Withdraw
\n
\n
\n
\n
\n
{user_referral_bonus}
\n
Total Referral Bonus
\n
\n
\n
\n
\n
\n
\n
\n
level 1 = 5%
\n
level 2 = 3%
\n
level 3 = 1%
\n
\n
\n
\n
\n
\n
\n
\n
\n Your Referral Link\n
\n
\n
\n
\n
\n {setReferralAddress(e.target.value)}}>\n
\n
\n
\n
\n
\n
\n
\n
\n
{referred_user}
\n
Referred Users
\n
\n \n
\n
\n
\n \n
\n
\n );\n}\n\nexport default App;\n","E:\\Blockchain\\Task\\2022_3_11 PolygonReactSite\\polygon-matic\\src\\reportWebVitals.js",[],"E:\\Blockchain\\Task\\2022_3_11 PolygonReactSite\\polygon-matic\\src\\utils\\web3API.js",["21","22"],"import Web3 from 'web3'\nimport contractAbi from '../config/abi.json'\nimport { toast } from 'react-toastify';\n\nlet Contract = require(\"web3-eth-contract\");\nContract.setProvider(\"https://rpc-mainnet.maticvigil.com\")\nexport const connectToWallet = async () => {//connect the metamask using web3 and get current user account\n let web3;\n try {\n if (window.ethereum) {\n web3 = new Web3(window.ethereum)\n await window.ethereum.request({ method: 'eth_requestAccounts' })\n } else if (window.web3) {\n web3 = new Web3(window.web3.currentProvider || \"https://rpc-mainnet.maticvigil.com\")\n }\n const accounts = await web3.eth.getAccounts();\n return accounts[0]\n } catch (error) {\n // console.log(\"Error: \", error)\n return false\n }\n}\n\nexport const getWeb3 = async () => {//first connect the EVM and return web3 instance. always use!\n let web3;\n if (window.ethereum) {\n web3 = new Web3(window.ethereum);\n } else if (window.web3) {\n await window.web3.currentProvider.enable();\n web3 = new Web3(window.web3.currentProvider);\n } else {\n console.log('No web3 instance detected.');\n return false;\n }\n return web3;\n}\n\nexport const web3_contact_balance = async () => {\n const web3 = await getWeb3();\n if (!web3) {\n console.log(\"No web3 instance found.\");\n return false;\n }\n try {\n let extraMaticContract = new Contract(contractAbi, \"0x2a2cf93bc92537a596e7956315ce914186d0242f\" );//create instance of contract with abi and address\n const res = await extraMaticContract.methods.getSiteInfo().call()\n let contact_balance = web3.utils.fromWei(res['_contractBalance'])\n // console.log(\"contract_balance\" + res['_contractBalance'])\n return contact_balance\n \n } catch (e) {\n console.log(\"failed\")\n return false;\n }\n}\n\nexport const web3_total_deposit = async () => {\n const web3 = await getWeb3();\n if (!web3) {\n toast.error(\"No web3 instance found.\");\n return false;\n }\n try {\n let extraMaticContract = new Contract(contractAbi, \"0x2a2cf93bc92537a596e7956315ce914186d0242f\" );//create instance of contract with abi and address\n const res = await extraMaticContract.methods.getSiteInfo().call()//get total staked money value\n let total_deposit = web3.utils.fromWei(res['_totalInvested'])\n // console.log(\"total_deposit\" + res['_totalInvested'])\n return total_deposit \n \n } catch (e) {\n return false;\n }\n}\n\nexport const web3_user_deposit_count = async () => {\n const web3 = await getWeb3();\n if (!web3) {\n console.log(\"No web3 instance found.\");\n return false;\n }\n try {\n let extraMaticContract = new Contract(contractAbi, \"0x2a2cf93bc92537a596e7956315ce914186d0242f\" );//create instance of contract with abi and address\n const accounts = await web3.eth.getAccounts();\n const res = await extraMaticContract.methods.getUserAmountOfDeposits(accounts[0]).call()//get total staked money value\n // let contact_balance = web3.utils.fromWei(res)\n \n return res \n \n } catch (e) {\n return false;\n }\n}\n\nexport const web3_user_total_deposit = async () => {\n const web3 = await getWeb3();\n if (!web3) {\n console.log(\"No web3 instance found.\");\n return false;\n }\n try {\n let extraMaticContract = new Contract(contractAbi, \"0x2a2cf93bc92537a596e7956315ce914186d0242f\" );//create instance of contract with abi and address\n const accounts = await web3.eth.getAccounts();\n const res = await extraMaticContract.methods.getUserInfo(accounts[0]).call()//get total staked money value\n let contact_balance = web3.utils.fromWei(res['totalDeposit'])\n return contact_balance \n \n } catch (e) {\n return false;\n }\n}\n\nexport const web3_user_total_withdraw = async () => {\n const web3 = await getWeb3();\n if (!web3) {\n console.log(\"No web3 instance found.\");\n return false;\n }\n try {\n let extraMaticContract = new Contract(contractAbi, \"0x2a2cf93bc92537a596e7956315ce914186d0242f\" );//create instance of contract with abi and address\n const accounts = await web3.eth.getAccounts();\n const res = await extraMaticContract.methods.getUserInfo(accounts[0]).call()//get total staked money value\n let contact_balance = web3.utils.fromWei(res['totalWithdrawn'])\n return contact_balance \n \n } catch (e) {\n return false;\n }\n}\n\nexport const web3_user_referral_bonus = async () => {\n const web3 = await getWeb3();\n if (!web3) {\n console.log(\"No web3 instance found.\");\n return false;\n }\n try {\n let extraMaticContract = new Contract(contractAbi, \"0x2a2cf93bc92537a596e7956315ce914186d0242f\" );//create instance of contract with abi and address\n const accounts = await web3.eth.getAccounts();\n const res = await extraMaticContract.methods.getUserReferralTotalBonus(accounts[0]).call()//get total staked money value\n let contact_balance = web3.utils.fromWei(res)\n return contact_balance \n \n } catch (e) {\n return false;\n }\n}\n\nexport const web3_referred_users = async () => {\n const web3 = await getWeb3();\n if (!web3) {\n console.log(\"No web3 instance found.\");\n return false;\n }\n try {\n let extraMaticContract = new Contract(contractAbi, \"0x2a2cf93bc92537a596e7956315ce914186d0242f\" );//create instance of contract with abi and address\n const accounts = await web3.eth.getAccounts();\n const res = await extraMaticContract.methods.getUserTotalReferrals(accounts[0]).call()//get total staked money value\n // let contact_balance = web3.utils.fromWei(res)\n return res \n \n } catch (e) {\n return false;\n }\n}\n\nexport const web3_available_balance = async () => {\n const web3 = await getWeb3();\n if (!web3) {\n console.log(\"No web3 instance found.\");\n return false;\n }\n try {\n let extraMaticContract = new Contract(contractAbi, \"0x2a2cf93bc92537a596e7956315ce914186d0242f\" );//create instance of contract with abi and address\n const accounts = await web3.eth.getAccounts();\n const res = await extraMaticContract.methods.getUserAvailable(accounts[0]).call()//get total staked money value\n let contact_balance = web3.utils.fromWei(res)\n return contact_balance \n \n } catch (e) {\n return false;\n }\n}\n\nexport const stakeMATIC = async (referral_address , amount, planId) => {//stake amount of BNB to the planId's plan\n const web3 = await getWeb3();\n if (!web3) {\n toast.error(\"No web3 instance found.\");\n return false;\n }\n try {\n let connectedAddress = await connectToWallet();\n console.log(connectedAddress);\n let extraMaticContract = new Contract(contractAbi, \"0x2a2cf93bc92537a596e7956315ce914186d0242f\" );\n const txCount = await web3.eth.getTransactionCount(connectedAddress);\n console.log(referral_address);\n if(!referral_address)\n var referrer = \"0x2D19c11f66BE26Ba13333C428aD2050630B8176b\"\n else referrer = referral_address\n console.log(referrer);\n const myNewData = await extraMaticContract.methods.invest(referrer, planId).encodeABI()\n let weiPrice = web3.utils.toWei(`${amount}`, 'ether');\n const gas2 = await web3.eth.getGasPrice()\n const transactionParameters = {\n nonce: web3.utils.toHex(txCount),\n gasPrice: web3.utils.toHex(gas2),\n // gasLimit: web3.utils.toHex(gasLimit),\n to: \"0x2a2cf93bc92537a596e7956315ce914186d0242f\" ,\n from: connectedAddress,\n data: myNewData,\n value: web3.utils.toHex(weiPrice)\n }\n\n // As with any RPC call, it may throw an error\n const txHash = await window.ethereum.request({\n method: 'eth_sendTransaction',\n params: [transactionParameters],\n });\n \n if (txHash) {\n console.log(\"Transaction Done Successfully.\");\n }\n } catch (e) {\n toast.error(e.message);\n return false;\n }\n}\n\nexport const reinvest = async (planId) => {\n const web3 = await getWeb3();\n const amount = '0.1';\n var referrer = \"0x2D19c11f66BE26Ba13333C428aD2050630B8176b\"\n if (!web3) {\n toast.error(\"No web3 instance found.\");\n return false;\n }\n try {\n let connectedAddress = await connectToWallet();\n console.log(connectedAddress);\n let extraMaticContract = new Contract(contractAbi, \"0x2a2cf93bc92537a596e7956315ce914186d0242f\" );\n const txCount = await web3.eth.getTransactionCount(connectedAddress);\n const myNewData = await extraMaticContract.methods.reinvest(planId).encodeABI()\n console.log(myNewData);\n let weiPrice = web3.utils.toWei(`${amount}`, 'ether');\n const gas2 = await web3.eth.getGasPrice()\n const transactionParameters = {\n nonce: web3.utils.toHex(txCount),\n gasPrice: web3.utils.toHex(gas2),\n // gasLimit: web3.utils.toHex(gasLimit),\n to: \"0x2a2cf93bc92537a596e7956315ce914186d0242f\" ,\n from: connectedAddress,\n data: myNewData,\n // value: web3.utils.toHex(weiPrice)\n }\n\n // As with any RPC call, it may throw an error\n const txHash = await window.ethereum.request({\n method: 'eth_sendTransaction',\n params: [transactionParameters],\n });\n \n if (txHash) {\n console.log(\"Transaction Done Successfully.\");\n }\n } catch (e) {\n console.log(e.message);\n return false;\n }\n}\n\nexport const WithdrawFn = async () => {\n const web3 = await getWeb3();\n if (!web3) {\n toast.error(\"No web3 instance found.\");\n return false;\n }\n try {\n let connectedAddress = await connectToWallet();\n let extraMaticContract = new Contract(contractAbi, \"0x2a2cf93bc92537a596e7956315ce914186d0242f\" );\n const txCount = await web3.eth.getTransactionCount(connectedAddress);//get total trasaction count sent by current address\n const myNewData = await extraMaticContract.methods.withdraw().encodeABI()\n const gas2 = await web3.eth.getGasPrice()\n const transactionParameters = {\n nonce: web3.utils.toHex(txCount),\n gasPrice: web3.utils.toHex(gas2),\n // gasLimit: web3.utils.toHex(gasLimit),\n to: \"0x2a2cf93bc92537a596e7956315ce914186d0242f\",\n from: connectedAddress,\n data: myNewData,\n }\n // As with any RPC call, it may throw an error\n const txHash = await window.ethereum.request({\n method: 'eth_sendTransaction',\n params: [transactionParameters],\n });\n if (txHash) {\n toast.success(\"Transaction Done Successfully.\");\n return\n }\n } catch (e) {\n toast.error(e.message);\n return false;\n }\n}\n",{"ruleId":"23","severity":1,"message":"24","line":19,"column":10,"nodeType":"25","messageId":"26","endLine":19,"endColumn":26},{"ruleId":"23","severity":1,"message":"27","line":231,"column":9,"nodeType":"25","messageId":"26","endLine":231,"endColumn":17},{"ruleId":"23","severity":1,"message":"28","line":243,"column":13,"nodeType":"25","messageId":"26","endLine":243,"endColumn":21},"no-unused-vars","'referral_address' is assigned a value but never used.","Identifier","unusedVar","'referrer' is assigned a value but never used.","'weiPrice' is assigned a value but never used."]
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # production
12 | /build
13 |
14 | # misc
15 | .DS_Store
16 | .env.local
17 | .env.development.local
18 | .env.test.local
19 | .env.production.local
20 |
21 | npm-debug.log*
22 | yarn-debug.log*
23 | yarn-error.log*
24 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Getting Started with Create React App
2 |
3 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
4 |
5 | ## Available Scripts
6 |
7 | In the project directory, you can run:
8 |
9 | ### `npm start`
10 |
11 | Runs the app in the development mode.\
12 | Open [http://localhost:3000](http://localhost:3000) to view it in your browser.
13 |
14 | The page will reload when you make changes.\
15 | You may also see any lint errors in the console.
16 |
17 | ### `npm test`
18 |
19 | Launches the test runner in the interactive watch mode.\
20 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
21 |
22 | ### `npm run build`
23 |
24 | Builds the app for production to the `build` folder.\
25 | It correctly bundles React in production mode and optimizes the build for the best performance.
26 |
27 | The build is minified and the filenames include the hashes.\
28 | Your app is ready to be deployed!
29 |
30 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
31 |
32 | ### `npm run eject`
33 |
34 | **Note: this is a one-way operation. Once you `eject`, you can't go back!**
35 |
36 | If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
37 |
38 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.
39 |
40 | You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.
41 |
42 | ## Learn More
43 |
44 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
45 |
46 | To learn React, check out the [React documentation](https://reactjs.org/).
47 |
48 | ### Code Splitting
49 |
50 | This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
51 |
52 | ### Analyzing the Bundle Size
53 |
54 | This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
55 |
56 | ### Making a Progressive Web App
57 |
58 | This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
59 |
60 | ### Advanced Configuration
61 |
62 | This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
63 |
64 | ### Deployment
65 |
66 | This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
67 |
68 | ### `npm run build` fails to minify
69 |
70 | This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
71 |
--------------------------------------------------------------------------------
/contracts/MaticHeaven.sol:
--------------------------------------------------------------------------------
1 | /**
2 | *Submitted for verification at polygonscan.com on 2022-02-14
3 | */
4 |
5 | pragma solidity >=0.5.10;
6 |
7 | contract MaticHeaven {
8 | using SafeMath for uint256;
9 |
10 | uint256 constant public INVEST_MIN_AMOUNT = 0.1 ether;
11 | uint256 constant public WITHDRAW_MIN_AMOUNT = 1 ether;
12 | uint256[] public REFERRAL_PERCENTS = [50, 30, 10];
13 | uint256 constant public TOTAL_REF = 90;
14 | uint256 constant public DEV_FEE = 100;
15 | uint256 constant public REINVEST_DEV_FEE = 50;
16 | uint256 constant public REINVEST_ON_WITHDRAWAL = 200;
17 | uint256 constant public REINVEST_BONUS = 50;
18 | uint256 constant public PERCENTS_DIVIDER = 1000;
19 | uint256 constant public TIME_STEP = 1 days;
20 |
21 | uint256 public totalInvested;
22 | uint256 public totalReferral;
23 |
24 | struct Plan {
25 | uint256 time;
26 | uint256 percent;
27 | }
28 |
29 | Plan[] internal plans;
30 |
31 | struct Deposit {
32 | uint8 plan;
33 | uint256 amount;
34 | uint256 start;
35 | }
36 |
37 | struct User {
38 | Deposit[] deposits;
39 | uint256 checkpoint;
40 | address referrer;
41 | uint256[3] levels;
42 | uint256 bonus;
43 | uint256 totalBonus;
44 | uint256 withdrawn;
45 | }
46 |
47 | mapping (address => User) internal users;
48 |
49 | uint256 public startDate;
50 |
51 | address payable public devWallet;
52 |
53 | event Newbie(address user);
54 | event NewDeposit(address indexed user, uint8 plan, uint256 amount, uint256 time);
55 | event Withdrawn(address indexed user, uint256 amount, uint256 time);
56 | event RefBonus(address indexed referrer, address indexed referral, uint256 indexed level, uint256 amount);
57 | event FeePaid(address indexed user, uint256 totalAmount);
58 |
59 | constructor(address payable devAddr, uint256 start) public {
60 | require(!isContract(devAddr));
61 | devWallet = devAddr;
62 |
63 | if(start>0){
64 | startDate = start;
65 | }
66 | else{
67 | startDate = block.timestamp;
68 | }
69 |
70 | plans.push(Plan(8, 170));
71 | plans.push(Plan(60, 70));
72 | }
73 |
74 | function invest(address referrer, uint8 plan) public payable {
75 | require(block.timestamp > startDate, "contract does not launch yet");
76 | require(msg.value >= INVEST_MIN_AMOUNT, "invest min amount is not reached");
77 | require(plan < 2, "Invalid plan");
78 |
79 | User storage user = users[msg.sender];
80 | require(user.deposits.length < 100, "Max 100 deposits per address");
81 |
82 | uint256 dFee = msg.value.mul(DEV_FEE).div(PERCENTS_DIVIDER);
83 | devWallet.transfer(dFee);
84 | emit FeePaid(msg.sender, dFee);
85 |
86 | if (user.referrer == address(0)) {
87 | if (users[referrer].deposits.length > 0 && referrer != msg.sender) {
88 | user.referrer = referrer;
89 | }
90 |
91 | address upline = user.referrer;
92 | for (uint256 i = 0; i < 3; i++) {
93 | if (upline != address(0)) {
94 | users[upline].levels[i] = users[upline].levels[i].add(1);
95 | upline = users[upline].referrer;
96 | } else break;
97 | }
98 | }
99 |
100 | if (user.referrer != address(0)) {
101 | address upline = user.referrer;
102 | for (uint256 i = 0; i < 3; i++) {
103 | if (upline != address(0)) {
104 | uint256 amount = msg.value.mul(REFERRAL_PERCENTS[i]).div(PERCENTS_DIVIDER);
105 | users[upline].bonus = users[upline].bonus.add(amount);
106 | users[upline].totalBonus = users[upline].totalBonus.add(amount);
107 | totalReferral = totalReferral.add(amount);
108 | emit RefBonus(upline, msg.sender, i, amount);
109 | upline = users[upline].referrer;
110 | } else break;
111 | }
112 | }else{
113 | uint256 amount = msg.value.mul(TOTAL_REF).div(PERCENTS_DIVIDER);
114 | devWallet.transfer(amount);
115 | totalReferral = totalReferral.add(amount);
116 | }
117 | if (user.deposits.length == 0) {
118 | user.checkpoint = block.timestamp;
119 | emit Newbie(msg.sender);
120 | }
121 | user.deposits.push(Deposit(plan, msg.value, block.timestamp));
122 | totalInvested = totalInvested.add(msg.value);
123 | emit NewDeposit(msg.sender, plan, msg.value, block.timestamp);
124 | }
125 |
126 | function withdraw() public {
127 | User storage user = users[msg.sender];
128 | require(user.checkpoint.add(TIME_STEP) < block.timestamp, "only once a day");
129 | uint256 totalAmount = getUserDividends(msg.sender);
130 | uint256 referralBonus = getUserReferralBonus(msg.sender);
131 |
132 | if (referralBonus > 0) {
133 | user.bonus = 0;
134 | totalAmount = totalAmount.add(referralBonus);
135 | }
136 | uint256 contractBalance = address(this).balance;
137 | if (contractBalance < totalAmount) {
138 | user.bonus = totalAmount.sub(contractBalance);
139 | totalAmount = contractBalance;
140 | }
141 |
142 | require(totalAmount >= WITHDRAW_MIN_AMOUNT, "withdraw min amount is not reached");
143 |
144 | if(user.deposits.length < 100) {
145 | uint256 reinvest_amount = totalAmount.mul(REINVEST_ON_WITHDRAWAL).div(PERCENTS_DIVIDER);
146 | totalAmount = totalAmount.sub(reinvest_amount);
147 | reinvestOnWithdraw(1, reinvest_amount);
148 | }
149 |
150 | user.checkpoint = block.timestamp;
151 | user.withdrawn = user.withdrawn.add(totalAmount);
152 | msg.sender.transfer(totalAmount);
153 | emit Withdrawn(msg.sender, totalAmount, block.timestamp);
154 | }
155 |
156 | function reinvest(uint8 plan) public {
157 | User storage user = users[msg.sender];
158 | (uint256 totalAmount1, uint256 totalAmount2) = getUserDividendsOnReinvest(msg.sender);
159 | if( totalAmount2 > 0 && plan == 1){
160 | totalAmount2 = totalAmount2.add(totalAmount2.mul(REINVEST_BONUS).div(PERCENTS_DIVIDER));
161 | }
162 | uint256 totalAmount = totalAmount1.add(totalAmount2);
163 | uint256 referralBonus = getUserReferralBonus(msg.sender);
164 | if (referralBonus > 0) {
165 | user.bonus = 0;
166 | totalAmount = totalAmount.add(referralBonus);
167 | }
168 | require(block.timestamp > startDate, "contract does not launch yet");
169 | require(totalAmount >= INVEST_MIN_AMOUNT, "invest min amount is not reached");
170 | require(plan < 2, "Invalid plan");
171 | require(user.deposits.length < 100, "Max 100 deposits per address");
172 |
173 | uint256 reinvest_dFee = totalAmount.mul(REINVEST_DEV_FEE).div(PERCENTS_DIVIDER);
174 | devWallet.transfer(reinvest_dFee);
175 | emit FeePaid(msg.sender, reinvest_dFee);
176 |
177 | user.deposits.push(Deposit(plan, totalAmount, block.timestamp));
178 | totalInvested = totalInvested.add(totalAmount);
179 | user.checkpoint = block.timestamp;
180 | user.withdrawn = user.withdrawn.add(totalAmount);
181 | emit NewDeposit(msg.sender, plan, totalAmount, block.timestamp);
182 | }
183 |
184 | function reinvestOnWithdraw(uint8 plan, uint256 amount) private {
185 | User storage user = users[msg.sender];
186 | uint256 bonusAmount = amount.mul(REINVEST_BONUS).div(PERCENTS_DIVIDER);
187 | uint256 totalAmount = amount.add(bonusAmount);
188 |
189 | uint256 reinvest_dFee = totalAmount.mul(REINVEST_DEV_FEE).div(PERCENTS_DIVIDER);
190 | devWallet.transfer(reinvest_dFee);
191 | emit FeePaid(msg.sender, reinvest_dFee);
192 |
193 | user.deposits.push(Deposit(plan, totalAmount, block.timestamp));
194 | totalInvested = totalInvested.add(totalAmount);
195 | user.checkpoint = block.timestamp;
196 | user.withdrawn = user.withdrawn.add(totalAmount);
197 | emit NewDeposit(msg.sender, plan, totalAmount, block.timestamp);
198 | }
199 |
200 | function getContractBalance() public view returns (uint256) {
201 | return address(this).balance;
202 | }
203 |
204 | function getPlanInfo(uint8 plan) public view returns(uint256 time, uint256 percent) {
205 | time = plans[plan].time;
206 | percent = plans[plan].percent;
207 | }
208 |
209 | function getUserDividends(address userAddress) public view returns (uint256) {
210 | User storage user = users[userAddress];
211 | uint256 totalAmount;
212 | for (uint256 i = 0; i < user.deposits.length; i++) {
213 | uint256 finish = user.deposits[i].start.add(plans[user.deposits[i].plan].time.mul(TIME_STEP));
214 | if (user.checkpoint < finish) {
215 | uint256 share = user.deposits[i].amount.mul(plans[user.deposits[i].plan].percent).div(PERCENTS_DIVIDER);
216 | uint256 from = user.deposits[i].start > user.checkpoint ? user.deposits[i].start : user.checkpoint;
217 | uint256 to = finish < block.timestamp ? finish : block.timestamp;
218 | if (from < to) {
219 | totalAmount = totalAmount.add(share.mul(to.sub(from)).div(TIME_STEP));
220 | }
221 | }
222 | }
223 | return totalAmount;
224 | }
225 |
226 | function getUserDividendsOnReinvest(address userAddress) public view returns (uint256,uint256) {
227 | User storage user = users[userAddress];
228 | uint256 totalAmountPlan1;
229 | uint256 totalAmountPlan2;
230 | for (uint256 i = 0; i < user.deposits.length; i++) {
231 | uint256 finish = user.deposits[i].start.add(plans[user.deposits[i].plan].time.mul(TIME_STEP));
232 | if (user.checkpoint < finish) {
233 | uint256 share = user.deposits[i].amount.mul(plans[user.deposits[i].plan].percent).div(PERCENTS_DIVIDER);
234 | uint256 from = user.deposits[i].start > user.checkpoint ? user.deposits[i].start : user.checkpoint;
235 | uint256 to = finish < block.timestamp ? finish : block.timestamp;
236 | if (from < to) {
237 |
238 | if(user.deposits[i].plan == 0){
239 | totalAmountPlan1 = totalAmountPlan1.add(share.mul(to.sub(from)).div(TIME_STEP));
240 | } else if(user.deposits[i].plan == 1){
241 | totalAmountPlan2 = totalAmountPlan2.add(share.mul(to.sub(from)).div(TIME_STEP));
242 | }
243 | }
244 | }
245 | }
246 | return (totalAmountPlan1, totalAmountPlan2);
247 | }
248 |
249 | function getUserTotalWithdrawn(address userAddress) public view returns (uint256) {
250 | return users[userAddress].withdrawn;
251 | }
252 |
253 | function getUserCheckpoint(address userAddress) public view returns(uint256) {
254 | return users[userAddress].checkpoint;
255 | }
256 |
257 | function getUserReferrer(address userAddress) public view returns(address) {
258 | return users[userAddress].referrer;
259 | }
260 |
261 | function getUserDownlineCount(address userAddress) public view returns(uint256[3] memory referrals) {
262 | return (users[userAddress].levels);
263 | }
264 |
265 | function getUserTotalReferrals(address userAddress) public view returns(uint256) {
266 | return users[userAddress].levels[0]+users[userAddress].levels[1]+users[userAddress].levels[2];
267 | }
268 |
269 | function getUserReferralBonus(address userAddress) public view returns(uint256) {
270 | return users[userAddress].bonus;
271 | }
272 |
273 | function getUserReferralTotalBonus(address userAddress) public view returns(uint256) {
274 | return users[userAddress].totalBonus;
275 | }
276 |
277 | function getUserReferralWithdrawn(address userAddress) public view returns(uint256) {
278 | return users[userAddress].totalBonus.sub(users[userAddress].bonus);
279 | }
280 |
281 | function getUserAvailable(address userAddress) public view returns(uint256) {
282 | return getUserReferralBonus(userAddress).add(getUserDividends(userAddress));
283 | }
284 |
285 | function getUserAmountOfDeposits(address userAddress) public view returns(uint256) {
286 | return users[userAddress].deposits.length;
287 | }
288 |
289 | function getUserTotalDeposits(address userAddress) public view returns(uint256 amount) {
290 | for (uint256 i = 0; i < users[userAddress].deposits.length; i++) {
291 | amount = amount.add(users[userAddress].deposits[i].amount);
292 | }
293 | }
294 |
295 | function getUserDepositInfo(address userAddress, uint256 index) public view returns(uint8 plan, uint256 percent, uint256 amount, uint256 start, uint256 finish) {
296 | User storage user = users[userAddress];
297 |
298 | plan = user.deposits[index].plan;
299 | percent = plans[plan].percent;
300 | amount = user.deposits[index].amount;
301 | start = user.deposits[index].start;
302 | finish = user.deposits[index].start.add(plans[user.deposits[index].plan].time.mul(TIME_STEP));
303 | }
304 |
305 | function getSiteInfo() public view returns(uint256 _totalInvested, uint256 _totalBonus, uint256 _contractBalance) {
306 | return(totalInvested, totalReferral, getContractBalance());
307 | }
308 |
309 | function getUserInfo(address userAddress) public view returns(uint256 checkpoint, uint256 totalDeposit, uint256 totalWithdrawn, uint256 totalReferrals) {
310 | return(getUserCheckpoint(userAddress), getUserTotalDeposits(userAddress), getUserTotalWithdrawn(userAddress), getUserTotalReferrals(userAddress));
311 | }
312 |
313 | function isContract(address addr) internal view returns (bool) {
314 | uint size;
315 | assembly { size := extcodesize(addr) }
316 | return size > 0;
317 | }
318 | }
319 |
320 | library SafeMath {
321 |
322 | function add(uint256 a, uint256 b) internal pure returns (uint256) {
323 | uint256 c = a + b;
324 | require(c >= a, "SafeMath: addition overflow");
325 |
326 | return c;
327 | }
328 |
329 | function sub(uint256 a, uint256 b) internal pure returns (uint256) {
330 | require(b <= a, "SafeMath: subtraction overflow");
331 | uint256 c = a - b;
332 |
333 | return c;
334 | }
335 |
336 | function mul(uint256 a, uint256 b) internal pure returns (uint256) {
337 | if (a == 0) {
338 | return 0;
339 | }
340 |
341 | uint256 c = a * b;
342 | require(c / a == b, "SafeMath: multiplication overflow");
343 |
344 | return c;
345 | }
346 |
347 | function div(uint256 a, uint256 b) internal pure returns (uint256) {
348 | require(b > 0, "SafeMath: division by zero");
349 | uint256 c = a / b;
350 |
351 | return c;
352 | }
353 | }
--------------------------------------------------------------------------------
/contracts/Migrations.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 | pragma solidity >=0.4.22 <0.9.0;
3 |
4 | contract Migrations {
5 | address public owner = msg.sender;
6 | uint public last_completed_migration;
7 |
8 | modifier restricted() {
9 | require(
10 | msg.sender == owner,
11 | "This function is restricted to the contract's owner"
12 | );
13 | _;
14 | }
15 |
16 | function setCompleted(uint completed) public restricted {
17 | last_completed_migration = completed;
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/migrations/1_initial_migration.js:
--------------------------------------------------------------------------------
1 | const Migrations = artifacts.require("Migrations");
2 |
3 | module.exports = function (deployer) {
4 | deployer.deploy(Migrations);
5 | };
6 |
--------------------------------------------------------------------------------
/migrations/2_deploy_contracts.js:
--------------------------------------------------------------------------------
1 | var MaticHeaven = artifacts.require("./MaticHeaven.sol");
2 |
3 | module.exports = function(deployer) {
4 | deployer.deploy(MaticHeaven , 10000);
5 | };
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "polygon-matic",
3 | "homepage": "http://polygon.bestfuture.pl/",
4 | "version": "0.1.0",
5 | "main": "truffle-config.js",
6 | "directories": {
7 | "test": "test"
8 | },
9 | "private": true,
10 | "dependencies": {
11 | "@testing-library/jest-dom": "^5.16.1",
12 | "@testing-library/react": "^12.1.2",
13 | "@testing-library/user-event": "^13.5.0",
14 | "axios": "^0.24.0",
15 | "react": "^17.0.2",
16 | "react-dom": "^17.0.2",
17 | "react-scripts": "4.0.1",
18 | "react-toastify": "^8.1.0",
19 | "web-vitals": "^1.1.2",
20 | "web3": "^1.6.0",
21 | "chai": "^4.1.2",
22 | "chai-as-promised": "^7.1.1",
23 | "chai-bignumber": "^2.0.2",
24 | "lite-server": "^2.3.0",
25 | "nodemon": "^1.17.3",
26 | "truffle": "5.0.2",
27 | "truffle-contract": "3.0.6"
28 | },
29 | "resolve.fallback": {
30 | "crypto": false,
31 | "assert": false,
32 | "util": false,
33 | "http": false,
34 | "https": false,
35 | "os": false
36 | },
37 | "scripts": {
38 | "start": "react-scripts start",
39 | "build": "react-scripts build",
40 | "test": "react-scripts test",
41 | "eject": "react-scripts eject"
42 | },
43 | "eslintConfig": {
44 | "extends": [
45 | "react-app",
46 | "react-app/jest"
47 | ]
48 | },
49 | "browserslist": {
50 | "production": [
51 | ">0.2%",
52 | "not dead",
53 | "not op_mini all"
54 | ],
55 | "development": [
56 | "last 1 chrome version",
57 | "last 1 firefox version",
58 | "last 1 safari version"
59 | ]
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/public/.htaccess:
--------------------------------------------------------------------------------
1 |
2 |
3 | RewriteEngine On
4 | RewriteBase /
5 | RewriteRule ^index\.html$ - [L]
6 | RewriteCond %{REQUEST_FILENAME} !-f
7 | RewriteCond %{REQUEST_FILENAME} !-d
8 | RewriteCond %{REQUEST_FILENAME} !-l
9 | RewriteRule . /index.html [L]
10 |
11 |
--------------------------------------------------------------------------------
/public/PolygonLogo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/reactmaster223/polygon-staking-site/c8fa0d593e63467fe3e24e5ada4e430751a513b3/public/PolygonLogo.png
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/reactmaster223/polygon-staking-site/c8fa0d593e63467fe3e24e5ada4e430751a513b3/public/favicon.ico
--------------------------------------------------------------------------------
/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
12 |
13 |
17 |
18 |
19 |
20 |
29 | Extra Matic
30 |
31 |
32 |
33 |
34 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/public/logo192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/reactmaster223/polygon-staking-site/c8fa0d593e63467fe3e24e5ada4e430751a513b3/public/logo192.png
--------------------------------------------------------------------------------
/public/logo512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/reactmaster223/polygon-staking-site/c8fa0d593e63467fe3e24e5ada4e430751a513b3/public/logo512.png
--------------------------------------------------------------------------------
/public/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "short_name": "React App",
3 | "name": "Create React App Sample",
4 | "icons": [
5 | {
6 | "src": "PolygonLogo.png",
7 | "sizes": "64x64 32x32 24x24 16x16",
8 | "type": "image/x-icon"
9 | },
10 | {
11 | "src": "logo192.png",
12 | "type": "image/png",
13 | "sizes": "192x192"
14 | },
15 | {
16 | "src": "logo512.png",
17 | "type": "image/png",
18 | "sizes": "512x512"
19 | }
20 | ],
21 | "start_url": ".",
22 | "display": "standalone",
23 | "theme_color": "#000000",
24 | "background_color": "#ffffff"
25 | }
26 |
--------------------------------------------------------------------------------
/public/robots.txt:
--------------------------------------------------------------------------------
1 | # https://www.robotstxt.org/robotstxt.html
2 | User-agent: *
3 | Disallow:
4 |
--------------------------------------------------------------------------------
/src/App.css:
--------------------------------------------------------------------------------
1 | .App {
2 | text-align: center;
3 | width: 100%;
4 | }
5 | @font-face {
6 | font-family: Lilita One;
7 | src: url(../src/assets/LilitaOne-Regular.ttf);
8 | }
9 | .primary-header{
10 | background: #331684;
11 | box-shadow: 0px 6.71486px 10.6319px -3.917px rgba(0, 0, 0, 0.28);
12 | border-radius: 16.7871px 16.7871px 0px 0px;
13 | }
14 | .primary-title{
15 | font-family: 'Lilita One';
16 | font-style: normal;
17 | font-weight: 400;
18 | font-size: 26.8594px;
19 | line-height: 160%;
20 | align-items: center;
21 | text-align: center;
22 | color: #ECE8FF;
23 | margin: 10px 0px 10px 0px;
24 | }
25 | .primary-subtitle{
26 | font-family: 'Lilita One';
27 | font-style: normal;
28 | font-weight: 400;
29 | font-size: 20px;
30 | line-height: 140%;
31 | margin: 0px;
32 | margin-bottom: 10px;
33 | text-align: center;
34 | color: #ECE8FF;
35 | }
36 | .primary-content{
37 | font-family: 'Lilita One';
38 | font-style: normal;
39 | font-weight: 400;
40 | font-size: 16px;
41 | line-height: 160%;
42 | color: #FFFFFF;
43 | }
44 | .primary-body{
45 | background: #FFFFFF;
46 | box-shadow: 0px 10.2px 16.15px -5.95px rgba(0, 0, 0, 0.28);
47 | border-radius: 0px 0px 25.5px 25.5px;
48 | }
49 | .primary-background{
50 | background: #331684;
51 | border: none;
52 | height: 100%;
53 | }
54 | .secondary-title{
55 | font-family: 'Lilita One';
56 | font-style: normal;
57 | font-weight: 400;
58 | font-size: 32px;
59 | line-height: 160%;
60 | margin: 0px;
61 | margin-bottom: 10px;
62 | text-align: center;
63 | color: #331684;
64 | }
65 | .secondary-subtitle{
66 | font-family: 'Lilita One';
67 | font-style: normal;
68 | font-weight: 400;
69 | font-size: 24px;
70 | line-height: 140%;
71 | margin: 0px;
72 | margin-bottom: 10px;
73 | text-align: center;
74 | color: #331684;
75 | }
76 | .secondary-background{
77 | background: #6433C4;
78 | border-radius: 18px 18px 18px 18px;
79 |
80 | }
81 | .secondary-content{
82 | font-family: 'Lilita One';
83 | font-style: normal;
84 | font-weight: 400;
85 | font-size: 16px;
86 | line-height: 160%;
87 | text-align: center;
88 | color: #331684;
89 | }
90 | .pr-10{
91 | padding-right: 4rem;
92 | }
93 | .pl-10{
94 | padding-left: 4rem;
95 | }
96 | .custom-p-5{
97 | padding:3rem;
98 | }
99 | .custom-pr-10{
100 | padding-right: 4rem;
101 | }
102 | .custom-pl-10{
103 | padding-left: 4rem;
104 | }
105 | .show{
106 | display: block;
107 | }
108 | .hidden{
109 | display: none;
110 | }
111 | .reinvest_btn{
112 | margin-left: 5%;
113 | margin-right: 5%;
114 | }
115 | .container{
116 | margin: 0px;
117 | }
118 | .header-content{
119 | font-size: 35px!important;
120 | margin: 5rem 20rem 5rem 20rem;
121 | }
122 | @media only screen and (max-width: 1700px) {
123 | .header-content{
124 | font-size: 30px!important;
125 | margin: 5rem 15rem 5rem 15rem;
126 | }
127 | }
128 | @media only screen and (max-width: 1200px) {
129 | .header-content{
130 | font-size: 30px!important;
131 | margin: 5rem 15rem 5rem 15rem;
132 | }
133 | }
134 | @media only screen and (max-width: 990px) {
135 | .custom-pr-10{
136 | padding-right: 1rem;
137 | }
138 | .custom-pl-10{
139 | padding-left: 1rem;
140 | }
141 | .header-content{
142 | font-size: 28px!important;
143 | margin: 3rem 10rem 3rem 10rem;
144 | }
145 | }
146 | @media only screen and (max-width: 768px) {
147 | /* For mobile phones: */
148 | .custom-p-5 {
149 | padding: 1rem;
150 | }
151 | .custom-pr-10{
152 | padding-right: 1rem;
153 | }
154 | .custom-pl-10{
155 | padding-left: 1rem;
156 | }
157 | .header-content{
158 | font-size: 24px!important;
159 | margin: 3rem 5rem 3rem 5rem;
160 | }
161 | }
162 | .App-header {
163 | display: flex;
164 | flex-direction: column;
165 | align-items: center;
166 | justify-content: center;
167 | font-size: calc(10px + 2vmin);
168 | }
169 | .header-logo{
170 | height: 374px;
171 | width: 100%;
172 | justify-content: space-between!important;
173 | display: flex!important;
174 | }
175 | .mainpart-one{
176 | justify-content: center!important;
177 | display: flex!important;
178 | }
179 | @media only screen and (max-width: 768px) {
180 | .header-logo{
181 | height: 374px;
182 | width: 100%;
183 | justify-content: center!important;
184 | display: block!important;
185 | }
186 | }
187 | .contact-btn{
188 | width: 124px;
189 | height: 48px;
190 | background: #FFFFFF;
191 | border: 1px solid #A673EF;
192 | box-sizing: border-box;
193 | box-shadow: 5px 10px 10px rgba(0, 0, 0, 0.5);
194 | border-radius: 12px;
195 | margin: 0px 12px 12px 12px;
196 | font-family: 'Lilita One';
197 | font-size: 24px;
198 | line-height: 160%;
199 | color: #8247E5;
200 | }
201 | @media only screen and (max-width: 460px) {
202 | .mainpart-one{
203 | justify-content: center!important;
204 | display: block!important;
205 | }
206 | }
207 | .maintitle{
208 | font-size: 64px;
209 | }
210 | .connect-wallet{
211 | display: flex;
212 | flex-direction: row;
213 | justify-content: center;
214 | align-items: center;
215 | padding: 6px 12px;
216 | background: #FFFFFF;
217 | border: 1px solid #A673EF;
218 | box-sizing: border-box;
219 | box-shadow: 0px 1px 1px rgba(0, 0, 0, 0.08);
220 | border-radius: 6px;
221 | }
222 | .connect-wallet span{
223 | font-family: 'Lilita One';
224 | font-style: normal;
225 | font-weight: 400;
226 | font-size: 15.871px;
227 | line-height: 160%;
228 | color: #8247E5;
229 | flex: none;
230 | order: 0;
231 | flex-grow: 0;
232 | margin: 0px 5.29032px;
233 | }
234 | .App-link {
235 | color: #61dafb;
236 | }
237 | .header-content{
238 | font-family: 'Lilita One';
239 | font-style: normal;
240 | font-weight: 400;
241 | font-size: 24px;
242 | line-height: 160%;
243 | text-align: center;
244 | color: #331684;
245 | }
246 | main{
247 | width: 100%;
248 | left: 0px;
249 | top: 491px;
250 | background: radial-gradient(58.94% 58.94% at -4.47% 0%, rgba(1, 11, 243, 0.47) 0%, rgba(159, 1, 243, 0) 100%) /* warning: gradient uses a rotation that is not supported by CSS and may not behave as expected */, radial-gradient(38.77% 38.77% at 57.25% 61.23%, rgba(241, 0, 116, 0.43) 0%, rgba(196, 0, 241, 0) 100%) /* warning: gradient uses a rotation that is not supported by CSS and may not behave as expected */, linear-gradient(83.32deg, #9000E8 4.01%, #B601F6 94.76%);
251 | }
252 | .mainpart-one{
253 | padding-top: 19px;
254 | }
255 |
256 | .plan{
257 | width: 212px;
258 | }
259 | .plan-subpart{
260 | background: #FFFFFF;
261 | box-shadow: 0px 1.42761px 2.14141px rgba(0, 0, 0, 0.08);
262 | border-radius: 21.4141px;
263 | }
264 |
265 | .deposit-title{
266 |
267 | font-family: 'Lilita One';
268 | font-style: normal;
269 | font-weight: 400;
270 | font-size: 17.1313px;
271 | line-height: 160%;
272 | text-align: center;
273 | color: #331684;
274 |
275 | }
276 | #contract-balance{
277 |
278 | }
279 | #total-deposit{
280 |
281 | }
282 | .plan-deadline{
283 |
284 | background: #9000E8;
285 | }
286 | .plan-deadline p{
287 |
288 | font-family: 'Lilita One';
289 | font-style: normal;
290 | font-weight: 400;
291 | font-size: 21.4141px;
292 | line-height: 117%;
293 | text-align: center;
294 | color: #FFFFFF;
295 | }
296 | .plan-totalvalue{
297 |
298 | font-family: 'Lilita One';
299 | font-style: normal;
300 | font-weight: 400;
301 | font-size: 25.697px;
302 | line-height: 160%;
303 | text-align: center;
304 | color: #331684;
305 |
306 | }
307 | .plan-valueinput{
308 | position: static;
309 | background: #FFFFFF;
310 | border: 0.713805px solid #8247E5;
311 | box-sizing: border-box;
312 | box-shadow: 0px 2px 2px -1px rgba(0, 0, 0, 0.12), 0px 0px 0px 3px #DCD4FF;
313 | border-radius: 4.28283px;
314 | flex: none;
315 | order: 0;
316 | align-self: stretch;
317 | flex-grow: 0;
318 | width: 100%;
319 | height: 100%;
320 | margin: 4px 0px;
321 | }
322 | .deposit-btn{
323 | background: #9000E8;
324 | width: 100%;
325 | border-radius: 0px 0px 9.27946px 9.27946px;
326 | margin: 0;
327 | }
328 | .dashboard-content{
329 | border-radius: 0px 18px 18px 18px;
330 | }
331 |
332 | footer{
333 | background: #1A1A1A;
334 | border: 8px dashed #FFFFFF;
335 | box-sizing: border-box;
336 | }
337 | .footer-contact-btn{
338 | display: flex;
339 | justify-content: center;
340 | align-items: center;
341 | width: 220px;
342 | height: 48px;
343 | background: #FFFFFF;
344 | border: 1px solid #A673EF;
345 | box-sizing: border-box;
346 | box-shadow: 5px 10px 10px rgba(0, 0, 0, 0.5);
347 | border-radius: 12px;
348 | flex: none;
349 | font-family: 'Lilita One';
350 | font-style: normal;
351 | font-size: 24px;
352 | color: #8247E5;
353 | margin: 0px 10px 0px 10px;
354 | }
355 | .footer-part{
356 | justify-content: center!important;
357 | display: flex!important;
358 | }
359 | @media only screen and (max-width: 768px) {
360 | .footer-part{
361 | justify-content: center!important;
362 | display: block!important;
363 | }
364 | .footer-contact-btn{
365 | margin: auto;
366 | margin-top : 10px;
367 | margin-bottom: 10px;
368 | }
369 | }
--------------------------------------------------------------------------------
/src/App.js:
--------------------------------------------------------------------------------
1 | import React, {useEffect, useState} from "react";
2 | import headerback from './assets/header.png';
3 | import logo from './assets/PolygonLogo.png';
4 | import contactIcon from './assets/ClipboardText.png'
5 | import './App.css';
6 | import {connectToWallet, web3_contact_balance , web3_total_deposit , web3_user_deposit_count , web3_user_total_withdraw , web3_user_total_deposit , web3_user_referral_bonus , web3_available_balance , stakeMATIC, reinvest , WithdrawFn , web3_referred_users} from './utils/web3API'
7 |
8 | function App() {
9 | const [ walletAddress, setWalletAddress ] = useState("")
10 | const [contact_balance , setContactBalance ] = useState(0.000)
11 | const [total_deposit , setTotalDeposit] = useState(0)
12 | const [user_deposit_count , setUserDepositCount] = useState(0)
13 | const [user_total_deposit , setUserTotalDeposit] = useState(0.000)
14 | const [user_total_withdraw , setUserTotalWithdraw] = useState(0.000)
15 | const [user_referral_bonus , setUserReferralBonus] = useState(0.000)
16 | const [referred_user , setReferredUsers] = useState(0.000)
17 | const [amount_plan1, setAmountPlan1] = useState(0.000)
18 | const [amount_plan2, setAmountPlan2] = useState(0.000)
19 | const [referral_address, setReferralAddress] = useState("")
20 | const [reinvest_show , setReinvestShow] = useState("")
21 | const [available_balance , setAvailableBalance] = useState(0)
22 | // const reinvest_show = false
23 | useEffect(()=> {
24 |
25 | if(!walletAddress){
26 | walletConnect()
27 | getContactBalance()
28 | getTotalDeposit()
29 | getUserDepositCount()
30 | getUserTotalDeposit()
31 | getUserTotalWithdraw()
32 | getUserReferralBonus()
33 | getReferredUsers()
34 | getUserAvailableBalance()
35 | }
36 |
37 | // getUSDValue()
38 | })
39 |
40 | const walletConnect = async () => {
41 | const res = await connectToWallet()//connect to metamask
42 | setWalletAddress(res)//set wallet adderess as the res
43 | }
44 |
45 | const getContactBalance = async () => {//get Contract balance
46 | const res = await web3_contact_balance()
47 | setContactBalance(parseFloat(res).toFixed(4))
48 | }
49 | const getTotalDeposit = async () => {//get Total deposit
50 | const res = await web3_total_deposit()
51 | console.log(res)
52 | setTotalDeposit(parseFloat(res).toFixed(4))
53 | }
54 | const getUserDepositCount = async () => {//get User deposit count
55 | const res = await web3_user_deposit_count()
56 | setUserDepositCount(res)
57 | }
58 | const getUserTotalDeposit = async () => {//get user total deposit
59 | const res = await web3_user_total_deposit()
60 | setUserTotalDeposit(parseFloat(res).toFixed(4))
61 | }
62 | const getUserTotalWithdraw = async () => {//get user total withdraw
63 | const res = await web3_user_total_withdraw()
64 | setUserTotalWithdraw(parseFloat(res).toFixed(4))
65 | }
66 | const getUserReferralBonus = async () => {//get user referral bonus
67 | const res = await web3_user_referral_bonus()
68 | setUserReferralBonus(res)
69 | }
70 | const getReferredUsers = async () => {//get referred users
71 | const res = await web3_referred_users()
72 | setReferredUsers(res)
73 | }
74 | const getUserAvailableBalance = async () => {
75 | const res = await web3_available_balance()
76 | setAvailableBalance(parseFloat(res).toFixed(4))
77 | }
78 |
79 | const formattedAddress = () => {
80 | if(walletAddress) {
81 | return `${walletAddress.slice(0,5)}...${walletAddress.slice(-5)}`
82 | }
83 | }
84 | const callStakePlan1 = async () => {
85 | var ref_add = document.getElementById('wallet_address').value
86 | const res = await stakeMATIC(ref_add , amount_plan1, 0)
87 | return res
88 | }
89 | const callStakePlan2 = async () => {
90 | var ref_add = document.getElementById('wallet_address').value
91 | const res = await stakeMATIC(ref_add , amount_plan2, 1)
92 | return res
93 | }
94 | const Reinvest_show = () => {
95 | if(reinvest_show === false)
96 | setReinvestShow(true)
97 | else setReinvestShow(false)
98 | console.log(reinvest_show)
99 | }
100 | const Reinvest = async (plan) => {
101 | const res = await reinvest(plan)
102 | return res
103 | }
104 | const Withdraw = async () => {
105 | const res = await WithdrawFn()
106 | return res
107 | }
108 | const PasteWalletAddress = async() => {
109 | const text = await navigator.clipboard.readText();
110 | console.log(text)
111 | document.getElementById('wallet_address').value = text
112 | }
113 |
114 | // const ipfsClient = require("ipfs-http-client");
115 | // const ipfs = ipfsClient({
116 | // host: "ipfs.infura.io",
117 | // port: 5001,
118 | // protocol: "https",
119 | // });
120 |
121 | return (
122 |
123 |
148 |
149 |
150 |
153 |
156 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 | {contact_balance}
168 |
169 |
170 | Contract Balance
171 |
172 |
173 |
174 |
175 |
176 |
177 | {total_deposit}
178 |
179 |
180 | Total Deposit
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 | Plan 1
190 |
191 |
192 |
193 |
194 |
195 | 17% daily
for 8 days
196 |
197 |
198 |
199 | total 136%
200 |
201 |
202 | {setAmountPlan1(e.target.value)}}>
203 |
204 |
205 |
206 |
207 |
210 |
211 |
212 | Minimum deposit 0.1 Matic
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 | Plan 2
221 |
222 |
223 |
224 |
225 |
226 | 7% daily
for 60 days
227 |
228 |
229 |
230 | total 420%
231 |
232 |
{setAmountPlan2(e.target.value)}}>
233 |
234 |
235 |
236 |
239 |
240 |
241 | Minimum deposit 0.1 Matic
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 | Personal Dashboard
254 |
255 |
256 |
257 |
258 |
259 |
260 |
261 |
{available_balance}
262 |
Available Balance
263 |
264 |
265 |
266 |
267 |
270 |
271 |
272 |
275 |
278 |
279 |
280 |
283 |
284 |
285 |
286 |

287 |
288 |
289 |
290 |
291 |
- Minimum reinvest 0.1 MATIC, Get 5% reinvest bonus on 60 days plan.
292 |
293 | - Minimum withdrawal 1 MATIC, and 20% of each withdrawal will be converted to auto reinvest on 60 days plan with 5% reinvest bonus
294 |
295 |
296 |
297 |
298 |
299 |
300 |
{user_deposit_count}
301 |
Deposit Count
302 |
303 |
304 |
305 |
306 |
{user_total_deposit}
307 |
Total Deposit
308 |
309 |
310 |
311 |
312 |
313 |
314 |
{user_total_withdraw}
315 |
Total Withdraw
316 |
317 |
318 |
319 |
320 |
{user_referral_bonus}
321 |
Total Referral Bonus
322 |
323 |
324 |
325 |
326 |
327 |
328 |
329 | Referral
330 |
331 |
332 |
333 |
level 1 = 5%
334 |
level 2 = 3%
335 |
level 3 = 1%
336 |
337 |
338 |
339 |
340 |
341 |
342 |
343 | Your Deposits
344 |
345 |
346 |
349 |
350 |
351 |
352 |
353 | Your Referral Link
354 |
355 |
356 |
357 |
358 |
359 | {setReferralAddress(e.target.value)}}>
360 |
361 |
362 |
363 |
364 |
365 |
366 |
367 |
368 |
{referred_user}
369 |
Referred Users
370 |
371 |
372 |
373 |
374 |
375 |
376 |
396 |
397 | );
398 | }
399 |
400 | export default App;
401 |
--------------------------------------------------------------------------------
/src/App.test.js:
--------------------------------------------------------------------------------
1 | import { render, screen } from '@testing-library/react';
2 | import App from './App';
3 |
4 | test('renders learn react link', () => {
5 | render();
6 | const linkElement = screen.getByText(/learn react/i);
7 | expect(linkElement).toBeInTheDocument();
8 | });
9 |
--------------------------------------------------------------------------------
/src/assets/ClipboardText.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/reactmaster223/polygon-staking-site/c8fa0d593e63467fe3e24e5ada4e430751a513b3/src/assets/ClipboardText.png
--------------------------------------------------------------------------------
/src/assets/Extra Matic (1).zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/reactmaster223/polygon-staking-site/c8fa0d593e63467fe3e24e5ada4e430751a513b3/src/assets/Extra Matic (1).zip
--------------------------------------------------------------------------------
/src/assets/LilitaOne-Regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/reactmaster223/polygon-staking-site/c8fa0d593e63467fe3e24e5ada4e430751a513b3/src/assets/LilitaOne-Regular.ttf
--------------------------------------------------------------------------------
/src/assets/PolygonLogo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/reactmaster223/polygon-staking-site/c8fa0d593e63467fe3e24e5ada4e430751a513b3/src/assets/PolygonLogo.png
--------------------------------------------------------------------------------
/src/assets/contract.sol:
--------------------------------------------------------------------------------
1 | /**
2 | *Submitted for verification at polygonscan.com on 2022-02-14
3 | */
4 |
5 | pragma solidity 0.5.10;
6 |
7 | contract MaticHeaven {
8 | using SafeMath for uint256;
9 |
10 | uint256 constant public INVEST_MIN_AMOUNT = 0.1 ether;
11 | uint256 constant public WITHDRAW_MIN_AMOUNT = 1 ether;
12 | uint256[] public REFERRAL_PERCENTS = [50, 30, 10];
13 | uint256 constant public TOTAL_REF = 90;
14 | uint256 constant public DEV_FEE = 100;
15 | uint256 constant public REINVEST_DEV_FEE = 50;
16 | uint256 constant public REINVEST_ON_WITHDRAWAL = 200;
17 | uint256 constant public REINVEST_BONUS = 50;
18 | uint256 constant public PERCENTS_DIVIDER = 1000;
19 | uint256 constant public TIME_STEP = 1 days;
20 |
21 | uint256 public totalInvested;
22 | uint256 public totalReferral;
23 |
24 | struct Plan {
25 | uint256 time;
26 | uint256 percent;
27 | }
28 |
29 | Plan[] internal plans;
30 |
31 | struct Deposit {
32 | uint8 plan;
33 | uint256 amount;
34 | uint256 start;
35 | }
36 |
37 | struct User {
38 | Deposit[] deposits;
39 | uint256 checkpoint;
40 | address referrer;
41 | uint256[3] levels;
42 | uint256 bonus;
43 | uint256 totalBonus;
44 | uint256 withdrawn;
45 | }
46 |
47 | mapping (address => User) internal users;
48 |
49 | uint256 public startDate;
50 |
51 | address payable public devWallet;
52 |
53 | event Newbie(address user);
54 | event NewDeposit(address indexed user, uint8 plan, uint256 amount, uint256 time);
55 | event Withdrawn(address indexed user, uint256 amount, uint256 time);
56 | event RefBonus(address indexed referrer, address indexed referral, uint256 indexed level, uint256 amount);
57 | event FeePaid(address indexed user, uint256 totalAmount);
58 |
59 | constructor(address payable devAddr, uint256 start) public {
60 | require(!isContract(devAddr));
61 | devWallet = devAddr;
62 |
63 | if(start>0){
64 | startDate = start;
65 | }
66 | else{
67 | startDate = block.timestamp;
68 | }
69 |
70 | plans.push(Plan(8, 170));
71 | plans.push(Plan(60, 70));
72 | }
73 |
74 | function invest(address referrer, uint8 plan) public payable {
75 | require(block.timestamp > startDate, "contract does not launch yet");
76 | require(msg.value >= INVEST_MIN_AMOUNT, "invest min amount is not reached");
77 | require(plan < 2, "Invalid plan");
78 |
79 | User storage user = users[msg.sender];
80 | require(user.deposits.length < 100, "Max 100 deposits per address");
81 |
82 | uint256 dFee = msg.value.mul(DEV_FEE).div(PERCENTS_DIVIDER);
83 | devWallet.transfer(dFee);
84 | emit FeePaid(msg.sender, dFee);
85 |
86 | if (user.referrer == address(0)) {
87 | if (users[referrer].deposits.length > 0 && referrer != msg.sender) {
88 | user.referrer = referrer;
89 | }
90 |
91 | address upline = user.referrer;
92 | for (uint256 i = 0; i < 3; i++) {
93 | if (upline != address(0)) {
94 | users[upline].levels[i] = users[upline].levels[i].add(1);
95 | upline = users[upline].referrer;
96 | } else break;
97 | }
98 | }
99 |
100 | if (user.referrer != address(0)) {
101 | address upline = user.referrer;
102 | for (uint256 i = 0; i < 3; i++) {
103 | if (upline != address(0)) {
104 | uint256 amount = msg.value.mul(REFERRAL_PERCENTS[i]).div(PERCENTS_DIVIDER);
105 | users[upline].bonus = users[upline].bonus.add(amount);
106 | users[upline].totalBonus = users[upline].totalBonus.add(amount);
107 | totalReferral = totalReferral.add(amount);
108 | emit RefBonus(upline, msg.sender, i, amount);
109 | upline = users[upline].referrer;
110 | } else break;
111 | }
112 | }else{
113 | uint256 amount = msg.value.mul(TOTAL_REF).div(PERCENTS_DIVIDER);
114 | devWallet.transfer(amount);
115 | totalReferral = totalReferral.add(amount);
116 | }
117 | if (user.deposits.length == 0) {
118 | user.checkpoint = block.timestamp;
119 | emit Newbie(msg.sender);
120 | }
121 | user.deposits.push(Deposit(plan, msg.value, block.timestamp));
122 | totalInvested = totalInvested.add(msg.value);
123 | emit NewDeposit(msg.sender, plan, msg.value, block.timestamp);
124 | }
125 |
126 | function withdraw() public {
127 | User storage user = users[msg.sender];
128 | require(user.checkpoint.add(TIME_STEP) < block.timestamp, "only once a day");
129 | uint256 totalAmount = getUserDividends(msg.sender);
130 | uint256 referralBonus = getUserReferralBonus(msg.sender);
131 |
132 | if (referralBonus > 0) {
133 | user.bonus = 0;
134 | totalAmount = totalAmount.add(referralBonus);
135 | }
136 | uint256 contractBalance = address(this).balance;
137 | if (contractBalance < totalAmount) {
138 | user.bonus = totalAmount.sub(contractBalance);
139 | totalAmount = contractBalance;
140 | }
141 |
142 | require(totalAmount >= WITHDRAW_MIN_AMOUNT, "withdraw min amount is not reached");
143 |
144 | if(user.deposits.length < 100) {
145 | uint256 reinvest_amount = totalAmount.mul(REINVEST_ON_WITHDRAWAL).div(PERCENTS_DIVIDER);
146 | totalAmount = totalAmount.sub(reinvest_amount);
147 | reinvestOnWithdraw(1, reinvest_amount);
148 | }
149 |
150 | user.checkpoint = block.timestamp;
151 | user.withdrawn = user.withdrawn.add(totalAmount);
152 | msg.sender.transfer(totalAmount);
153 | emit Withdrawn(msg.sender, totalAmount, block.timestamp);
154 | }
155 |
156 | function reinvest(uint8 plan) public {
157 | User storage user = users[msg.sender];
158 | (uint256 totalAmount1, uint256 totalAmount2) = getUserDividendsOnReinvest(msg.sender);
159 | if( totalAmount2 > 0 && plan == 1){
160 | totalAmount2 = totalAmount2.add(totalAmount2.mul(REINVEST_BONUS).div(PERCENTS_DIVIDER));
161 | }
162 | uint256 totalAmount = totalAmount1.add(totalAmount2);
163 | uint256 referralBonus = getUserReferralBonus(msg.sender);
164 | if (referralBonus > 0) {
165 | user.bonus = 0;
166 | totalAmount = totalAmount.add(referralBonus);
167 | }
168 | require(block.timestamp > startDate, "contract does not launch yet");
169 | require(totalAmount >= INVEST_MIN_AMOUNT, "invest min amount is not reached");
170 | require(plan < 2, "Invalid plan");
171 | require(user.deposits.length < 100, "Max 100 deposits per address");
172 |
173 | uint256 reinvest_dFee = totalAmount.mul(REINVEST_DEV_FEE).div(PERCENTS_DIVIDER);
174 | devWallet.transfer(reinvest_dFee);
175 | emit FeePaid(msg.sender, reinvest_dFee);
176 |
177 | user.deposits.push(Deposit(plan, totalAmount, block.timestamp));
178 | totalInvested = totalInvested.add(totalAmount);
179 | user.checkpoint = block.timestamp;
180 | user.withdrawn = user.withdrawn.add(totalAmount);
181 | emit NewDeposit(msg.sender, plan, totalAmount, block.timestamp);
182 | }
183 |
184 | function reinvestOnWithdraw(uint8 plan, uint256 amount) private {
185 | User storage user = users[msg.sender];
186 | uint256 bonusAmount = amount.mul(REINVEST_BONUS).div(PERCENTS_DIVIDER);
187 | uint256 totalAmount = amount.add(bonusAmount);
188 |
189 | uint256 reinvest_dFee = totalAmount.mul(REINVEST_DEV_FEE).div(PERCENTS_DIVIDER);
190 | devWallet.transfer(reinvest_dFee);
191 | emit FeePaid(msg.sender, reinvest_dFee);
192 |
193 | user.deposits.push(Deposit(plan, totalAmount, block.timestamp));
194 | totalInvested = totalInvested.add(totalAmount);
195 | user.checkpoint = block.timestamp;
196 | user.withdrawn = user.withdrawn.add(totalAmount);
197 | emit NewDeposit(msg.sender, plan, totalAmount, block.timestamp);
198 | }
199 |
200 | function getContractBalance() public view returns (uint256) {
201 | return address(this).balance;
202 | }
203 |
204 | function getPlanInfo(uint8 plan) public view returns(uint256 time, uint256 percent) {
205 | time = plans[plan].time;
206 | percent = plans[plan].percent;
207 | }
208 |
209 | function getUserDividends(address userAddress) public view returns (uint256) {
210 | User storage user = users[userAddress];
211 | uint256 totalAmount;
212 | for (uint256 i = 0; i < user.deposits.length; i++) {
213 | uint256 finish = user.deposits[i].start.add(plans[user.deposits[i].plan].time.mul(TIME_STEP));
214 | if (user.checkpoint < finish) {
215 | uint256 share = user.deposits[i].amount.mul(plans[user.deposits[i].plan].percent).div(PERCENTS_DIVIDER);
216 | uint256 from = user.deposits[i].start > user.checkpoint ? user.deposits[i].start : user.checkpoint;
217 | uint256 to = finish < block.timestamp ? finish : block.timestamp;
218 | if (from < to) {
219 | totalAmount = totalAmount.add(share.mul(to.sub(from)).div(TIME_STEP));
220 | }
221 | }
222 | }
223 | return totalAmount;
224 | }
225 |
226 | function getUserDividendsOnReinvest(address userAddress) public view returns (uint256,uint256) {
227 | User storage user = users[userAddress];
228 | uint256 totalAmountPlan1;
229 | uint256 totalAmountPlan2;
230 | for (uint256 i = 0; i < user.deposits.length; i++) {
231 | uint256 finish = user.deposits[i].start.add(plans[user.deposits[i].plan].time.mul(TIME_STEP));
232 | if (user.checkpoint < finish) {
233 | uint256 share = user.deposits[i].amount.mul(plans[user.deposits[i].plan].percent).div(PERCENTS_DIVIDER);
234 | uint256 from = user.deposits[i].start > user.checkpoint ? user.deposits[i].start : user.checkpoint;
235 | uint256 to = finish < block.timestamp ? finish : block.timestamp;
236 | if (from < to) {
237 |
238 | if(user.deposits[i].plan == 0){
239 | totalAmountPlan1 = totalAmountPlan1.add(share.mul(to.sub(from)).div(TIME_STEP));
240 | } else if(user.deposits[i].plan == 1){
241 | totalAmountPlan2 = totalAmountPlan2.add(share.mul(to.sub(from)).div(TIME_STEP));
242 | }
243 | }
244 | }
245 | }
246 | return (totalAmountPlan1, totalAmountPlan2);
247 | }
248 |
249 | function getUserTotalWithdrawn(address userAddress) public view returns (uint256) {
250 | return users[userAddress].withdrawn;
251 | }
252 |
253 | function getUserCheckpoint(address userAddress) public view returns(uint256) {
254 | return users[userAddress].checkpoint;
255 | }
256 |
257 | function getUserReferrer(address userAddress) public view returns(address) {
258 | return users[userAddress].referrer;
259 | }
260 |
261 | function getUserDownlineCount(address userAddress) public view returns(uint256[3] memory referrals) {
262 | return (users[userAddress].levels);
263 | }
264 |
265 | function getUserTotalReferrals(address userAddress) public view returns(uint256) {
266 | return users[userAddress].levels[0]+users[userAddress].levels[1]+users[userAddress].levels[2];
267 | }
268 |
269 | function getUserReferralBonus(address userAddress) public view returns(uint256) {
270 | return users[userAddress].bonus;
271 | }
272 |
273 | function getUserReferralTotalBonus(address userAddress) public view returns(uint256) {
274 | return users[userAddress].totalBonus;
275 | }
276 |
277 | function getUserReferralWithdrawn(address userAddress) public view returns(uint256) {
278 | return users[userAddress].totalBonus.sub(users[userAddress].bonus);
279 | }
280 |
281 | function getUserAvailable(address userAddress) public view returns(uint256) {
282 | return getUserReferralBonus(userAddress).add(getUserDividends(userAddress));
283 | }
284 |
285 | function getUserAmountOfDeposits(address userAddress) public view returns(uint256) {
286 | return users[userAddress].deposits.length;
287 | }
288 |
289 | function getUserTotalDeposits(address userAddress) public view returns(uint256 amount) {
290 | for (uint256 i = 0; i < users[userAddress].deposits.length; i++) {
291 | amount = amount.add(users[userAddress].deposits[i].amount);
292 | }
293 | }
294 |
295 | function getUserDepositInfo(address userAddress, uint256 index) public view returns(uint8 plan, uint256 percent, uint256 amount, uint256 start, uint256 finish) {
296 | User storage user = users[userAddress];
297 |
298 | plan = user.deposits[index].plan;
299 | percent = plans[plan].percent;
300 | amount = user.deposits[index].amount;
301 | start = user.deposits[index].start;
302 | finish = user.deposits[index].start.add(plans[user.deposits[index].plan].time.mul(TIME_STEP));
303 | }
304 |
305 | function getSiteInfo() public view returns(uint256 _totalInvested, uint256 _totalBonus, uint256 _contractBalance) {
306 | return(totalInvested, totalReferral, getContractBalance());
307 | }
308 |
309 | function getUserInfo(address userAddress) public view returns(uint256 checkpoint, uint256 totalDeposit, uint256 totalWithdrawn, uint256 totalReferrals) {
310 | return(getUserCheckpoint(userAddress), getUserTotalDeposits(userAddress), getUserTotalWithdrawn(userAddress), getUserTotalReferrals(userAddress));
311 | }
312 |
313 | function isContract(address addr) internal view returns (bool) {
314 | uint size;
315 | assembly { size := extcodesize(addr) }
316 | return size > 0;
317 | }
318 | }
319 |
320 | library SafeMath {
321 |
322 | function add(uint256 a, uint256 b) internal pure returns (uint256) {
323 | uint256 c = a + b;
324 | require(c >= a, "SafeMath: addition overflow");
325 |
326 | return c;
327 | }
328 |
329 | function sub(uint256 a, uint256 b) internal pure returns (uint256) {
330 | require(b <= a, "SafeMath: subtraction overflow");
331 | uint256 c = a - b;
332 |
333 | return c;
334 | }
335 |
336 | function mul(uint256 a, uint256 b) internal pure returns (uint256) {
337 | if (a == 0) {
338 | return 0;
339 | }
340 |
341 | uint256 c = a * b;
342 | require(c / a == b, "SafeMath: multiplication overflow");
343 |
344 | return c;
345 | }
346 |
347 | function div(uint256 a, uint256 b) internal pure returns (uint256) {
348 | require(b > 0, "SafeMath: division by zero");
349 | uint256 c = a / b;
350 |
351 | return c;
352 | }
353 | }
--------------------------------------------------------------------------------
/src/assets/header.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/reactmaster223/polygon-staking-site/c8fa0d593e63467fe3e24e5ada4e430751a513b3/src/assets/header.png
--------------------------------------------------------------------------------
/src/config/abi.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "constant": true,
4 | "inputs": [],
5 | "name": "PERCENTS_DIVIDER",
6 | "outputs": [
7 | {
8 | "name": "",
9 | "type": "uint256"
10 | }
11 | ],
12 | "payable": false,
13 | "stateMutability": "view",
14 | "type": "function"
15 | },
16 | {
17 | "constant": true,
18 | "inputs": [
19 | {
20 | "name": "userAddress",
21 | "type": "address"
22 | }
23 | ],
24 | "name": "getUserDownlineCount",
25 | "outputs": [
26 | {
27 | "name": "referrals",
28 | "type": "uint256[3]"
29 | }
30 | ],
31 | "payable": false,
32 | "stateMutability": "view",
33 | "type": "function"
34 | },
35 | {
36 | "constant": true,
37 | "inputs": [
38 | {
39 | "name": "userAddress",
40 | "type": "address"
41 | }
42 | ],
43 | "name": "getUserDividends",
44 | "outputs": [
45 | {
46 | "name": "",
47 | "type": "uint256"
48 | }
49 | ],
50 | "payable": false,
51 | "stateMutability": "view",
52 | "type": "function"
53 | },
54 | {
55 | "constant": true,
56 | "inputs": [],
57 | "name": "startDate",
58 | "outputs": [
59 | {
60 | "name": "",
61 | "type": "uint256"
62 | }
63 | ],
64 | "payable": false,
65 | "stateMutability": "view",
66 | "type": "function"
67 | },
68 | {
69 | "constant": true,
70 | "inputs": [],
71 | "name": "REINVEST_DEV_FEE",
72 | "outputs": [
73 | {
74 | "name": "",
75 | "type": "uint256"
76 | }
77 | ],
78 | "payable": false,
79 | "stateMutability": "view",
80 | "type": "function"
81 | },
82 | {
83 | "constant": true,
84 | "inputs": [
85 | {
86 | "name": "userAddress",
87 | "type": "address"
88 | }
89 | ],
90 | "name": "getUserAvailable",
91 | "outputs": [
92 | {
93 | "name": "",
94 | "type": "uint256"
95 | }
96 | ],
97 | "payable": false,
98 | "stateMutability": "view",
99 | "type": "function"
100 | },
101 | {
102 | "constant": true,
103 | "inputs": [
104 | {
105 | "name": "userAddress",
106 | "type": "address"
107 | }
108 | ],
109 | "name": "getUserDividendsOnReinvest",
110 | "outputs": [
111 | {
112 | "name": "",
113 | "type": "uint256"
114 | },
115 | {
116 | "name": "",
117 | "type": "uint256"
118 | }
119 | ],
120 | "payable": false,
121 | "stateMutability": "view",
122 | "type": "function"
123 | },
124 | {
125 | "constant": true,
126 | "inputs": [],
127 | "name": "totalReferral",
128 | "outputs": [
129 | {
130 | "name": "",
131 | "type": "uint256"
132 | }
133 | ],
134 | "payable": false,
135 | "stateMutability": "view",
136 | "type": "function"
137 | },
138 | {
139 | "constant": true,
140 | "inputs": [],
141 | "name": "WITHDRAW_MIN_AMOUNT",
142 | "outputs": [
143 | {
144 | "name": "",
145 | "type": "uint256"
146 | }
147 | ],
148 | "payable": false,
149 | "stateMutability": "view",
150 | "type": "function"
151 | },
152 | {
153 | "constant": true,
154 | "inputs": [],
155 | "name": "TIME_STEP",
156 | "outputs": [
157 | {
158 | "name": "",
159 | "type": "uint256"
160 | }
161 | ],
162 | "payable": false,
163 | "stateMutability": "view",
164 | "type": "function"
165 | },
166 | {
167 | "constant": true,
168 | "inputs": [
169 | {
170 | "name": "userAddress",
171 | "type": "address"
172 | }
173 | ],
174 | "name": "getUserReferrer",
175 | "outputs": [
176 | {
177 | "name": "",
178 | "type": "address"
179 | }
180 | ],
181 | "payable": false,
182 | "stateMutability": "view",
183 | "type": "function"
184 | },
185 | {
186 | "constant": false,
187 | "inputs": [],
188 | "name": "withdraw",
189 | "outputs": [],
190 | "payable": false,
191 | "stateMutability": "nonpayable",
192 | "type": "function"
193 | },
194 | {
195 | "constant": true,
196 | "inputs": [],
197 | "name": "DEV_FEE",
198 | "outputs": [
199 | {
200 | "name": "",
201 | "type": "uint256"
202 | }
203 | ],
204 | "payable": false,
205 | "stateMutability": "view",
206 | "type": "function"
207 | },
208 | {
209 | "constant": false,
210 | "inputs": [
211 | {
212 | "name": "plan",
213 | "type": "uint8"
214 | }
215 | ],
216 | "name": "reinvest",
217 | "outputs": [],
218 | "payable": false,
219 | "stateMutability": "nonpayable",
220 | "type": "function"
221 | },
222 | {
223 | "constant": true,
224 | "inputs": [],
225 | "name": "REINVEST_BONUS",
226 | "outputs": [
227 | {
228 | "name": "",
229 | "type": "uint256"
230 | }
231 | ],
232 | "payable": false,
233 | "stateMutability": "view",
234 | "type": "function"
235 | },
236 | {
237 | "constant": true,
238 | "inputs": [
239 | {
240 | "name": "userAddress",
241 | "type": "address"
242 | }
243 | ],
244 | "name": "getUserReferralTotalBonus",
245 | "outputs": [
246 | {
247 | "name": "",
248 | "type": "uint256"
249 | }
250 | ],
251 | "payable": false,
252 | "stateMutability": "view",
253 | "type": "function"
254 | },
255 | {
256 | "constant": true,
257 | "inputs": [],
258 | "name": "TOTAL_REF",
259 | "outputs": [
260 | {
261 | "name": "",
262 | "type": "uint256"
263 | }
264 | ],
265 | "payable": false,
266 | "stateMutability": "view",
267 | "type": "function"
268 | },
269 | {
270 | "constant": true,
271 | "inputs": [],
272 | "name": "getSiteInfo",
273 | "outputs": [
274 | {
275 | "name": "_totalInvested",
276 | "type": "uint256"
277 | },
278 | {
279 | "name": "_totalBonus",
280 | "type": "uint256"
281 | },
282 | {
283 | "name": "_contractBalance",
284 | "type": "uint256"
285 | }
286 | ],
287 | "payable": false,
288 | "stateMutability": "view",
289 | "type": "function"
290 | },
291 | {
292 | "constant": true,
293 | "inputs": [],
294 | "name": "totalInvested",
295 | "outputs": [
296 | {
297 | "name": "",
298 | "type": "uint256"
299 | }
300 | ],
301 | "payable": false,
302 | "stateMutability": "view",
303 | "type": "function"
304 | },
305 | {
306 | "constant": false,
307 | "inputs": [
308 | {
309 | "name": "referrer",
310 | "type": "address"
311 | },
312 | {
313 | "name": "plan",
314 | "type": "uint8"
315 | }
316 | ],
317 | "name": "invest",
318 | "outputs": [],
319 | "payable": true,
320 | "stateMutability": "payable",
321 | "type": "function"
322 | },
323 | {
324 | "constant": true,
325 | "inputs": [
326 | {
327 | "name": "",
328 | "type": "uint256"
329 | }
330 | ],
331 | "name": "REFERRAL_PERCENTS",
332 | "outputs": [
333 | {
334 | "name": "",
335 | "type": "uint256"
336 | }
337 | ],
338 | "payable": false,
339 | "stateMutability": "view",
340 | "type": "function"
341 | },
342 | {
343 | "constant": true,
344 | "inputs": [
345 | {
346 | "name": "userAddress",
347 | "type": "address"
348 | }
349 | ],
350 | "name": "getUserInfo",
351 | "outputs": [
352 | {
353 | "name": "checkpoint",
354 | "type": "uint256"
355 | },
356 | {
357 | "name": "totalDeposit",
358 | "type": "uint256"
359 | },
360 | {
361 | "name": "totalWithdrawn",
362 | "type": "uint256"
363 | },
364 | {
365 | "name": "totalReferrals",
366 | "type": "uint256"
367 | }
368 | ],
369 | "payable": false,
370 | "stateMutability": "view",
371 | "type": "function"
372 | },
373 | {
374 | "constant": true,
375 | "inputs": [
376 | {
377 | "name": "userAddress",
378 | "type": "address"
379 | }
380 | ],
381 | "name": "getUserReferralWithdrawn",
382 | "outputs": [
383 | {
384 | "name": "",
385 | "type": "uint256"
386 | }
387 | ],
388 | "payable": false,
389 | "stateMutability": "view",
390 | "type": "function"
391 | },
392 | {
393 | "constant": true,
394 | "inputs": [],
395 | "name": "getContractBalance",
396 | "outputs": [
397 | {
398 | "name": "",
399 | "type": "uint256"
400 | }
401 | ],
402 | "payable": false,
403 | "stateMutability": "view",
404 | "type": "function"
405 | },
406 | {
407 | "constant": true,
408 | "inputs": [
409 | {
410 | "name": "userAddress",
411 | "type": "address"
412 | }
413 | ],
414 | "name": "getUserTotalDeposits",
415 | "outputs": [
416 | {
417 | "name": "amount",
418 | "type": "uint256"
419 | }
420 | ],
421 | "payable": false,
422 | "stateMutability": "view",
423 | "type": "function"
424 | },
425 | {
426 | "constant": true,
427 | "inputs": [],
428 | "name": "devWallet",
429 | "outputs": [
430 | {
431 | "name": "",
432 | "type": "address"
433 | }
434 | ],
435 | "payable": false,
436 | "stateMutability": "view",
437 | "type": "function"
438 | },
439 | {
440 | "constant": true,
441 | "inputs": [
442 | {
443 | "name": "userAddress",
444 | "type": "address"
445 | }
446 | ],
447 | "name": "getUserAmountOfDeposits",
448 | "outputs": [
449 | {
450 | "name": "",
451 | "type": "uint256"
452 | }
453 | ],
454 | "payable": false,
455 | "stateMutability": "view",
456 | "type": "function"
457 | },
458 | {
459 | "constant": true,
460 | "inputs": [
461 | {
462 | "name": "plan",
463 | "type": "uint8"
464 | }
465 | ],
466 | "name": "getPlanInfo",
467 | "outputs": [
468 | {
469 | "name": "time",
470 | "type": "uint256"
471 | },
472 | {
473 | "name": "percent",
474 | "type": "uint256"
475 | }
476 | ],
477 | "payable": false,
478 | "stateMutability": "view",
479 | "type": "function"
480 | },
481 | {
482 | "constant": true,
483 | "inputs": [],
484 | "name": "REINVEST_ON_WITHDRAWAL",
485 | "outputs": [
486 | {
487 | "name": "",
488 | "type": "uint256"
489 | }
490 | ],
491 | "payable": false,
492 | "stateMutability": "view",
493 | "type": "function"
494 | },
495 | {
496 | "constant": true,
497 | "inputs": [
498 | {
499 | "name": "userAddress",
500 | "type": "address"
501 | },
502 | {
503 | "name": "index",
504 | "type": "uint256"
505 | }
506 | ],
507 | "name": "getUserDepositInfo",
508 | "outputs": [
509 | {
510 | "name": "plan",
511 | "type": "uint8"
512 | },
513 | {
514 | "name": "percent",
515 | "type": "uint256"
516 | },
517 | {
518 | "name": "amount",
519 | "type": "uint256"
520 | },
521 | {
522 | "name": "start",
523 | "type": "uint256"
524 | },
525 | {
526 | "name": "finish",
527 | "type": "uint256"
528 | }
529 | ],
530 | "payable": false,
531 | "stateMutability": "view",
532 | "type": "function"
533 | },
534 | {
535 | "constant": true,
536 | "inputs": [
537 | {
538 | "name": "userAddress",
539 | "type": "address"
540 | }
541 | ],
542 | "name": "getUserCheckpoint",
543 | "outputs": [
544 | {
545 | "name": "",
546 | "type": "uint256"
547 | }
548 | ],
549 | "payable": false,
550 | "stateMutability": "view",
551 | "type": "function"
552 | },
553 | {
554 | "constant": true,
555 | "inputs": [],
556 | "name": "INVEST_MIN_AMOUNT",
557 | "outputs": [
558 | {
559 | "name": "",
560 | "type": "uint256"
561 | }
562 | ],
563 | "payable": false,
564 | "stateMutability": "view",
565 | "type": "function"
566 | },
567 | {
568 | "constant": true,
569 | "inputs": [
570 | {
571 | "name": "userAddress",
572 | "type": "address"
573 | }
574 | ],
575 | "name": "getUserReferralBonus",
576 | "outputs": [
577 | {
578 | "name": "",
579 | "type": "uint256"
580 | }
581 | ],
582 | "payable": false,
583 | "stateMutability": "view",
584 | "type": "function"
585 | },
586 | {
587 | "constant": true,
588 | "inputs": [
589 | {
590 | "name": "userAddress",
591 | "type": "address"
592 | }
593 | ],
594 | "name": "getUserTotalWithdrawn",
595 | "outputs": [
596 | {
597 | "name": "",
598 | "type": "uint256"
599 | }
600 | ],
601 | "payable": false,
602 | "stateMutability": "view",
603 | "type": "function"
604 | },
605 | {
606 | "constant": true,
607 | "inputs": [
608 | {
609 | "name": "userAddress",
610 | "type": "address"
611 | }
612 | ],
613 | "name": "getUserTotalReferrals",
614 | "outputs": [
615 | {
616 | "name": "",
617 | "type": "uint256"
618 | }
619 | ],
620 | "payable": false,
621 | "stateMutability": "view",
622 | "type": "function"
623 | },
624 | {
625 | "inputs": [
626 | {
627 | "name": "devAddr",
628 | "type": "address"
629 | },
630 | {
631 | "name": "start",
632 | "type": "uint256"
633 | }
634 | ],
635 | "payable": false,
636 | "stateMutability": "nonpayable",
637 | "type": "constructor"
638 | },
639 | {
640 | "anonymous": false,
641 | "inputs": [
642 | {
643 | "indexed": false,
644 | "name": "user",
645 | "type": "address"
646 | }
647 | ],
648 | "name": "Newbie",
649 | "type": "event"
650 | },
651 | {
652 | "anonymous": false,
653 | "inputs": [
654 | {
655 | "indexed": true,
656 | "name": "user",
657 | "type": "address"
658 | },
659 | {
660 | "indexed": false,
661 | "name": "plan",
662 | "type": "uint8"
663 | },
664 | {
665 | "indexed": false,
666 | "name": "amount",
667 | "type": "uint256"
668 | },
669 | {
670 | "indexed": false,
671 | "name": "time",
672 | "type": "uint256"
673 | }
674 | ],
675 | "name": "NewDeposit",
676 | "type": "event"
677 | },
678 | {
679 | "anonymous": false,
680 | "inputs": [
681 | {
682 | "indexed": true,
683 | "name": "user",
684 | "type": "address"
685 | },
686 | {
687 | "indexed": false,
688 | "name": "amount",
689 | "type": "uint256"
690 | },
691 | {
692 | "indexed": false,
693 | "name": "time",
694 | "type": "uint256"
695 | }
696 | ],
697 | "name": "Withdrawn",
698 | "type": "event"
699 | },
700 | {
701 | "anonymous": false,
702 | "inputs": [
703 | {
704 | "indexed": true,
705 | "name": "referrer",
706 | "type": "address"
707 | },
708 | {
709 | "indexed": true,
710 | "name": "referral",
711 | "type": "address"
712 | },
713 | {
714 | "indexed": true,
715 | "name": "level",
716 | "type": "uint256"
717 | },
718 | {
719 | "indexed": false,
720 | "name": "amount",
721 | "type": "uint256"
722 | }
723 | ],
724 | "name": "RefBonus",
725 | "type": "event"
726 | },
727 | {
728 | "anonymous": false,
729 | "inputs": [
730 | {
731 | "indexed": true,
732 | "name": "user",
733 | "type": "address"
734 | },
735 | {
736 | "indexed": false,
737 | "name": "totalAmount",
738 | "type": "uint256"
739 | }
740 | ],
741 | "name": "FeePaid",
742 | "type": "event"
743 | }
744 | ]
--------------------------------------------------------------------------------
/src/config/new.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "inputs": [
4 | {
5 | "internalType": "address payable",
6 | "name": "wallet",
7 | "type": "address"
8 | }
9 | ],
10 | "stateMutability": "nonpayable",
11 | "type": "constructor"
12 | },
13 | {
14 | "anonymous": false,
15 | "inputs": [
16 | {
17 | "indexed": true,
18 | "internalType": "address",
19 | "name": "user",
20 | "type": "address"
21 | },
22 | {
23 | "indexed": false,
24 | "internalType": "uint256",
25 | "name": "totalAmount",
26 | "type": "uint256"
27 | }
28 | ],
29 | "name": "FeePayed",
30 | "type": "event"
31 | },
32 | {
33 | "anonymous": false,
34 | "inputs": [
35 | {
36 | "indexed": true,
37 | "internalType": "address",
38 | "name": "user",
39 | "type": "address"
40 | },
41 | {
42 | "indexed": false,
43 | "internalType": "uint8",
44 | "name": "plan",
45 | "type": "uint8"
46 | },
47 | {
48 | "indexed": false,
49 | "internalType": "uint256",
50 | "name": "percent",
51 | "type": "uint256"
52 | },
53 | {
54 | "indexed": false,
55 | "internalType": "uint256",
56 | "name": "amount",
57 | "type": "uint256"
58 | },
59 | {
60 | "indexed": false,
61 | "internalType": "uint256",
62 | "name": "profit",
63 | "type": "uint256"
64 | },
65 | {
66 | "indexed": false,
67 | "internalType": "uint256",
68 | "name": "start",
69 | "type": "uint256"
70 | },
71 | {
72 | "indexed": false,
73 | "internalType": "uint256",
74 | "name": "finish",
75 | "type": "uint256"
76 | }
77 | ],
78 | "name": "NewDeposit",
79 | "type": "event"
80 | },
81 | {
82 | "anonymous": false,
83 | "inputs": [
84 | {
85 | "indexed": false,
86 | "internalType": "address",
87 | "name": "user",
88 | "type": "address"
89 | }
90 | ],
91 | "name": "Newbie",
92 | "type": "event"
93 | },
94 | {
95 | "anonymous": false,
96 | "inputs": [
97 | {
98 | "indexed": true,
99 | "internalType": "address",
100 | "name": "referrer",
101 | "type": "address"
102 | },
103 | {
104 | "indexed": true,
105 | "internalType": "address",
106 | "name": "referral",
107 | "type": "address"
108 | },
109 | {
110 | "indexed": true,
111 | "internalType": "uint256",
112 | "name": "level",
113 | "type": "uint256"
114 | },
115 | {
116 | "indexed": false,
117 | "internalType": "uint256",
118 | "name": "amount",
119 | "type": "uint256"
120 | }
121 | ],
122 | "name": "RefBonus",
123 | "type": "event"
124 | },
125 | {
126 | "anonymous": false,
127 | "inputs": [
128 | {
129 | "indexed": true,
130 | "internalType": "address",
131 | "name": "user",
132 | "type": "address"
133 | },
134 | {
135 | "indexed": false,
136 | "internalType": "uint256",
137 | "name": "amount",
138 | "type": "uint256"
139 | }
140 | ],
141 | "name": "Withdrawn",
142 | "type": "event"
143 | },
144 | {
145 | "inputs": [],
146 | "name": "INVEST_MIN_AMOUNT",
147 | "outputs": [
148 | {
149 | "internalType": "uint256",
150 | "name": "",
151 | "type": "uint256"
152 | }
153 | ],
154 | "stateMutability": "view",
155 | "type": "function"
156 | },
157 | {
158 | "inputs": [],
159 | "name": "LAUNCH_TIME",
160 | "outputs": [
161 | {
162 | "internalType": "uint256",
163 | "name": "",
164 | "type": "uint256"
165 | }
166 | ],
167 | "stateMutability": "view",
168 | "type": "function"
169 | },
170 | {
171 | "inputs": [],
172 | "name": "PERCENTS_DIVIDER",
173 | "outputs": [
174 | {
175 | "internalType": "uint256",
176 | "name": "",
177 | "type": "uint256"
178 | }
179 | ],
180 | "stateMutability": "view",
181 | "type": "function"
182 | },
183 | {
184 | "inputs": [],
185 | "name": "PERCENT_STEP",
186 | "outputs": [
187 | {
188 | "internalType": "uint256",
189 | "name": "",
190 | "type": "uint256"
191 | }
192 | ],
193 | "stateMutability": "view",
194 | "type": "function"
195 | },
196 | {
197 | "inputs": [],
198 | "name": "PROJECT_FEE",
199 | "outputs": [
200 | {
201 | "internalType": "uint256",
202 | "name": "",
203 | "type": "uint256"
204 | }
205 | ],
206 | "stateMutability": "view",
207 | "type": "function"
208 | },
209 | {
210 | "inputs": [
211 | {
212 | "internalType": "uint256",
213 | "name": "",
214 | "type": "uint256"
215 | }
216 | ],
217 | "name": "REFERRAL_PERCENTS",
218 | "outputs": [
219 | {
220 | "internalType": "uint256",
221 | "name": "",
222 | "type": "uint256"
223 | }
224 | ],
225 | "stateMutability": "view",
226 | "type": "function"
227 | },
228 | {
229 | "inputs": [],
230 | "name": "TIME_STEP",
231 | "outputs": [
232 | {
233 | "internalType": "uint256",
234 | "name": "",
235 | "type": "uint256"
236 | }
237 | ],
238 | "stateMutability": "view",
239 | "type": "function"
240 | },
241 | {
242 | "inputs": [],
243 | "name": "commissionWallet",
244 | "outputs": [
245 | {
246 | "internalType": "address payable",
247 | "name": "",
248 | "type": "address"
249 | }
250 | ],
251 | "stateMutability": "view",
252 | "type": "function"
253 | },
254 | {
255 | "inputs": [],
256 | "name": "getChainID",
257 | "outputs": [
258 | {
259 | "internalType": "uint256",
260 | "name": "",
261 | "type": "uint256"
262 | }
263 | ],
264 | "stateMutability": "pure",
265 | "type": "function"
266 | },
267 | {
268 | "inputs": [],
269 | "name": "getContractBalance",
270 | "outputs": [
271 | {
272 | "internalType": "uint256",
273 | "name": "",
274 | "type": "uint256"
275 | }
276 | ],
277 | "stateMutability": "view",
278 | "type": "function"
279 | },
280 | {
281 | "inputs": [
282 | {
283 | "internalType": "uint8",
284 | "name": "plan",
285 | "type": "uint8"
286 | }
287 | ],
288 | "name": "getPercent",
289 | "outputs": [
290 | {
291 | "internalType": "uint256",
292 | "name": "",
293 | "type": "uint256"
294 | }
295 | ],
296 | "stateMutability": "view",
297 | "type": "function"
298 | },
299 | {
300 | "inputs": [
301 | {
302 | "internalType": "uint8",
303 | "name": "plan",
304 | "type": "uint8"
305 | }
306 | ],
307 | "name": "getPlanInfo",
308 | "outputs": [
309 | {
310 | "internalType": "uint256",
311 | "name": "time",
312 | "type": "uint256"
313 | },
314 | {
315 | "internalType": "uint256",
316 | "name": "percent",
317 | "type": "uint256"
318 | }
319 | ],
320 | "stateMutability": "view",
321 | "type": "function"
322 | },
323 | {
324 | "inputs": [
325 | {
326 | "internalType": "uint8",
327 | "name": "plan",
328 | "type": "uint8"
329 | },
330 | {
331 | "internalType": "uint256",
332 | "name": "deposit",
333 | "type": "uint256"
334 | }
335 | ],
336 | "name": "getResult",
337 | "outputs": [
338 | {
339 | "internalType": "uint256",
340 | "name": "percent",
341 | "type": "uint256"
342 | },
343 | {
344 | "internalType": "uint256",
345 | "name": "profit",
346 | "type": "uint256"
347 | },
348 | {
349 | "internalType": "uint256",
350 | "name": "finish",
351 | "type": "uint256"
352 | }
353 | ],
354 | "stateMutability": "view",
355 | "type": "function"
356 | },
357 | {
358 | "inputs": [
359 | {
360 | "internalType": "address",
361 | "name": "userAddress",
362 | "type": "address"
363 | }
364 | ],
365 | "name": "getUserAmountOfDeposits",
366 | "outputs": [
367 | {
368 | "internalType": "uint256",
369 | "name": "",
370 | "type": "uint256"
371 | }
372 | ],
373 | "stateMutability": "view",
374 | "type": "function"
375 | },
376 | {
377 | "inputs": [
378 | {
379 | "internalType": "address",
380 | "name": "userAddress",
381 | "type": "address"
382 | }
383 | ],
384 | "name": "getUserAvailable",
385 | "outputs": [
386 | {
387 | "internalType": "uint256",
388 | "name": "",
389 | "type": "uint256"
390 | }
391 | ],
392 | "stateMutability": "view",
393 | "type": "function"
394 | },
395 | {
396 | "inputs": [
397 | {
398 | "internalType": "address",
399 | "name": "userAddress",
400 | "type": "address"
401 | }
402 | ],
403 | "name": "getUserCheckpoint",
404 | "outputs": [
405 | {
406 | "internalType": "uint256",
407 | "name": "",
408 | "type": "uint256"
409 | }
410 | ],
411 | "stateMutability": "view",
412 | "type": "function"
413 | },
414 | {
415 | "inputs": [
416 | {
417 | "internalType": "address",
418 | "name": "userAddress",
419 | "type": "address"
420 | },
421 | {
422 | "internalType": "uint256",
423 | "name": "index",
424 | "type": "uint256"
425 | }
426 | ],
427 | "name": "getUserDepositInfo",
428 | "outputs": [
429 | {
430 | "internalType": "uint8",
431 | "name": "plan",
432 | "type": "uint8"
433 | },
434 | {
435 | "internalType": "uint256",
436 | "name": "percent",
437 | "type": "uint256"
438 | },
439 | {
440 | "internalType": "uint256",
441 | "name": "amount",
442 | "type": "uint256"
443 | },
444 | {
445 | "internalType": "uint256",
446 | "name": "profit",
447 | "type": "uint256"
448 | },
449 | {
450 | "internalType": "uint256",
451 | "name": "start",
452 | "type": "uint256"
453 | },
454 | {
455 | "internalType": "uint256",
456 | "name": "finish",
457 | "type": "uint256"
458 | }
459 | ],
460 | "stateMutability": "view",
461 | "type": "function"
462 | },
463 | {
464 | "inputs": [
465 | {
466 | "internalType": "address",
467 | "name": "userAddress",
468 | "type": "address"
469 | }
470 | ],
471 | "name": "getUserDividends",
472 | "outputs": [
473 | {
474 | "internalType": "uint256",
475 | "name": "",
476 | "type": "uint256"
477 | }
478 | ],
479 | "stateMutability": "view",
480 | "type": "function"
481 | },
482 | {
483 | "inputs": [
484 | {
485 | "internalType": "address",
486 | "name": "userAddress",
487 | "type": "address"
488 | }
489 | ],
490 | "name": "getUserDownlineCount",
491 | "outputs": [
492 | {
493 | "internalType": "uint256",
494 | "name": "",
495 | "type": "uint256"
496 | },
497 | {
498 | "internalType": "uint256",
499 | "name": "",
500 | "type": "uint256"
501 | },
502 | {
503 | "internalType": "uint256",
504 | "name": "",
505 | "type": "uint256"
506 | }
507 | ],
508 | "stateMutability": "view",
509 | "type": "function"
510 | },
511 | {
512 | "inputs": [
513 | {
514 | "internalType": "address",
515 | "name": "userAddress",
516 | "type": "address"
517 | }
518 | ],
519 | "name": "getUserReferralBonus",
520 | "outputs": [
521 | {
522 | "internalType": "uint256",
523 | "name": "",
524 | "type": "uint256"
525 | }
526 | ],
527 | "stateMutability": "view",
528 | "type": "function"
529 | },
530 | {
531 | "inputs": [
532 | {
533 | "internalType": "address",
534 | "name": "userAddress",
535 | "type": "address"
536 | }
537 | ],
538 | "name": "getUserReferralTotalBonus",
539 | "outputs": [
540 | {
541 | "internalType": "uint256",
542 | "name": "",
543 | "type": "uint256"
544 | }
545 | ],
546 | "stateMutability": "view",
547 | "type": "function"
548 | },
549 | {
550 | "inputs": [
551 | {
552 | "internalType": "address",
553 | "name": "userAddress",
554 | "type": "address"
555 | }
556 | ],
557 | "name": "getUserReferralWithdrawn",
558 | "outputs": [
559 | {
560 | "internalType": "uint256",
561 | "name": "",
562 | "type": "uint256"
563 | }
564 | ],
565 | "stateMutability": "view",
566 | "type": "function"
567 | },
568 | {
569 | "inputs": [
570 | {
571 | "internalType": "address",
572 | "name": "userAddress",
573 | "type": "address"
574 | }
575 | ],
576 | "name": "getUserReferrer",
577 | "outputs": [
578 | {
579 | "internalType": "address",
580 | "name": "",
581 | "type": "address"
582 | }
583 | ],
584 | "stateMutability": "view",
585 | "type": "function"
586 | },
587 | {
588 | "inputs": [
589 | {
590 | "internalType": "address",
591 | "name": "userAddress",
592 | "type": "address"
593 | }
594 | ],
595 | "name": "getUserTotalDeposits",
596 | "outputs": [
597 | {
598 | "internalType": "uint256",
599 | "name": "amount",
600 | "type": "uint256"
601 | }
602 | ],
603 | "stateMutability": "view",
604 | "type": "function"
605 | },
606 | {
607 | "inputs": [
608 | {
609 | "internalType": "address",
610 | "name": "to",
611 | "type": "address"
612 | }
613 | ],
614 | "name": "invest",
615 | "outputs": [],
616 | "stateMutability": "payable",
617 | "type": "function"
618 | },
619 | {
620 | "inputs": [
621 | {
622 | "internalType": "address",
623 | "name": "referrer",
624 | "type": "address"
625 | },
626 | {
627 | "internalType": "uint8",
628 | "name": "plan",
629 | "type": "uint8"
630 | }
631 | ],
632 | "name": "invest",
633 | "outputs": [],
634 | "stateMutability": "payable",
635 | "type": "function"
636 | },
637 | {
638 | "inputs": [],
639 | "name": "invest",
640 | "outputs": [],
641 | "stateMutability": "payable",
642 | "type": "function"
643 | },
644 | {
645 | "inputs": [],
646 | "name": "totalRefBonus",
647 | "outputs": [
648 | {
649 | "internalType": "uint256",
650 | "name": "",
651 | "type": "uint256"
652 | }
653 | ],
654 | "stateMutability": "view",
655 | "type": "function"
656 | },
657 | {
658 | "inputs": [],
659 | "name": "totalStaked",
660 | "outputs": [
661 | {
662 | "internalType": "uint256",
663 | "name": "",
664 | "type": "uint256"
665 | }
666 | ],
667 | "stateMutability": "view",
668 | "type": "function"
669 | },
670 | {
671 | "inputs": [],
672 | "name": "withdraw",
673 | "outputs": [],
674 | "stateMutability": "nonpayable",
675 | "type": "function"
676 | }
677 | ]
--------------------------------------------------------------------------------
/src/index.css:
--------------------------------------------------------------------------------
1 | body {
2 | margin: 0;
3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
5 | sans-serif;
6 | -webkit-font-smoothing: antialiased;
7 | -moz-osx-font-smoothing: grayscale;
8 | }
9 |
10 | code {
11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
12 | monospace;
13 | }
14 |
--------------------------------------------------------------------------------
/src/index.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom';
3 | import './index.css';
4 | import App from './App';
5 | import reportWebVitals from './reportWebVitals';
6 |
7 | ReactDOM.render(
8 |
9 |
10 | ,
11 | document.getElementById('root')
12 | );
13 |
14 | // If you want to start measuring performance in your app, pass a function
15 | // to log results (for example: reportWebVitals(console.log))
16 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
17 | reportWebVitals();
18 |
--------------------------------------------------------------------------------
/src/logo.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/reportWebVitals.js:
--------------------------------------------------------------------------------
1 | const reportWebVitals = onPerfEntry => {
2 | if (onPerfEntry && onPerfEntry instanceof Function) {
3 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
4 | getCLS(onPerfEntry);
5 | getFID(onPerfEntry);
6 | getFCP(onPerfEntry);
7 | getLCP(onPerfEntry);
8 | getTTFB(onPerfEntry);
9 | });
10 | }
11 | };
12 |
13 | export default reportWebVitals;
14 |
--------------------------------------------------------------------------------
/src/setupTests.js:
--------------------------------------------------------------------------------
1 | // jest-dom adds custom jest matchers for asserting on DOM nodes.
2 | // allows you to do things like:
3 | // expect(element).toHaveTextContent(/react/i)
4 | // learn more: https://github.com/testing-library/jest-dom
5 | import '@testing-library/jest-dom';
6 |
--------------------------------------------------------------------------------
/src/utils/web3API.js:
--------------------------------------------------------------------------------
1 | import Web3 from 'web3'
2 | import contractAbi from '../config/abi.json'
3 | import { toast } from 'react-toastify';
4 |
5 | let Contract = require("web3-eth-contract");
6 | Contract.setProvider("https://rpc-mainnet.maticvigil.com")
7 | export const connectToWallet = async () => {//connect the metamask using web3 and get current user account
8 | let web3;
9 | try {
10 | if (window.ethereum) {
11 | web3 = new Web3(window.ethereum)
12 | await window.ethereum.request({ method: 'eth_requestAccounts' })
13 | } else if (window.web3) {
14 | web3 = new Web3(window.web3.currentProvider || "https://rpc-mainnet.maticvigil.com")
15 | }
16 | const accounts = await web3.eth.getAccounts();
17 | return accounts[0]
18 | } catch (error) {
19 | // console.log("Error: ", error)
20 | return false
21 | }
22 | }
23 |
24 | export const getWeb3 = async () => {//first connect the EVM and return web3 instance. always use!
25 | let web3;
26 | if (window.ethereum) {
27 | web3 = new Web3(window.ethereum);
28 | } else if (window.web3) {
29 | await window.web3.currentProvider.enable();
30 | web3 = new Web3(window.web3.currentProvider);
31 | } else {
32 | console.log('No web3 instance detected.');
33 | return false;
34 | }
35 | return web3;
36 | }
37 |
38 | export const web3_contact_balance = async () => {
39 | const web3 = await getWeb3();
40 | if (!web3) {
41 | console.log("No web3 instance found.");
42 | return false;
43 | }
44 | try {
45 | let extraMaticContract = new Contract(contractAbi, "0x2a2cf93bc92537a596e7956315ce914186d0242f" );//create instance of contract with abi and address
46 | const res = await extraMaticContract.methods.getSiteInfo().call()
47 | let contact_balance = web3.utils.fromWei(res['_contractBalance'])
48 | // console.log("contract_balance" + res['_contractBalance'])
49 | return contact_balance
50 |
51 | } catch (e) {
52 | console.log("failed")
53 | return false;
54 | }
55 | }
56 |
57 | export const web3_total_deposit = async () => {
58 | const web3 = await getWeb3();
59 | if (!web3) {
60 | toast.error("No web3 instance found.");
61 | return false;
62 | }
63 | try {
64 | let extraMaticContract = new Contract(contractAbi, "0x2a2cf93bc92537a596e7956315ce914186d0242f" );//create instance of contract with abi and address
65 | const res = await extraMaticContract.methods.getSiteInfo().call()//get total staked money value
66 | let total_deposit = web3.utils.fromWei(res['_totalInvested'])
67 | // console.log("total_deposit" + res['_totalInvested'])
68 | return total_deposit
69 |
70 | } catch (e) {
71 | return false;
72 | }
73 | }
74 |
75 | export const web3_user_deposit_count = async () => {
76 | const web3 = await getWeb3();
77 | if (!web3) {
78 | console.log("No web3 instance found.");
79 | return false;
80 | }
81 | try {
82 | let extraMaticContract = new Contract(contractAbi, "0x2a2cf93bc92537a596e7956315ce914186d0242f" );//create instance of contract with abi and address
83 | const accounts = await web3.eth.getAccounts();
84 | const res = await extraMaticContract.methods.getUserAmountOfDeposits(accounts[0]).call()//get total staked money value
85 | // let contact_balance = web3.utils.fromWei(res)
86 |
87 | return res
88 |
89 | } catch (e) {
90 | return false;
91 | }
92 | }
93 |
94 | export const web3_user_total_deposit = async () => {
95 | const web3 = await getWeb3();
96 | if (!web3) {
97 | console.log("No web3 instance found.");
98 | return false;
99 | }
100 | try {
101 | let extraMaticContract = new Contract(contractAbi, "0x2a2cf93bc92537a596e7956315ce914186d0242f" );//create instance of contract with abi and address
102 | const accounts = await web3.eth.getAccounts();
103 | const res = await extraMaticContract.methods.getUserInfo(accounts[0]).call()//get total staked money value
104 | let contact_balance = web3.utils.fromWei(res['totalDeposit'])
105 | return contact_balance
106 |
107 | } catch (e) {
108 | return false;
109 | }
110 | }
111 |
112 | export const web3_user_total_withdraw = async () => {
113 | const web3 = await getWeb3();
114 | if (!web3) {
115 | console.log("No web3 instance found.");
116 | return false;
117 | }
118 | try {
119 | let extraMaticContract = new Contract(contractAbi, "0x2a2cf93bc92537a596e7956315ce914186d0242f" );//create instance of contract with abi and address
120 | const accounts = await web3.eth.getAccounts();
121 | const res = await extraMaticContract.methods.getUserInfo(accounts[0]).call()//get total staked money value
122 | let contact_balance = web3.utils.fromWei(res['totalWithdrawn'])
123 | return contact_balance
124 |
125 | } catch (e) {
126 | return false;
127 | }
128 | }
129 |
130 | export const web3_user_referral_bonus = async () => {
131 | const web3 = await getWeb3();
132 | if (!web3) {
133 | console.log("No web3 instance found.");
134 | return false;
135 | }
136 | try {
137 | let extraMaticContract = new Contract(contractAbi, "0x2a2cf93bc92537a596e7956315ce914186d0242f" );//create instance of contract with abi and address
138 | const accounts = await web3.eth.getAccounts();
139 | const res = await extraMaticContract.methods.getUserReferralTotalBonus(accounts[0]).call()//get total staked money value
140 | let contact_balance = web3.utils.fromWei(res)
141 | return contact_balance
142 |
143 | } catch (e) {
144 | return false;
145 | }
146 | }
147 |
148 | export const web3_referred_users = async () => {
149 | const web3 = await getWeb3();
150 | if (!web3) {
151 | console.log("No web3 instance found.");
152 | return false;
153 | }
154 | try {
155 | let extraMaticContract = new Contract(contractAbi, "0x2a2cf93bc92537a596e7956315ce914186d0242f" );//create instance of contract with abi and address
156 | const accounts = await web3.eth.getAccounts();
157 | const res = await extraMaticContract.methods.getUserTotalReferrals(accounts[0]).call()//get total staked money value
158 | // let contact_balance = web3.utils.fromWei(res)
159 | return res
160 |
161 | } catch (e) {
162 | return false;
163 | }
164 | }
165 |
166 | export const web3_available_balance = async () => {
167 | const web3 = await getWeb3();
168 | if (!web3) {
169 | console.log("No web3 instance found.");
170 | return false;
171 | }
172 | try {
173 | let extraMaticContract = new Contract(contractAbi, "0x2a2cf93bc92537a596e7956315ce914186d0242f" );//create instance of contract with abi and address
174 | const accounts = await web3.eth.getAccounts();
175 | const res = await extraMaticContract.methods.getUserAvailable(accounts[0]).call()//get total staked money value
176 | let contact_balance = web3.utils.fromWei(res)
177 | return contact_balance
178 |
179 | } catch (e) {
180 | return false;
181 | }
182 | }
183 |
184 | export const stakeMATIC = async (referral_address , amount, planId) => {//stake amount of BNB to the planId's plan
185 | const web3 = await getWeb3();
186 | if (!web3) {
187 | toast.error("No web3 instance found.");
188 | return false;
189 | }
190 | try {
191 | let connectedAddress = await connectToWallet();
192 | console.log(connectedAddress);
193 | let extraMaticContract = new Contract(contractAbi, "0x2a2cf93bc92537a596e7956315ce914186d0242f" );
194 | const txCount = await web3.eth.getTransactionCount(connectedAddress);
195 | console.log(referral_address);
196 | if(!referral_address)
197 | var referrer = "0x2D19c11f66BE26Ba13333C428aD2050630B8176b"
198 | else referrer = referral_address
199 | console.log(referrer);
200 | const myNewData = await extraMaticContract.methods.invest(referrer, planId).encodeABI()
201 | let weiPrice = web3.utils.toWei(`${amount}`, 'ether');
202 | const gas2 = await web3.eth.getGasPrice()
203 | const transactionParameters = {
204 | nonce: web3.utils.toHex(txCount),
205 | gasPrice: web3.utils.toHex(gas2),
206 | // gasLimit: web3.utils.toHex(gasLimit),
207 | to: "0x2a2cf93bc92537a596e7956315ce914186d0242f" ,
208 | from: connectedAddress,
209 | data: myNewData,
210 | value: web3.utils.toHex(weiPrice)
211 | }
212 |
213 | // As with any RPC call, it may throw an error
214 | const txHash = await window.ethereum.request({
215 | method: 'eth_sendTransaction',
216 | params: [transactionParameters],
217 | });
218 |
219 | if (txHash) {
220 | console.log("Transaction Done Successfully.");
221 | }
222 | } catch (e) {
223 | toast.error(e.message);
224 | return false;
225 | }
226 | }
227 |
228 | export const reinvest = async (planId) => {
229 | const web3 = await getWeb3();
230 | const amount = '0.1';
231 | var referrer = "0x2D19c11f66BE26Ba13333C428aD2050630B8176b"
232 | if (!web3) {
233 | toast.error("No web3 instance found.");
234 | return false;
235 | }
236 | try {
237 | let connectedAddress = await connectToWallet();
238 | console.log(connectedAddress);
239 | let extraMaticContract = new Contract(contractAbi, "0x2a2cf93bc92537a596e7956315ce914186d0242f" );
240 | const txCount = await web3.eth.getTransactionCount(connectedAddress);
241 | const myNewData = await extraMaticContract.methods.reinvest(planId).encodeABI()
242 | console.log(myNewData);
243 | let weiPrice = web3.utils.toWei(`${amount}`, 'ether');
244 | const gas2 = await web3.eth.getGasPrice()
245 | const transactionParameters = {
246 | nonce: web3.utils.toHex(txCount),
247 | gasPrice: web3.utils.toHex(gas2),
248 | // gasLimit: web3.utils.toHex(gasLimit),
249 | to: "0x2a2cf93bc92537a596e7956315ce914186d0242f" ,
250 | from: connectedAddress,
251 | data: myNewData,
252 | // value: web3.utils.toHex(weiPrice)
253 | }
254 |
255 | // As with any RPC call, it may throw an error
256 | const txHash = await window.ethereum.request({
257 | method: 'eth_sendTransaction',
258 | params: [transactionParameters],
259 | });
260 |
261 | if (txHash) {
262 | console.log("Transaction Done Successfully.");
263 | }
264 | } catch (e) {
265 | console.log(e.message);
266 | return false;
267 | }
268 | }
269 |
270 | export const WithdrawFn = async () => {
271 | const web3 = await getWeb3();
272 | if (!web3) {
273 | toast.error("No web3 instance found.");
274 | return false;
275 | }
276 | try {
277 | let connectedAddress = await connectToWallet();
278 | let extraMaticContract = new Contract(contractAbi, "0x2a2cf93bc92537a596e7956315ce914186d0242f" );
279 | const txCount = await web3.eth.getTransactionCount(connectedAddress);//get total trasaction count sent by current address
280 | const myNewData = await extraMaticContract.methods.withdraw().encodeABI()
281 | const gas2 = await web3.eth.getGasPrice()
282 | const transactionParameters = {
283 | nonce: web3.utils.toHex(txCount),
284 | gasPrice: web3.utils.toHex(gas2),
285 | // gasLimit: web3.utils.toHex(gasLimit),
286 | to: "0x2a2cf93bc92537a596e7956315ce914186d0242f",
287 | from: connectedAddress,
288 | data: myNewData,
289 | }
290 | // As with any RPC call, it may throw an error
291 | const txHash = await window.ethereum.request({
292 | method: 'eth_sendTransaction',
293 | params: [transactionParameters],
294 | });
295 | if (txHash) {
296 | toast.success("Transaction Done Successfully.");
297 | return
298 | }
299 | } catch (e) {
300 | toast.error(e.message);
301 | return false;
302 | }
303 | }
304 |
--------------------------------------------------------------------------------
/test/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/reactmaster223/polygon-staking-site/c8fa0d593e63467fe3e24e5ada4e430751a513b3/test/.gitkeep
--------------------------------------------------------------------------------
/truffle-config.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Use this file to configure your truffle project. It's seeded with some
3 | * common settings for different networks and features like migrations,
4 | * compilation and testing. Uncomment the ones you need or modify
5 | * them to suit your project as necessary.
6 | *
7 | * More information about configuration can be found at:
8 | *
9 | * trufflesuite.com/docs/advanced/configuration
10 | *
11 | * To deploy via Infura you'll need a wallet provider (like @truffle/hdwallet-provider)
12 | * to sign your transactions before they're sent to a remote public node. Infura accounts
13 | * are available for free at: infura.io/register.
14 | *
15 | * You'll also need a mnemonic - the twelve word phrase the wallet uses to generate
16 | * public/private key pairs. If you're publishing your code to GitHub make sure you load this
17 | * phrase from a file you've .gitignored so it doesn't accidentally become public.
18 | *
19 | */
20 |
21 | // const HDWalletProvider = require('@truffle/hdwallet-provider');
22 | //
23 | // const fs = require('fs');
24 | // const mnemonic = fs.readFileSync(".secret").toString().trim();
25 |
26 | module.exports = {
27 | networks: {
28 | development: {
29 | host: "https://rpc-mumbai.maticvigil.com",
30 | port: 8545,
31 | network_id: "80001" // Match any network id
32 | }
33 | },
34 | solc: {
35 | optimizer: {
36 | enabled: true,
37 | runs: 200
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------