├── client ├── src │ ├── scss │ │ ├── components │ │ │ ├── table.scss │ │ │ ├── orderList.scss │ │ │ ├── tradeList.scss │ │ │ ├── card.scss │ │ │ ├── header.scss │ │ │ └── dropdown.scss │ │ ├── utils.scss │ │ ├── index.scss │ │ ├── colors.scss │ │ ├── base.scss │ │ └── theme.scss │ ├── index.js │ ├── Footer.js │ ├── Header.js │ ├── Dropdown.js │ ├── LoadingContainer.js │ ├── AllOrders.js │ ├── MyOrders.js │ ├── AllTrades.js │ ├── utils.js │ ├── Wallet.js │ ├── NewOrder.js │ ├── ERC20Abi.json │ ├── App.js │ └── contracts │ │ ├── Context.json │ │ ├── Migrations.json │ │ └── ERC20Detailed.json ├── public │ ├── robots.txt │ ├── favicon.ico │ └── index.html ├── .gitignore ├── package.json └── README.md ├── .gitignore ├── trading-app.png ├── migrations ├── 1_initial_migration.js └── 2_deploy_contracts.js ├── truffle-config.js ├── contracts ├── mocks │ ├── Rep.sol │ ├── Zrx.sol │ ├── Dai.sol │ └── Bat.sol ├── Migrations.sol └── Dex.sol ├── package.json ├── test ├── TestSimpleStorage.sol └── simplestorage.js └── README.md /client/src/scss/components/table.scss: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | build 3 | app/src/contracts 4 | .DS_Store 5 | -------------------------------------------------------------------------------- /client/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | -------------------------------------------------------------------------------- /trading-app.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/samarth30/Decentralized-Trading-Platform/HEAD/trading-app.png -------------------------------------------------------------------------------- /client/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/samarth30/Decentralized-Trading-Platform/HEAD/client/public/favicon.ico -------------------------------------------------------------------------------- /migrations/1_initial_migration.js: -------------------------------------------------------------------------------- 1 | var Migrations = artifacts.require("Migrations"); 2 | 3 | module.exports = function(deployer) { 4 | deployer.deploy(Migrations); 5 | }; 6 | -------------------------------------------------------------------------------- /client/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import 'bootstrap/dist/css/bootstrap.min.css'; 4 | import './scss/index.scss'; 5 | import LoadingContainer from './LoadingContainer'; 6 | 7 | ReactDOM.render(, document.getElementById('root')); 8 | -------------------------------------------------------------------------------- /client/src/scss/utils.scss: -------------------------------------------------------------------------------- 1 | $fontSmall: 14px; 2 | 3 | .green-bg { 4 | background: $green; 5 | } 6 | .red-bg { 7 | background: $red; 8 | } 9 | 10 | .flex { 11 | display: flex; 12 | } 13 | 14 | @media (min-width: 576px) { 15 | .first-col { 16 | padding-right: 0; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /client/src/scss/components/orderList.scss: -------------------------------------------------------------------------------- 1 | .order-list { 2 | &.order-list-buy { 3 | .order-list-title { 4 | background-color: $green !important; 5 | } 6 | } 7 | &.order-list-sell { 8 | .order-list-title { 9 | background-color: $red !important; 10 | } 11 | } 12 | color: $white; 13 | } 14 | -------------------------------------------------------------------------------- /client/src/scss/components/tradeList.scss: -------------------------------------------------------------------------------- 1 | .trade-list { 2 | &.order-list-buy { 3 | .order-list-title { 4 | background-color: $green !important; 5 | } 6 | } 7 | &.order-list-sell { 8 | .order-list-title { 9 | background-color: $red !important; 10 | } 11 | } 12 | color: $white; 13 | } 14 | -------------------------------------------------------------------------------- /client/src/scss/index.scss: -------------------------------------------------------------------------------- 1 | @import './colors'; 2 | @import './base'; 3 | @import './utils'; 4 | @import './theme'; 5 | @import './components/dropdown'; 6 | @import './components/card'; 7 | @import './components/header'; 8 | @import './components/orderList'; 9 | @import './components/tradeList'; 10 | //@import './components/table'; 11 | -------------------------------------------------------------------------------- /client/src/scss/colors.scss: -------------------------------------------------------------------------------- 1 | $black: rgb(0, 0, 0); 2 | $dimBlack: rgb(20, 20, 20); 3 | $lightBlack: rgb(40, 40, 40); 4 | 5 | $white: rgb(255, 255, 255); 6 | $dimWhite: rgb(200, 200, 200); 7 | $lightWhite: rgb(240, 240, 240); 8 | 9 | $red: rgb(60, 147, 59); 10 | $green: rgb(204, 36, 36); 11 | 12 | $purple: rgb(68, 19, 130); 13 | $lightPurple: rgb(116, 28, 215); 14 | -------------------------------------------------------------------------------- /truffle-config.js: -------------------------------------------------------------------------------- 1 | const path = require("path"); 2 | 3 | module.exports = { 4 | // See 5 | // to customize your Truffle configuration! 6 | contracts_build_directory: path.join(__dirname, "client/src/contracts"), 7 | compilers: { 8 | solc: { 9 | version: '0.6.3' 10 | } 11 | } 12 | }; 13 | -------------------------------------------------------------------------------- /client/src/scss/components/card.scss: -------------------------------------------------------------------------------- 1 | .card { 2 | background-color: rgb(20, 20, 20); 3 | border-radius: 5px; 4 | padding: 1em; 5 | margin-bottom: 1em; 6 | .card-title { 7 | font-size: 1.5rem; 8 | font-family: 'Montserrat', sans-serif; 9 | font-weight: 700; 10 | border-bottom: 10px solid #731DD8; 11 | margin-bottom: 1em; 12 | } 13 | } 14 | 15 | -------------------------------------------------------------------------------- /client/src/Footer.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | const Footer = () => { 4 | return ( 5 | 10 | ); 11 | }; 12 | 13 | export default Footer; 14 | -------------------------------------------------------------------------------- /contracts/mocks/Rep.sol: -------------------------------------------------------------------------------- 1 | pragma solidity 0.6.3; 2 | 3 | import '@openzeppelin/contracts/token/ERC20/ERC20.sol'; 4 | import '@openzeppelin/contracts/token/ERC20/ERC20Detailed.sol'; 5 | 6 | contract Rep is ERC20, ERC20Detailed { 7 | constructor() ERC20Detailed('REP', 'Augur token', 18) public {} 8 | 9 | function faucet(address to, uint amount) external { 10 | _mint(to, amount); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /contracts/mocks/Zrx.sol: -------------------------------------------------------------------------------- 1 | pragma solidity 0.6.3; 2 | 3 | import '@openzeppelin/contracts/token/ERC20/ERC20.sol'; 4 | import '@openzeppelin/contracts/token/ERC20/ERC20Detailed.sol'; 5 | 6 | contract Zrx is ERC20, ERC20Detailed { 7 | constructor() ERC20Detailed('ZRX', '0x token', 18) public {} 8 | 9 | function faucet(address to, uint amount) external { 10 | _mint(to, amount); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /contracts/mocks/Dai.sol: -------------------------------------------------------------------------------- 1 | pragma solidity 0.6.3; 2 | 3 | import '@openzeppelin/contracts/token/ERC20/ERC20.sol'; 4 | import '@openzeppelin/contracts/token/ERC20/ERC20Detailed.sol'; 5 | 6 | contract Dai is ERC20, ERC20Detailed { 7 | constructor() ERC20Detailed('DAI', 'Dai Stablecoin', 18) public {} 8 | 9 | function faucet(address to, uint amount) external { 10 | _mint(to, amount); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /contracts/mocks/Bat.sol: -------------------------------------------------------------------------------- 1 | pragma solidity 0.6.3; 2 | 3 | import '@openzeppelin/contracts/token/ERC20/ERC20.sol'; 4 | import '@openzeppelin/contracts/token/ERC20/ERC20Detailed.sol'; 5 | 6 | contract Bat is ERC20, ERC20Detailed { 7 | constructor() ERC20Detailed('BAT', 'Brave browser token', 18) public {} 8 | 9 | function faucet(address to, uint amount) external { 10 | _mint(to, amount); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /client/.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 | -------------------------------------------------------------------------------- /client/src/scss/components/header.scss: -------------------------------------------------------------------------------- 1 | #header { 2 | .header-title { 3 | font-family: 'Montserrat', sans-serif; 4 | font-weight: 700; 5 | text-align: center; 6 | margin-bottom: 0; 7 | font-size: 1rem; 8 | line-height: 38px; 9 | } 10 | .contract-address { 11 | color: $dimWhite; 12 | font-size: 0.8rem; 13 | .contract-address .address { 14 | font-family: 'Courier'; 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /client/src/scss/base.scss: -------------------------------------------------------------------------------- 1 | body { 2 | background-color: $black; 3 | font-size: 16px; 4 | color: $lightWhite; 5 | } 6 | 7 | h1 { 8 | color: $white; 9 | } 10 | 11 | h2 { 12 | color: $white; 13 | } 14 | 15 | h3 { 16 | color: $white; 17 | } 18 | 19 | footer { 20 | font-size: 0.75rem; 21 | background-color: $dimBlack; 22 | color: $white; 23 | padding: 25px 15px; 24 | a { 25 | color: $black; 26 | font-weight: bold; 27 | } 28 | p { 29 | margin: 0; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "end", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "truffle-config.js", 6 | "directories": { 7 | "test": "test" 8 | }, 9 | "scripts": { 10 | "test": "echo \"Error: no test specified\" && exit 1" 11 | }, 12 | "keywords": [], 13 | "author": "", 14 | "license": "ISC", 15 | "dependencies": { 16 | "@openzeppelin/contracts": "^3.0.0-beta.0", 17 | "@openzeppelin/test-helpers": "^0.5.5", 18 | "@truffle/hdwallet-provider": "^1.0.37" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /test/TestSimpleStorage.sol: -------------------------------------------------------------------------------- 1 | pragma solidity >=0.4.21 <0.6.0; 2 | 3 | import "truffle/Assert.sol"; 4 | import "truffle/DeployedAddresses.sol"; 5 | import "../contracts/SimpleStorage.sol"; 6 | 7 | contract TestSimpleStorage { 8 | function testItStoresAValue() public { 9 | SimpleStorage simpleStorage = SimpleStorage(DeployedAddresses.SimpleStorage()); 10 | 11 | simpleStorage.set(89); 12 | 13 | uint expected = 89; 14 | 15 | Assert.equal(simpleStorage.storedData(), expected, "It should store the value 89."); 16 | } 17 | } -------------------------------------------------------------------------------- /test/simplestorage.js: -------------------------------------------------------------------------------- 1 | const SimpleStorage = artifacts.require("SimpleStorage"); 2 | 3 | contract("SimpleStorage", accounts => { 4 | it("...should store the value 89.", async () => { 5 | const simpleStorageInstance = await SimpleStorage.deployed(); 6 | 7 | // Set value of 89 8 | await simpleStorageInstance.set(89, { from: accounts[0] }); 9 | 10 | // Get stored value 11 | const storedData = await simpleStorageInstance.storedData.call(); 12 | 13 | assert.equal(storedData, 89, "The value 89 was not stored."); 14 | }); 15 | }); 16 | -------------------------------------------------------------------------------- /contracts/Migrations.sol: -------------------------------------------------------------------------------- 1 | pragma solidity 0.6.3; 2 | 3 | contract Migrations { 4 | address public owner; 5 | uint public last_completed_migration; 6 | 7 | constructor() public { 8 | owner = msg.sender; 9 | } 10 | 11 | modifier restricted() { 12 | if (msg.sender == owner) _; 13 | } 14 | 15 | function setCompleted(uint completed) public restricted { 16 | last_completed_migration = completed; 17 | } 18 | 19 | function upgrade(address new_address) public restricted { 20 | Migrations upgraded = Migrations(new_address); 21 | upgraded.setCompleted(last_completed_migration); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /client/src/scss/components/dropdown.scss: -------------------------------------------------------------------------------- 1 | .dropdown { 2 | .dropdown-toggle { 3 | background-color: black; 4 | border: 1px solid rgb(40,40,40); 5 | &:focus { 6 | box-shadow: none; 7 | } 8 | } 9 | 10 | .dropdown-menu { 11 | background-color: black; 12 | border: 1px solid rgb(40,40,40); 13 | color: white; 14 | .dropdown-item { 15 | color: white; 16 | } 17 | .dropdown-item.active { 18 | background-color: #731DD8; 19 | color: white; 20 | } 21 | .dropdown-item:hover{ 22 | background-color: #441282; 23 | color: white; 24 | } 25 | } 26 | 27 | .visible { 28 | display: block; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /client/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "app", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "bootstrap": "^4.4.1", 7 | "moment": "^2.24.0", 8 | "react": "^16.11.0", 9 | "react-dom": "^16.11.0", 10 | "react-moment": "^0.9.7", 11 | "react-scripts": "^3.2.0", 12 | "recharts": "^1.8.5", 13 | "web3": "^1.2.6" 14 | }, 15 | "scripts": { 16 | "start": "react-scripts start", 17 | "build": "react-scripts build", 18 | "test": "react-scripts test", 19 | "eject": "react-scripts eject" 20 | }, 21 | "eslintConfig": { 22 | "extends": "react-app" 23 | }, 24 | "browserslist": { 25 | "production": [ 26 | ">0.2%", 27 | "not dead", 28 | "not op_mini all" 29 | ], 30 | "development": [ 31 | "last 1 chrome version", 32 | "last 1 firefox version", 33 | "last 1 safari version" 34 | ] 35 | }, 36 | "devDependencies": { 37 | "node-sass": "^4.13.1" 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /client/src/Header.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import Dropdown from './Dropdown.js'; 3 | 4 | function Header({ 5 | user, 6 | tokens, 7 | contracts, 8 | selectToken}) { 9 | return ( 10 | 32 | ); 33 | } 34 | 35 | export default Header; 36 | -------------------------------------------------------------------------------- /client/src/Dropdown.js: -------------------------------------------------------------------------------- 1 | import React, { useState } from 'react'; 2 | 3 | function Dropdown({onSelect, activeItem, items}) { 4 | const [dropdownVisible, setDropdownVisible] = useState(false); 5 | 6 | const selectItem = (e, item) => { 7 | e.preventDefault(); 8 | setDropdownVisible(!dropdownVisible); 9 | onSelect(item); 10 | } 11 | 12 | return ( 13 |
14 | 21 |
22 | {items && items.map((item, i) => ( 23 | selectItem(e, item.value)} 28 | > 29 | {item.label} 30 | 31 | ))} 32 |
33 |
34 | ); 35 | } 36 | 37 | export default Dropdown; 38 | -------------------------------------------------------------------------------- /client/src/LoadingContainer.js: -------------------------------------------------------------------------------- 1 | import React, { useState, useEffect } from "react"; 2 | import { getWeb3, getContracts } from './utils.js'; 3 | import App from './App.js'; 4 | 5 | function LoadingContainer() { 6 | const [web3, setWeb3] = useState(undefined); 7 | const [accounts, setAccounts] = useState([]); 8 | const [contracts, setContracts] = useState(undefined); 9 | 10 | useEffect(() => { 11 | const init = async () => { 12 | const web3 = await getWeb3(); 13 | const contracts = await getContracts(web3); 14 | const accounts = await web3.eth.getAccounts(); 15 | setWeb3(web3); 16 | setContracts(contracts); 17 | setAccounts(accounts); 18 | } 19 | init(); 20 | // eslint-disable-next-line 21 | }, []); 22 | 23 | const isReady = () => { 24 | return ( 25 | typeof web3 !== 'undefined' 26 | && typeof contracts !== 'undefined' 27 | && accounts.length > 0 28 | ); 29 | } 30 | 31 | if (!isReady()) { 32 | return
Loading...
; 33 | } 34 | 35 | return ( 36 | 41 | ); 42 | } 43 | 44 | export default LoadingContainer; 45 | -------------------------------------------------------------------------------- /client/src/AllOrders.js: -------------------------------------------------------------------------------- 1 | 2 | import React from 'react'; 3 | import Moment from 'react-moment'; 4 | 5 | function AllOrders({orders}) { 6 | const renderList = (orders, side, className) => { 7 | return ( 8 | <> 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | {orders.map((order) => ( 22 | 23 | 24 | 25 | 28 | 29 | ))} 30 | 31 |
{side}
amountpricedate
{order.amount - order.filled}{order.price} 26 | {parseInt(order.date) * 1000} 27 |
32 | 33 | ); 34 | } 35 | 36 | return ( 37 |
38 |

All orders

39 |
40 |
41 | {renderList(orders.buy, 'Buy', 'order-list-buy')} 42 |
43 |
44 | {renderList(orders.sell, 'Sell', 'order-list-sell')} 45 |
46 |
47 |
48 | ); 49 | } 50 | 51 | export default AllOrders; -------------------------------------------------------------------------------- /client/src/MyOrders.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import Moment from 'react-moment'; 3 | 4 | function MyOrders({orders}) { 5 | const renderList = (orders, side, className) => { 6 | return ( 7 | <> 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | {orders.map((order) => ( 21 | 22 | 23 | 24 | 27 | 28 | ))} 29 | 30 |
{side}
amount/filledpricedate
{order.amount}/{order.filled}{order.price} 25 | {parseInt(order.date) * 1000} 26 |
31 | 32 | ); 33 | } 34 | 35 | return ( 36 |
37 |

My orders

38 |
39 |
40 | {renderList(orders.buy, 'Buy', 'order-list-buy')} 41 |
42 |
43 | {renderList(orders.sell, 'Sell', 'order-list-sell')} 44 |
45 |
46 |
47 | ); 48 | } 49 | 50 | export default MyOrders; -------------------------------------------------------------------------------- /client/src/scss/theme.scss: -------------------------------------------------------------------------------- 1 | .table { 2 | border: 1px solid $black; 3 | font-size: $fontSmall; 4 | .table-title { 5 | padding: 1em 0.5em; 6 | text-transform: uppercase; 7 | } 8 | thead { 9 | tr { 10 | background-color: $black !important; 11 | } 12 | th { 13 | border: none; 14 | padding: 0.5em 15 | } 16 | } 17 | td { 18 | border-top: none; 19 | padding: 0.25em 0.5em; 20 | } 21 | &.table-striped { 22 | tr:nth-of-type(odd) { 23 | background-color: $lightBlack; 24 | } 25 | } 26 | } 27 | 28 | .btn-group { 29 | width: 100%; 30 | display: flex; 31 | .btn { 32 | flex: 1; 33 | border: 2px solid $purple !important; 34 | background-color: $purple; 35 | &.active { 36 | background-color: $lightPurple !important; 37 | } 38 | &:focus { 39 | box-shadow: none !important; 40 | } 41 | } 42 | } 43 | 44 | .btn-primary { 45 | color: $white; 46 | background-color: $lightPurple; 47 | border-color: $lightPurple; 48 | &:hover { 49 | background-color: $purple; 50 | border-color: $lightPurple; 51 | } 52 | } 53 | 54 | .form-control { 55 | background-color: rgb(40,40,40); 56 | color: white; 57 | border: none; 58 | &:focus { 59 | background-color: rgb(40,40,40); 60 | color: white; 61 | border: none; 62 | } 63 | &:disabled { 64 | background-color: rgb(20,20,20); 65 | color: white; 66 | border: none; 67 | } 68 | } 69 | 70 | .input-group-append { 71 | .input-group-text { 72 | background-color: $black; 73 | border: 1px solid rgb(40,40,40); 74 | color: white; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /client/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 27 | DEX 28 | 29 | 30 | 31 |
32 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /client/src/AllTrades.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import Moment from 'react-moment'; 3 | import { ResponsiveContainer, LineChart, Line, CartesianGrid, XAxis, YAxis } from 'recharts'; 4 | 5 | function AllTrades({trades}) { 6 | const renderList = (trades, className) => { 7 | return ( 8 | <> 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | {trades.map((trade) => ( 19 | 20 | 21 | 22 | 25 | 26 | ))} 27 | 28 |
amountpricedate
{trade.amount}{trade.price} 23 | {parseInt(trade.date) * 1000} 24 |
29 | 30 | ); 31 | } 32 | 33 | const renderChart = (trades) => { 34 | return ( 35 | 36 | 37 | 38 | 39 | { 40 | const date = new Date(parseInt(dateStr) * 1000); 41 | return `${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}`; 42 | }} /> 43 | 44 | 45 | 46 | ); 47 | } 48 | 49 | return ( 50 |
51 |

All trades

52 |
53 |
54 | {renderChart(trades)} 55 | {renderList(trades, 'trade-list')} 56 |
57 |
58 |
59 | ); 60 | } 61 | 62 | export default AllTrades; -------------------------------------------------------------------------------- /client/src/utils.js: -------------------------------------------------------------------------------- 1 | import Web3 from 'web3'; 2 | import Dex from './contracts/Dex.json'; 3 | import ERC20Abi from './ERC20Abi.json'; 4 | 5 | const getWeb3 = () => { 6 | return new Promise((resolve, reject) => { 7 | // Wait for loading completion to avoid race conditions with web3 injection timing. 8 | window.addEventListener("load", async () => { 9 | // Modern dapp browsers... 10 | if (window.ethereum) { 11 | const web3 = new Web3(window.ethereum); 12 | try { 13 | // Request account access if needed 14 | await window.ethereum.enable(); 15 | // Acccounts now exposed 16 | resolve(web3); 17 | } catch (error) { 18 | reject(error); 19 | } 20 | } 21 | // Legacy dapp browsers... 22 | else if (window.web3) { 23 | // Use Mist/MetaMask's provider. 24 | const web3 = window.web3; 25 | console.log("Injected web3 detected."); 26 | resolve(web3); 27 | } 28 | // Fallback to localhost; use dev console port by default... 29 | else { 30 | const provider = new Web3.providers.HttpProvider( 31 | "http://localhost:9545" 32 | ); 33 | const web3 = new Web3(provider); 34 | console.log("No web3 instance injected, using Local web3."); 35 | resolve(web3); 36 | } 37 | }); 38 | }); 39 | }; 40 | 41 | const getContracts = async web3 => { 42 | const networkId = await web3.eth.net.getId(); 43 | const deployedNetwork = Dex.networks[networkId]; 44 | const dex = new web3.eth.Contract( 45 | Dex.abi, 46 | deployedNetwork && deployedNetwork.address, 47 | ); 48 | const tokens = await dex.methods.getTokens().call(); 49 | const tokenContracts = tokens.reduce((acc, token) => ({ 50 | ...acc, 51 | [web3.utils.hexToUtf8(token.ticker)]: new web3.eth.Contract( 52 | ERC20Abi, 53 | token.tokenAddress 54 | ) 55 | }), {}); 56 | return { dex, ...tokenContracts }; 57 | } 58 | 59 | export { getWeb3, getContracts }; 60 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | [![HitCount](http://hits.dwyl.com/samarth30/GithubFinder.svg)](http://hits.dwyl.com/samarth30/GithubFinder) 3 | # Decentralized-Trading-Platform 4 | 5 | 6 | 7 | 8 | # How to install the code 9 | 10 | ``` 11 | npm install 12 | ``` 13 | open a new terminal 14 | ``` 15 | truffle develop 16 | copy the nemonic 17 | logout from the metamask and Import using account seed phrase 18 | copy paste the nemonic 19 | migrate --reset in the same terminal and keep that terminal open 20 | ``` 21 | 22 | open a new terminal 23 | ``` 24 | cd app or client 25 | npm install 26 | npm start 27 | ``` 28 | 29 | enjoy the code happy coding 30 | 31 | just made this awsome project called DEFI trading platform 32 | 33 | in this project i have imbedded 4 fake erc-20 tokens named DAI, BAT ,ZRX , REP made using #OpenZeppelin in this i have given first four accounts of mine 1 #ethereum equivalent fake erc-20 tokens 34 | 35 | 36 | 37 | there is a withdraw and a deposit function by withdraw button you can invest fake #crypto tokens present in your account to the trading application and by depositing you can deposit the tokens earned to your account 38 | 39 | 40 | 41 | also there is a function called limit order and market order 42 | 43 | limit order basically means that you want to buy or sell n number of tokens at this highest price that you will put in the input field 44 | 45 | 46 | 47 | market orders means that you want to buy or sell n number of tokens what ever price that is availiable in the market 48 | 49 | 50 | 51 | the trading algorithm matches the limit order and the market orders and create a trade between the tokens and price that person who wants the tokens at any price get the tokens and the person who wants to sell at a specific price sells it so its all about the working of this DAPP 52 | 53 | 54 | 55 | I have followed Julien Klepatch tutorial series avaliable on 56 | 57 | https://eattheblocks-pro.teachable.com/ this website 58 | 59 | 60 | 61 | thanks Julien Klepatch for making this awsome course on decentralized applications using ethereum and soldity you are great teacher and an awsome person 62 | 63 | 64 | 65 | #solidity #smartcontracts #ethereum #truffle #reactjs #nodejs #ganache #metamask #chai_test #testing #crypto #eattheblocks 66 | -------------------------------------------------------------------------------- /client/README.md: -------------------------------------------------------------------------------- 1 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). 2 | 3 | ## Available Scripts 4 | 5 | In the project directory, you can run: 6 | 7 | ### `yarn start` 8 | 9 | Runs the app in the development mode.
10 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser. 11 | 12 | The page will reload if you make edits.
13 | You will also see any lint errors in the console. 14 | 15 | ### `yarn test` 16 | 17 | Launches the test runner in the interactive watch mode.
18 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. 19 | 20 | ### `yarn build` 21 | 22 | Builds the app for production to the `build` folder.
23 | It correctly bundles React in production mode and optimizes the build for the best performance. 24 | 25 | The build is minified and the filenames include the hashes.
26 | Your app is ready to be deployed! 27 | 28 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. 29 | 30 | ### `yarn eject` 31 | 32 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!** 33 | 34 | 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. 35 | 36 | 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. 37 | 38 | 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. 39 | 40 | ## Learn More 41 | 42 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). 43 | 44 | To learn React, check out the [React documentation](https://reactjs.org/). 45 | 46 | ### Code Splitting 47 | 48 | This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting 49 | 50 | ### Analyzing the Bundle Size 51 | 52 | This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size 53 | 54 | ### Making a Progressive Web App 55 | 56 | This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app 57 | 58 | ### Advanced Configuration 59 | 60 | This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration 61 | 62 | ### Deployment 63 | 64 | This section has moved here: https://facebook.github.io/create-react-app/docs/deployment 65 | 66 | ### `yarn build` fails to minify 67 | 68 | This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify 69 | -------------------------------------------------------------------------------- /client/src/Wallet.js: -------------------------------------------------------------------------------- 1 | import React, { useState } from 'react'; 2 | 3 | const DIRECTION = { 4 | WITHDRAW: 'WITHDRAW', 5 | DEPOSIT: 'DEPOSIT' 6 | }; 7 | 8 | function Wallet({deposit, withdraw, user,getBalances}) { 9 | const [direction, setDirection] = useState(DIRECTION.DEPOSIT); 10 | const [amount, setAmount] = useState(0); 11 | 12 | const onSubmit = (e) => { 13 | e.preventDefault(); 14 | if(direction === DIRECTION.DEPOSIT) { 15 | deposit(amount); 16 | } else { 17 | withdraw(amount); 18 | } 19 | } 20 | 21 | return ( 22 |
23 |

Wallet

24 |

Token balance for {user.selectedToken.ticker}

25 |
26 | 27 |
28 | 34 |
35 |
36 |
37 | 38 |
39 | 45 |
46 |
47 |

Transfer {user.selectedToken.ticker}

48 |
onSubmit(e)}> 49 |
50 | 51 |
52 |
53 | 58 | 63 |
64 |
65 |
66 |
67 | 68 |
69 |
70 | setAmount(e.target.value)} 75 | /> 76 |
77 | {user.selectedToken.ticker} 78 |
79 |
80 |
81 |
82 |
83 | 84 |
85 |
86 |
87 | ); 88 | } 89 | 90 | export default Wallet; 91 | -------------------------------------------------------------------------------- /client/src/NewOrder.js: -------------------------------------------------------------------------------- 1 | import React ,{useState} from 'react' 2 | 3 | const TYPE = { 4 | LIMIT : 'LIMIT', 5 | MARKET : 'MARKET' 6 | }; 7 | 8 | const SIDE = { 9 | BUY:0, 10 | SELL:1 11 | } 12 | 13 | const NewOrder = ({createMarketOrder,createLimitOrder}) => { 14 | 15 | const [order,setOrder] = useState({ 16 | type:TYPE.LIMIT, 17 | side:SIDE.BUY, 18 | amount:'', 19 | price:'' 20 | }) 21 | 22 | const onSubmit = (e)=>{ 23 | e.preventDefault(); 24 | if(order.type === TYPE.MARKET){ 25 | createMarketOrder(order.amount,order.side); 26 | }else{ 27 | createLimitOrder(order.amount,order.price,order.side); 28 | } 29 | } 30 | 31 | return ( 32 |
33 |

New Order

34 |
onSubmit(e)}> 35 |
36 | 37 |
38 |
39 | 44 | 49 |
50 |
51 |
52 |
53 | 54 |
55 |
56 | 61 | 66 |
67 |
68 |
69 |
70 | 71 |
72 | setOrder(order => ({ ...order, amount: value}))} 77 | /> 78 |
79 |
80 | {order.type === TYPE.MARKET ? null : 81 |
82 | 83 |
84 | setOrder(order => ({ ...order, price: value}))} 89 | /> 90 |
91 |
92 | } 93 |
94 | 95 |
96 |
97 |
98 | ) 99 | } 100 | 101 | export default NewOrder 102 | -------------------------------------------------------------------------------- /migrations/2_deploy_contracts.js: -------------------------------------------------------------------------------- 1 | const Dai = artifacts.require('mocks/Dai.sol'); 2 | const Bat = artifacts.require('mocks/Bat.sol'); 3 | const Rep = artifacts.require('mocks/Rep.sol'); 4 | const Zrx = artifacts.require('mocks/Zrx.sol'); 5 | const Dex = artifacts.require("Dex.sol"); 6 | 7 | const [DAI, BAT, REP, ZRX] = ['DAI', 'BAT', 'REP', 'ZRX'] 8 | .map(ticker => web3.utils.fromAscii(ticker)); 9 | 10 | const SIDE = { 11 | BUY: 0, 12 | SELL: 1 13 | }; 14 | 15 | module.exports = async function(deployer, _network, accounts) { 16 | const [trader1, trader2, trader3, trader4, _] = accounts; 17 | await Promise.all( 18 | [Dai, Bat, Rep, Zrx, Dex].map(contract => deployer.deploy(contract)) 19 | ); 20 | const [dai, bat, rep, zrx, dex] = await Promise.all( 21 | [Dai, Bat, Rep, Zrx, Dex].map(contract => contract.deployed()) 22 | ); 23 | 24 | await Promise.all([ 25 | dex.addToken(DAI, dai.address), 26 | dex.addToken(BAT, bat.address), 27 | dex.addToken(REP, rep.address), 28 | dex.addToken(ZRX, zrx.address) 29 | ]); 30 | 31 | const amount = web3.utils.toWei('1000'); 32 | const seedTokenBalance = async (token, trader) => { 33 | await token.faucet(trader, amount) 34 | await token.approve( 35 | dex.address, 36 | amount, 37 | {from: trader} 38 | ); 39 | const ticker = await token.name(); 40 | await dex.deposit( 41 | amount, 42 | web3.utils.fromAscii(ticker), 43 | {from: trader} 44 | ); 45 | }; 46 | await Promise.all( 47 | [dai, bat, rep, zrx].map( 48 | token => seedTokenBalance(token, trader1) 49 | ) 50 | ); 51 | await Promise.all( 52 | [dai, bat, rep, zrx].map( 53 | token => seedTokenBalance(token, trader2) 54 | ) 55 | ); 56 | await Promise.all( 57 | [dai, bat, rep, zrx].map( 58 | token => seedTokenBalance(token, trader3) 59 | ) 60 | ); 61 | await Promise.all( 62 | [dai, bat, rep, zrx].map( 63 | token => seedTokenBalance(token, trader4) 64 | ) 65 | ); 66 | 67 | const increaseTime = async (seconds) => { 68 | await web3.currentProvider.send({ 69 | jsonrpc: '2.0', 70 | method: 'evm_increaseTime', 71 | params: [seconds], 72 | id: 0, 73 | }, () => {}); 74 | await web3.currentProvider.send({ 75 | jsonrpc: '2.0', 76 | method: 'evm_mine', 77 | params: [], 78 | id: 0, 79 | }, () => {}); 80 | } 81 | 82 | //create trades 83 | await dex.createLimitOrder(BAT, 1000, 10, SIDE.BUY, {from: trader1}); 84 | await dex.createMarketOrder(BAT, 1000, SIDE.SELL, {from: trader2}); 85 | await increaseTime(1); 86 | await dex.createLimitOrder(BAT, 1200, 11, SIDE.BUY, {from: trader1}); 87 | await dex.createMarketOrder(BAT, 1200, SIDE.SELL, {from: trader2}); 88 | await increaseTime(1); 89 | await dex.createLimitOrder(BAT, 1200, 15, SIDE.BUY, {from: trader1}); 90 | await dex.createMarketOrder(BAT, 1200, SIDE.SELL, {from: trader2}); 91 | await increaseTime(1); 92 | await dex.createLimitOrder(BAT, 1500, 14, SIDE.BUY, {from: trader1}); 93 | await dex.createMarketOrder(BAT, 1500, SIDE.SELL, {from: trader2}); 94 | await increaseTime(1); 95 | await dex.createLimitOrder(BAT, 2000, 12, SIDE.BUY, {from: trader1}); 96 | await dex.createMarketOrder(BAT, 2000, SIDE.SELL, {from: trader2}); 97 | 98 | await dex.createLimitOrder(REP, 1000, 2, SIDE.BUY, {from: trader1}); 99 | await dex.createMarketOrder(REP, 1000, SIDE.SELL, {from: trader2}); 100 | await increaseTime(1); 101 | await dex.createLimitOrder(REP, 500, 4, SIDE.BUY, {from: trader1}); 102 | await dex.createMarketOrder(REP, 500, SIDE.SELL, {from: trader2}); 103 | await increaseTime(1); 104 | await dex.createLimitOrder(REP, 800, 2, SIDE.BUY, {from: trader1}); 105 | await dex.createMarketOrder(REP, 800, SIDE.SELL, {from: trader2}); 106 | await increaseTime(1); 107 | await dex.createLimitOrder(REP, 1200, 6, SIDE.BUY, {from: trader1}); 108 | await dex.createMarketOrder(REP, 1200, SIDE.SELL, {from: trader2}); 109 | 110 | //create orders 111 | await Promise.all([ 112 | dex.createLimitOrder(BAT, 1400, 10, SIDE.BUY, {from: trader1}), 113 | dex.createLimitOrder(BAT, 1200, 11, SIDE.BUY, {from: trader2}), 114 | dex.createLimitOrder(BAT, 1000, 12, SIDE.BUY, {from: trader2}), 115 | 116 | dex.createLimitOrder(REP, 3000, 4, SIDE.BUY, {from: trader1}), 117 | dex.createLimitOrder(REP, 2000, 5, SIDE.BUY, {from: trader1}), 118 | dex.createLimitOrder(REP, 500, 6, SIDE.BUY, {from: trader2}), 119 | 120 | dex.createLimitOrder(ZRX, 4000, 12, SIDE.BUY, {from: trader1}), 121 | dex.createLimitOrder(ZRX, 3000, 13, SIDE.BUY, {from: trader1}), 122 | dex.createLimitOrder(ZRX, 500, 14, SIDE.BUY, {from: trader2}), 123 | 124 | dex.createLimitOrder(BAT, 2000, 16, SIDE.SELL, {from: trader3}), 125 | dex.createLimitOrder(BAT, 3000, 15, SIDE.SELL, {from: trader4}), 126 | dex.createLimitOrder(BAT, 500, 14, SIDE.SELL, {from: trader4}), 127 | 128 | dex.createLimitOrder(REP, 4000, 10, SIDE.SELL, {from: trader3}), 129 | dex.createLimitOrder(REP, 2000, 9, SIDE.SELL, {from: trader3}), 130 | dex.createLimitOrder(REP, 800, 8, SIDE.SELL, {from: trader4}), 131 | 132 | dex.createLimitOrder(ZRX, 1500, 23, SIDE.SELL, {from: trader3}), 133 | dex.createLimitOrder(ZRX, 1200, 22, SIDE.SELL, {from: trader3}), 134 | dex.createLimitOrder(ZRX, 900, 21, SIDE.SELL, {from: trader4}), 135 | ]); 136 | }; 137 | -------------------------------------------------------------------------------- /client/src/ERC20Abi.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "constant": true, 4 | "inputs": [], 5 | "name": "name", 6 | "outputs": [ 7 | { 8 | "name": "", 9 | "type": "string" 10 | } 11 | ], 12 | "payable": false, 13 | "stateMutability": "view", 14 | "type": "function" 15 | }, 16 | { 17 | "constant": false, 18 | "inputs": [ 19 | { 20 | "name": "_spender", 21 | "type": "address" 22 | }, 23 | { 24 | "name": "_value", 25 | "type": "uint256" 26 | } 27 | ], 28 | "name": "approve", 29 | "outputs": [ 30 | { 31 | "name": "", 32 | "type": "bool" 33 | } 34 | ], 35 | "payable": false, 36 | "stateMutability": "nonpayable", 37 | "type": "function" 38 | }, 39 | { 40 | "constant": true, 41 | "inputs": [], 42 | "name": "totalSupply", 43 | "outputs": [ 44 | { 45 | "name": "", 46 | "type": "uint256" 47 | } 48 | ], 49 | "payable": false, 50 | "stateMutability": "view", 51 | "type": "function" 52 | }, 53 | { 54 | "constant": false, 55 | "inputs": [ 56 | { 57 | "name": "_from", 58 | "type": "address" 59 | }, 60 | { 61 | "name": "_to", 62 | "type": "address" 63 | }, 64 | { 65 | "name": "_value", 66 | "type": "uint256" 67 | } 68 | ], 69 | "name": "transferFrom", 70 | "outputs": [ 71 | { 72 | "name": "", 73 | "type": "bool" 74 | } 75 | ], 76 | "payable": false, 77 | "stateMutability": "nonpayable", 78 | "type": "function" 79 | }, 80 | { 81 | "constant": true, 82 | "inputs": [], 83 | "name": "decimals", 84 | "outputs": [ 85 | { 86 | "name": "", 87 | "type": "uint8" 88 | } 89 | ], 90 | "payable": false, 91 | "stateMutability": "view", 92 | "type": "function" 93 | }, 94 | { 95 | "constant": true, 96 | "inputs": [ 97 | { 98 | "name": "_owner", 99 | "type": "address" 100 | } 101 | ], 102 | "name": "balanceOf", 103 | "outputs": [ 104 | { 105 | "name": "balance", 106 | "type": "uint256" 107 | } 108 | ], 109 | "payable": false, 110 | "stateMutability": "view", 111 | "type": "function" 112 | }, 113 | { 114 | "constant": true, 115 | "inputs": [], 116 | "name": "symbol", 117 | "outputs": [ 118 | { 119 | "name": "", 120 | "type": "string" 121 | } 122 | ], 123 | "payable": false, 124 | "stateMutability": "view", 125 | "type": "function" 126 | }, 127 | { 128 | "constant": false, 129 | "inputs": [ 130 | { 131 | "name": "_to", 132 | "type": "address" 133 | }, 134 | { 135 | "name": "_value", 136 | "type": "uint256" 137 | } 138 | ], 139 | "name": "transfer", 140 | "outputs": [ 141 | { 142 | "name": "", 143 | "type": "bool" 144 | } 145 | ], 146 | "payable": false, 147 | "stateMutability": "nonpayable", 148 | "type": "function" 149 | }, 150 | { 151 | "constant": true, 152 | "inputs": [ 153 | { 154 | "name": "_owner", 155 | "type": "address" 156 | }, 157 | { 158 | "name": "_spender", 159 | "type": "address" 160 | } 161 | ], 162 | "name": "allowance", 163 | "outputs": [ 164 | { 165 | "name": "", 166 | "type": "uint256" 167 | } 168 | ], 169 | "payable": false, 170 | "stateMutability": "view", 171 | "type": "function" 172 | }, 173 | { 174 | "payable": true, 175 | "stateMutability": "payable", 176 | "type": "fallback" 177 | }, 178 | { 179 | "anonymous": false, 180 | "inputs": [ 181 | { 182 | "indexed": true, 183 | "name": "owner", 184 | "type": "address" 185 | }, 186 | { 187 | "indexed": true, 188 | "name": "spender", 189 | "type": "address" 190 | }, 191 | { 192 | "indexed": false, 193 | "name": "value", 194 | "type": "uint256" 195 | } 196 | ], 197 | "name": "Approval", 198 | "type": "event" 199 | }, 200 | { 201 | "anonymous": false, 202 | "inputs": [ 203 | { 204 | "indexed": true, 205 | "name": "from", 206 | "type": "address" 207 | }, 208 | { 209 | "indexed": true, 210 | "name": "to", 211 | "type": "address" 212 | }, 213 | { 214 | "indexed": false, 215 | "name": "value", 216 | "type": "uint256" 217 | } 218 | ], 219 | "name": "Transfer", 220 | "type": "event" 221 | } 222 | ] 223 | -------------------------------------------------------------------------------- /client/src/App.js: -------------------------------------------------------------------------------- 1 | import React, { useState, useEffect } from "react"; 2 | import Header from './Header.js'; 3 | import Footer from './Footer.js'; 4 | import Wallet from './Wallet.js'; 5 | import NewOrder from './NewOrder.js'; 6 | import AllOrders from './AllOrders.js'; 7 | import MyOrders from './MyOrders'; 8 | import AllTrades from './AllTrades'; 9 | 10 | const SIDE = { 11 | BUY: 0, 12 | SELL: 1 13 | }; 14 | 15 | function App({web3, accounts, contracts}) { 16 | const [tokens, setTokens] = useState([]); 17 | const [user, setUser] = useState({ 18 | accounts: [], 19 | balances: { 20 | tokenDex: 0, 21 | tokenWallet: 0 22 | }, 23 | selectedToken: undefined 24 | }); 25 | const [orders, setOrders] = useState({ 26 | buy: [], 27 | sell: [] 28 | }); 29 | const [listener, setListener] = useState(undefined); 30 | 31 | const [trades ,setTrades] = useState({}); 32 | const getBalances = async (account, token) => { 33 | const tokenDex = await contracts.dex.methods 34 | .traderBalances(account, web3.utils.fromAscii(token.ticker)) 35 | .call(); 36 | const tokenWallet = await contracts[token.ticker].methods 37 | .balanceOf(account) 38 | .call(); 39 | return {tokenDex, tokenWallet}; 40 | } 41 | 42 | const getOrders = async token => { 43 | const orders = await Promise.all([ 44 | contracts.dex.methods 45 | .getOrders(web3.utils.fromAscii(token.ticker), SIDE.BUY) 46 | .call(), 47 | contracts.dex.methods 48 | .getOrders(web3.utils.fromAscii(token.ticker), SIDE.SELL) 49 | .call(), 50 | ]); 51 | return {buy: orders[0], sell: orders[1]}; 52 | } 53 | 54 | 55 | const listenToTrades = async(token)=>{ 56 | setTrades([]); 57 | const tradeIds= new Set(); 58 | const listener = contracts.dex.events.NewTrade( 59 | { 60 | filter:{ticker:web3.utils.fromAscii(token.ticker)}, 61 | fromBlock:0 62 | } 63 | ).on('data',newTrade=>{ 64 | if(tradeIds.has(newTrade.returnValues.tradeId)) return; 65 | tradeIds.add(newTrade.returnValues.tradeId); 66 | setTrades(trades => ([...trades,newTrade.returnValues])); 67 | }) 68 | setListener(listener); 69 | } 70 | 71 | const selectToken = token => { 72 | setUser({...user, selectedToken: token}); 73 | } 74 | 75 | 76 | 77 | const deposit = async amount => { 78 | await contracts[user.selectedToken.ticker].methods 79 | .approve(contracts.dex.options.address, amount) 80 | .send({from: user.accounts[0]}); 81 | await contracts.dex.methods 82 | .deposit(amount, web3.utils.fromAscii(user.selectedToken.ticker)) 83 | .send({from: user.accounts[0]}); 84 | const balances = await getBalances( 85 | user.accounts[0], 86 | user.selectedToken 87 | ); 88 | setUser(user => ({ ...user, balances})); 89 | } 90 | 91 | const withdraw = async amount => { 92 | await contracts.dex.methods 93 | .withdraw( 94 | amount, 95 | web3.utils.fromAscii(user.selectedToken.ticker) 96 | ) 97 | .send({from: user.accounts[0]}); 98 | const balances = await getBalances( 99 | user.accounts[0], 100 | user.selectedToken 101 | ); 102 | setUser(user => ({ ...user, balances})); 103 | } 104 | 105 | const createMarketOrder = async (amount, side) => { 106 | await contracts.dex.methods 107 | .createMarketOrder( 108 | web3.utils.fromAscii(user.selectedToken.ticker), 109 | amount, 110 | side 111 | ) 112 | .send({from: user.accounts[0]}); 113 | const orders = await getOrders(user.selectedToken); 114 | setOrders(orders); 115 | } 116 | 117 | const createLimitOrder = async (amount, price, side) => { 118 | await contracts.dex.methods 119 | .createLimitOrder( 120 | web3.utils.fromAscii(user.selectedToken.ticker), 121 | amount, 122 | price, 123 | side 124 | ) 125 | .send({from: user.accounts[0]}); 126 | const orders = await getOrders(user.selectedToken); 127 | setOrders(orders); 128 | } 129 | 130 | useEffect(() => { 131 | const init = async () => { 132 | const rawTokens = await contracts.dex.methods.getTokens().call(); 133 | const tokens = rawTokens.map(token => ({ 134 | ...token, 135 | ticker: web3.utils.hexToUtf8(token.ticker) 136 | })); 137 | const [balances, orders] = await Promise.all([ 138 | getBalances(accounts[0], tokens[0]), 139 | getOrders(tokens[0]), 140 | ]); 141 | listenToTrades(tokens[0]); 142 | setTokens(tokens); 143 | setUser({accounts, balances, selectedToken: tokens[0]}); 144 | setOrders(orders); 145 | } 146 | init(); 147 | }, []); 148 | 149 | useEffect(() => { 150 | const init = async () => { 151 | const [balances, orders] = await Promise.all([ 152 | getBalances( 153 | user.accounts[0], 154 | user.selectedToken 155 | ), 156 | getOrders(user.selectedToken), 157 | ]); 158 | listenToTrades(user.selectedToken); 159 | setUser(user => ({ ...user, balances})); 160 | setOrders(orders); 161 | } 162 | if(typeof user.selectedToken !== 'undefined') { 163 | init(); 164 | } 165 | }, [user.selectedToken] , ()=>{ 166 | listener.unsubscribe(); 167 | }); 168 | 169 | if(typeof user.selectedToken === 'undefined') { 170 | return
Loading...
; 171 | } 172 | 173 | return ( 174 |
175 |
181 |
182 |
183 |
184 | 189 | {user.selectedToken.ticker !== 'DAI' ? ( 190 | 194 | ) : null} 195 |
196 | {user.selectedToken.ticker !== 'DAI' ? ( 197 |
198 | 201 | 204 | order.trader.toLowerCase() === accounts[0].toLowerCase() 208 | ), 209 | sell: orders.sell.filter( 210 | order => order.trader.toLowerCase() === accounts[0].toLowerCase() 211 | ) 212 | }} 213 | /> 214 |
215 | ) : null} 216 |
217 |
218 |
220 | ); 221 | } 222 | 223 | export default App; -------------------------------------------------------------------------------- /contracts/Dex.sol: -------------------------------------------------------------------------------- 1 | pragma solidity 0.6.3; 2 | pragma experimental ABIEncoderV2; 3 | 4 | import '@openzeppelin/contracts/token/ERC20/IERC20.sol'; 5 | import '@openzeppelin/contracts/math/SafeMath.sol'; 6 | 7 | contract Dex { 8 | 9 | using SafeMath for uint; 10 | 11 | enum Side { 12 | BUY, 13 | SELL 14 | } 15 | 16 | struct Token { 17 | bytes32 ticker; 18 | address tokenAddress; 19 | } 20 | 21 | struct Order { 22 | uint id; 23 | address trader; 24 | Side side; 25 | bytes32 ticker; 26 | uint amount; 27 | uint filled; 28 | uint price; 29 | uint date; 30 | } 31 | 32 | mapping(bytes32 => Token) public tokens; 33 | bytes32[] public tokenList; 34 | mapping(address => mapping(bytes32 => uint)) public traderBalances; 35 | mapping(bytes32 => mapping(uint => Order[])) public orderBook; 36 | address public admin; 37 | uint public nextOrderId; 38 | uint public nextTradeId; 39 | bytes32 constant DAI = bytes32('DAI'); 40 | 41 | event NewTrade( 42 | uint tradeId, 43 | uint orderId, 44 | bytes32 indexed ticker, 45 | address indexed trader1, 46 | address indexed trader2, 47 | uint amount, 48 | uint price, 49 | uint date 50 | ); 51 | 52 | constructor() public { 53 | admin = msg.sender; 54 | } 55 | 56 | function getOrders( 57 | bytes32 ticker, 58 | Side side) 59 | external 60 | view 61 | returns(Order[] memory) { 62 | return orderBook[ticker][uint(side)]; 63 | } 64 | 65 | function getTokens() 66 | external 67 | view 68 | returns(Token[] memory) { 69 | Token[] memory _tokens = new Token[](tokenList.length); 70 | for (uint i = 0; i < tokenList.length; i++) { 71 | _tokens[i] = Token( 72 | tokens[tokenList[i]].ticker, 73 | tokens[tokenList[i]].tokenAddress 74 | ); 75 | } 76 | return _tokens; 77 | } 78 | 79 | function addToken( 80 | bytes32 ticker, 81 | address tokenAddress) 82 | onlyAdmin() 83 | external { 84 | tokens[ticker] = Token(ticker, tokenAddress); 85 | tokenList.push(ticker); 86 | } 87 | 88 | function deposit( 89 | uint amount, 90 | bytes32 ticker) 91 | tokenExist(ticker) 92 | external { 93 | IERC20(tokens[ticker].tokenAddress).transferFrom( 94 | msg.sender, 95 | address(this), 96 | amount 97 | ); 98 | traderBalances[msg.sender][ticker] = traderBalances[msg.sender][ticker].add(amount); 99 | } 100 | 101 | function withdraw( 102 | uint amount, 103 | bytes32 ticker) 104 | tokenExist(ticker) 105 | external { 106 | require( 107 | traderBalances[msg.sender][ticker] >= amount, 108 | 'balance too low' 109 | ); 110 | traderBalances[msg.sender][ticker] = traderBalances[msg.sender][ticker].sub(amount); 111 | IERC20(tokens[ticker].tokenAddress).transfer(msg.sender, amount); 112 | } 113 | 114 | function createLimitOrder( 115 | bytes32 ticker, 116 | uint amount, 117 | uint price, 118 | Side side) 119 | tokenExist(ticker) 120 | tokenIsNotDai(ticker) 121 | external { 122 | if(side == Side.SELL) { 123 | require( 124 | traderBalances[msg.sender][ticker] >= amount, 125 | 'token balance too low' 126 | ); 127 | } else { 128 | require( 129 | traderBalances[msg.sender][DAI] >= amount.mul(price), 130 | 'dai balance too low' 131 | ); 132 | } 133 | Order[] storage orders = orderBook[ticker][uint(side)]; 134 | orders.push(Order( 135 | nextOrderId, 136 | msg.sender, 137 | side, 138 | ticker, 139 | amount, 140 | 0, 141 | price, 142 | now 143 | )); 144 | 145 | uint i = orders.length > 0 ? orders.length - 1 : 0; 146 | while(i > 0) { 147 | if(side == Side.BUY && orders[i - 1].price > orders[i].price) { 148 | break; 149 | } 150 | if(side == Side.SELL && orders[i - 1].price < orders[i].price) { 151 | break; 152 | } 153 | Order memory order = orders[i - 1]; 154 | orders[i - 1] = orders[i]; 155 | orders[i] = order; 156 | i--; 157 | } 158 | nextOrderId++; 159 | } 160 | 161 | function createMarketOrder( 162 | bytes32 ticker, 163 | uint amount, 164 | Side side) 165 | tokenExist(ticker) 166 | tokenIsNotDai(ticker) 167 | external { 168 | if(side == Side.SELL) { 169 | require( 170 | traderBalances[msg.sender][ticker] >= amount, 171 | 'token balance too low' 172 | ); 173 | } 174 | Order[] storage orders = orderBook[ticker][uint(side == Side.BUY ? Side.SELL : Side.BUY)]; 175 | uint i; 176 | uint remaining = amount; 177 | 178 | while(i < orders.length && remaining > 0) { 179 | uint available = orders[i].amount.sub(orders[i].filled); 180 | uint matched = (remaining > available) ? available : remaining; 181 | remaining = remaining.sub(matched); 182 | orders[i].filled = orders[i].filled.add(matched); 183 | emit NewTrade( 184 | nextTradeId, 185 | orders[i].id, 186 | ticker, 187 | orders[i].trader, 188 | msg.sender, 189 | matched, 190 | orders[i].price, 191 | now 192 | ); 193 | if(side == Side.SELL) { 194 | traderBalances[msg.sender][ticker] = traderBalances[msg.sender][ticker].sub(matched); 195 | traderBalances[msg.sender][DAI] = traderBalances[msg.sender][DAI].add(matched.mul(orders[i].price)); 196 | traderBalances[orders[i].trader][ticker] = traderBalances[orders[i].trader][ticker].add(matched); 197 | traderBalances[orders[i].trader][DAI] = traderBalances[orders[i].trader][DAI].sub(matched.mul(orders[i].price)); 198 | } 199 | if(side == Side.BUY) { 200 | require( 201 | traderBalances[msg.sender][DAI] >= matched.mul(orders[i].price), 202 | 'dai balance too low' 203 | ); 204 | traderBalances[msg.sender][ticker] = traderBalances[msg.sender][ticker].add(matched); 205 | traderBalances[msg.sender][DAI] = traderBalances[msg.sender][DAI].sub(matched.mul(orders[i].price)); 206 | traderBalances[orders[i].trader][ticker] = traderBalances[orders[i].trader][ticker].sub(matched); 207 | traderBalances[orders[i].trader][DAI] = traderBalances[orders[i].trader][DAI].add(matched.mul(orders[i].price)); 208 | } 209 | nextTradeId++; 210 | i++; 211 | } 212 | 213 | i = 0; 214 | while(i < orders.length && orders[i].filled == orders[i].amount) { 215 | for(uint j = i; j < orders.length - 1; j++ ) { 216 | orders[j] = orders[j + 1]; 217 | } 218 | orders.pop(); 219 | i++; 220 | } 221 | } 222 | 223 | modifier tokenIsNotDai(bytes32 ticker) { 224 | require(ticker != DAI, 'cannot trade DAI'); 225 | _; 226 | } 227 | 228 | modifier tokenExist(bytes32 ticker) { 229 | require( 230 | tokens[ticker].tokenAddress != address(0), 231 | 'this token does not exist' 232 | ); 233 | _; 234 | } 235 | 236 | modifier onlyAdmin() { 237 | require(msg.sender == admin, 'only admin'); 238 | _; 239 | } 240 | } 241 | -------------------------------------------------------------------------------- /client/src/contracts/Context.json: -------------------------------------------------------------------------------- 1 | { 2 | "contractName": "Context", 3 | "abi": [ 4 | { 5 | "inputs": [], 6 | "stateMutability": "nonpayable", 7 | "type": "constructor" 8 | } 9 | ], 10 | "metadata": "{\"compiler\":{\"version\":\"0.6.3+commit.8dda9521\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"}],\"devdoc\":{\"methods\":{}},\"userdoc\":{\"methods\":{}}},\"settings\":{\"compilationTarget\":{\"@openzeppelin/contracts/GSN/Context.sol\":\"Context\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":false,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/GSN/Context.sol\":{\"keccak256\":\"0x0de74dfa6b37943c1b834cbd8fb7a8d052e5ff80c7adb33692102dd6cd2985e9\",\"urls\":[\"bzz-raw://9d2d827fcf4a838f5821732c0acd6a40d21c2a5a2cfe2563feec91465f47bb60\",\"dweb:/ipfs/Qmex3wMKf5Sghbfvr288RUg1kP2uAyTMf11w83WbMbpQQc\"]}},\"version\":1}", 11 | "bytecode": "0x", 12 | "deployedBytecode": "0x", 13 | "sourceMap": "", 14 | "deployedSourceMap": "", 15 | "source": "pragma solidity ^0.6.0;\n\n/*\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with GSN meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\ncontract Context {\n // Empty internal constructor, to prevent people from mistakenly deploying\n // an instance of this contract, which should be used via inheritance.\n constructor () internal { }\n\n function _msgSender() internal view virtual returns (address payable) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes memory) {\n this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691\n return msg.data;\n }\n}\n", 16 | "sourcePath": "@openzeppelin\\contracts\\GSN\\Context.sol", 17 | "ast": { 18 | "absolutePath": "@openzeppelin/contracts/GSN/Context.sol", 19 | "exportedSymbols": { 20 | "Context": [ 21 | 1105 22 | ] 23 | }, 24 | "id": 1106, 25 | "nodeType": "SourceUnit", 26 | "nodes": [ 27 | { 28 | "id": 1080, 29 | "literals": [ 30 | "solidity", 31 | "^", 32 | "0.6", 33 | ".0" 34 | ], 35 | "nodeType": "PragmaDirective", 36 | "src": "0:23:6" 37 | }, 38 | { 39 | "abstract": false, 40 | "baseContracts": [], 41 | "contractDependencies": [], 42 | "contractKind": "contract", 43 | "documentation": null, 44 | "fullyImplemented": true, 45 | "id": 1105, 46 | "linearizedBaseContracts": [ 47 | 1105 48 | ], 49 | "name": "Context", 50 | "nodeType": "ContractDefinition", 51 | "nodes": [ 52 | { 53 | "body": { 54 | "id": 1083, 55 | "nodeType": "Block", 56 | "src": "726:3:6", 57 | "statements": [] 58 | }, 59 | "documentation": null, 60 | "id": 1084, 61 | "implemented": true, 62 | "kind": "constructor", 63 | "modifiers": [], 64 | "name": "", 65 | "nodeType": "FunctionDefinition", 66 | "overrides": null, 67 | "parameters": { 68 | "id": 1081, 69 | "nodeType": "ParameterList", 70 | "parameters": [], 71 | "src": "714:2:6" 72 | }, 73 | "returnParameters": { 74 | "id": 1082, 75 | "nodeType": "ParameterList", 76 | "parameters": [], 77 | "src": "726:0:6" 78 | }, 79 | "scope": 1105, 80 | "src": "702:27:6", 81 | "stateMutability": "nonpayable", 82 | "virtual": false, 83 | "visibility": "internal" 84 | }, 85 | { 86 | "body": { 87 | "id": 1092, 88 | "nodeType": "Block", 89 | "src": "805:34:6", 90 | "statements": [ 91 | { 92 | "expression": { 93 | "argumentTypes": null, 94 | "expression": { 95 | "argumentTypes": null, 96 | "id": 1089, 97 | "name": "msg", 98 | "nodeType": "Identifier", 99 | "overloadedDeclarations": [], 100 | "referencedDeclaration": -15, 101 | "src": "822:3:6", 102 | "typeDescriptions": { 103 | "typeIdentifier": "t_magic_message", 104 | "typeString": "msg" 105 | } 106 | }, 107 | "id": 1090, 108 | "isConstant": false, 109 | "isLValue": false, 110 | "isPure": false, 111 | "lValueRequested": false, 112 | "memberName": "sender", 113 | "nodeType": "MemberAccess", 114 | "referencedDeclaration": null, 115 | "src": "822:10:6", 116 | "typeDescriptions": { 117 | "typeIdentifier": "t_address_payable", 118 | "typeString": "address payable" 119 | } 120 | }, 121 | "functionReturnParameters": 1088, 122 | "id": 1091, 123 | "nodeType": "Return", 124 | "src": "815:17:6" 125 | } 126 | ] 127 | }, 128 | "documentation": null, 129 | "id": 1093, 130 | "implemented": true, 131 | "kind": "function", 132 | "modifiers": [], 133 | "name": "_msgSender", 134 | "nodeType": "FunctionDefinition", 135 | "overrides": null, 136 | "parameters": { 137 | "id": 1085, 138 | "nodeType": "ParameterList", 139 | "parameters": [], 140 | "src": "754:2:6" 141 | }, 142 | "returnParameters": { 143 | "id": 1088, 144 | "nodeType": "ParameterList", 145 | "parameters": [ 146 | { 147 | "constant": false, 148 | "id": 1087, 149 | "name": "", 150 | "nodeType": "VariableDeclaration", 151 | "overrides": null, 152 | "scope": 1093, 153 | "src": "788:15:6", 154 | "stateVariable": false, 155 | "storageLocation": "default", 156 | "typeDescriptions": { 157 | "typeIdentifier": "t_address_payable", 158 | "typeString": "address payable" 159 | }, 160 | "typeName": { 161 | "id": 1086, 162 | "name": "address", 163 | "nodeType": "ElementaryTypeName", 164 | "src": "788:15:6", 165 | "stateMutability": "payable", 166 | "typeDescriptions": { 167 | "typeIdentifier": "t_address_payable", 168 | "typeString": "address payable" 169 | } 170 | }, 171 | "value": null, 172 | "visibility": "internal" 173 | } 174 | ], 175 | "src": "787:17:6" 176 | }, 177 | "scope": 1105, 178 | "src": "735:104:6", 179 | "stateMutability": "view", 180 | "virtual": true, 181 | "visibility": "internal" 182 | }, 183 | { 184 | "body": { 185 | "id": 1103, 186 | "nodeType": "Block", 187 | "src": "910:165:6", 188 | "statements": [ 189 | { 190 | "expression": { 191 | "argumentTypes": null, 192 | "id": 1098, 193 | "name": "this", 194 | "nodeType": "Identifier", 195 | "overloadedDeclarations": [], 196 | "referencedDeclaration": -28, 197 | "src": "920:4:6", 198 | "typeDescriptions": { 199 | "typeIdentifier": "t_contract$_Context_$1105", 200 | "typeString": "contract Context" 201 | } 202 | }, 203 | "id": 1099, 204 | "nodeType": "ExpressionStatement", 205 | "src": "920:4:6" 206 | }, 207 | { 208 | "expression": { 209 | "argumentTypes": null, 210 | "expression": { 211 | "argumentTypes": null, 212 | "id": 1100, 213 | "name": "msg", 214 | "nodeType": "Identifier", 215 | "overloadedDeclarations": [], 216 | "referencedDeclaration": -15, 217 | "src": "1060:3:6", 218 | "typeDescriptions": { 219 | "typeIdentifier": "t_magic_message", 220 | "typeString": "msg" 221 | } 222 | }, 223 | "id": 1101, 224 | "isConstant": false, 225 | "isLValue": false, 226 | "isPure": false, 227 | "lValueRequested": false, 228 | "memberName": "data", 229 | "nodeType": "MemberAccess", 230 | "referencedDeclaration": null, 231 | "src": "1060:8:6", 232 | "typeDescriptions": { 233 | "typeIdentifier": "t_bytes_calldata_ptr", 234 | "typeString": "bytes calldata" 235 | } 236 | }, 237 | "functionReturnParameters": 1097, 238 | "id": 1102, 239 | "nodeType": "Return", 240 | "src": "1053:15:6" 241 | } 242 | ] 243 | }, 244 | "documentation": null, 245 | "id": 1104, 246 | "implemented": true, 247 | "kind": "function", 248 | "modifiers": [], 249 | "name": "_msgData", 250 | "nodeType": "FunctionDefinition", 251 | "overrides": null, 252 | "parameters": { 253 | "id": 1094, 254 | "nodeType": "ParameterList", 255 | "parameters": [], 256 | "src": "862:2:6" 257 | }, 258 | "returnParameters": { 259 | "id": 1097, 260 | "nodeType": "ParameterList", 261 | "parameters": [ 262 | { 263 | "constant": false, 264 | "id": 1096, 265 | "name": "", 266 | "nodeType": "VariableDeclaration", 267 | "overrides": null, 268 | "scope": 1104, 269 | "src": "896:12:6", 270 | "stateVariable": false, 271 | "storageLocation": "memory", 272 | "typeDescriptions": { 273 | "typeIdentifier": "t_bytes_memory_ptr", 274 | "typeString": "bytes" 275 | }, 276 | "typeName": { 277 | "id": 1095, 278 | "name": "bytes", 279 | "nodeType": "ElementaryTypeName", 280 | "src": "896:5:6", 281 | "typeDescriptions": { 282 | "typeIdentifier": "t_bytes_storage_ptr", 283 | "typeString": "bytes" 284 | } 285 | }, 286 | "value": null, 287 | "visibility": "internal" 288 | } 289 | ], 290 | "src": "895:14:6" 291 | }, 292 | "scope": 1105, 293 | "src": "845:230:6", 294 | "stateMutability": "view", 295 | "virtual": true, 296 | "visibility": "internal" 297 | } 298 | ], 299 | "scope": 1106, 300 | "src": "525:552:6" 301 | } 302 | ], 303 | "src": "0:1078:6" 304 | }, 305 | "legacyAST": { 306 | "absolutePath": "@openzeppelin/contracts/GSN/Context.sol", 307 | "exportedSymbols": { 308 | "Context": [ 309 | 1105 310 | ] 311 | }, 312 | "id": 1106, 313 | "nodeType": "SourceUnit", 314 | "nodes": [ 315 | { 316 | "id": 1080, 317 | "literals": [ 318 | "solidity", 319 | "^", 320 | "0.6", 321 | ".0" 322 | ], 323 | "nodeType": "PragmaDirective", 324 | "src": "0:23:6" 325 | }, 326 | { 327 | "abstract": false, 328 | "baseContracts": [], 329 | "contractDependencies": [], 330 | "contractKind": "contract", 331 | "documentation": null, 332 | "fullyImplemented": true, 333 | "id": 1105, 334 | "linearizedBaseContracts": [ 335 | 1105 336 | ], 337 | "name": "Context", 338 | "nodeType": "ContractDefinition", 339 | "nodes": [ 340 | { 341 | "body": { 342 | "id": 1083, 343 | "nodeType": "Block", 344 | "src": "726:3:6", 345 | "statements": [] 346 | }, 347 | "documentation": null, 348 | "id": 1084, 349 | "implemented": true, 350 | "kind": "constructor", 351 | "modifiers": [], 352 | "name": "", 353 | "nodeType": "FunctionDefinition", 354 | "overrides": null, 355 | "parameters": { 356 | "id": 1081, 357 | "nodeType": "ParameterList", 358 | "parameters": [], 359 | "src": "714:2:6" 360 | }, 361 | "returnParameters": { 362 | "id": 1082, 363 | "nodeType": "ParameterList", 364 | "parameters": [], 365 | "src": "726:0:6" 366 | }, 367 | "scope": 1105, 368 | "src": "702:27:6", 369 | "stateMutability": "nonpayable", 370 | "virtual": false, 371 | "visibility": "internal" 372 | }, 373 | { 374 | "body": { 375 | "id": 1092, 376 | "nodeType": "Block", 377 | "src": "805:34:6", 378 | "statements": [ 379 | { 380 | "expression": { 381 | "argumentTypes": null, 382 | "expression": { 383 | "argumentTypes": null, 384 | "id": 1089, 385 | "name": "msg", 386 | "nodeType": "Identifier", 387 | "overloadedDeclarations": [], 388 | "referencedDeclaration": -15, 389 | "src": "822:3:6", 390 | "typeDescriptions": { 391 | "typeIdentifier": "t_magic_message", 392 | "typeString": "msg" 393 | } 394 | }, 395 | "id": 1090, 396 | "isConstant": false, 397 | "isLValue": false, 398 | "isPure": false, 399 | "lValueRequested": false, 400 | "memberName": "sender", 401 | "nodeType": "MemberAccess", 402 | "referencedDeclaration": null, 403 | "src": "822:10:6", 404 | "typeDescriptions": { 405 | "typeIdentifier": "t_address_payable", 406 | "typeString": "address payable" 407 | } 408 | }, 409 | "functionReturnParameters": 1088, 410 | "id": 1091, 411 | "nodeType": "Return", 412 | "src": "815:17:6" 413 | } 414 | ] 415 | }, 416 | "documentation": null, 417 | "id": 1093, 418 | "implemented": true, 419 | "kind": "function", 420 | "modifiers": [], 421 | "name": "_msgSender", 422 | "nodeType": "FunctionDefinition", 423 | "overrides": null, 424 | "parameters": { 425 | "id": 1085, 426 | "nodeType": "ParameterList", 427 | "parameters": [], 428 | "src": "754:2:6" 429 | }, 430 | "returnParameters": { 431 | "id": 1088, 432 | "nodeType": "ParameterList", 433 | "parameters": [ 434 | { 435 | "constant": false, 436 | "id": 1087, 437 | "name": "", 438 | "nodeType": "VariableDeclaration", 439 | "overrides": null, 440 | "scope": 1093, 441 | "src": "788:15:6", 442 | "stateVariable": false, 443 | "storageLocation": "default", 444 | "typeDescriptions": { 445 | "typeIdentifier": "t_address_payable", 446 | "typeString": "address payable" 447 | }, 448 | "typeName": { 449 | "id": 1086, 450 | "name": "address", 451 | "nodeType": "ElementaryTypeName", 452 | "src": "788:15:6", 453 | "stateMutability": "payable", 454 | "typeDescriptions": { 455 | "typeIdentifier": "t_address_payable", 456 | "typeString": "address payable" 457 | } 458 | }, 459 | "value": null, 460 | "visibility": "internal" 461 | } 462 | ], 463 | "src": "787:17:6" 464 | }, 465 | "scope": 1105, 466 | "src": "735:104:6", 467 | "stateMutability": "view", 468 | "virtual": true, 469 | "visibility": "internal" 470 | }, 471 | { 472 | "body": { 473 | "id": 1103, 474 | "nodeType": "Block", 475 | "src": "910:165:6", 476 | "statements": [ 477 | { 478 | "expression": { 479 | "argumentTypes": null, 480 | "id": 1098, 481 | "name": "this", 482 | "nodeType": "Identifier", 483 | "overloadedDeclarations": [], 484 | "referencedDeclaration": -28, 485 | "src": "920:4:6", 486 | "typeDescriptions": { 487 | "typeIdentifier": "t_contract$_Context_$1105", 488 | "typeString": "contract Context" 489 | } 490 | }, 491 | "id": 1099, 492 | "nodeType": "ExpressionStatement", 493 | "src": "920:4:6" 494 | }, 495 | { 496 | "expression": { 497 | "argumentTypes": null, 498 | "expression": { 499 | "argumentTypes": null, 500 | "id": 1100, 501 | "name": "msg", 502 | "nodeType": "Identifier", 503 | "overloadedDeclarations": [], 504 | "referencedDeclaration": -15, 505 | "src": "1060:3:6", 506 | "typeDescriptions": { 507 | "typeIdentifier": "t_magic_message", 508 | "typeString": "msg" 509 | } 510 | }, 511 | "id": 1101, 512 | "isConstant": false, 513 | "isLValue": false, 514 | "isPure": false, 515 | "lValueRequested": false, 516 | "memberName": "data", 517 | "nodeType": "MemberAccess", 518 | "referencedDeclaration": null, 519 | "src": "1060:8:6", 520 | "typeDescriptions": { 521 | "typeIdentifier": "t_bytes_calldata_ptr", 522 | "typeString": "bytes calldata" 523 | } 524 | }, 525 | "functionReturnParameters": 1097, 526 | "id": 1102, 527 | "nodeType": "Return", 528 | "src": "1053:15:6" 529 | } 530 | ] 531 | }, 532 | "documentation": null, 533 | "id": 1104, 534 | "implemented": true, 535 | "kind": "function", 536 | "modifiers": [], 537 | "name": "_msgData", 538 | "nodeType": "FunctionDefinition", 539 | "overrides": null, 540 | "parameters": { 541 | "id": 1094, 542 | "nodeType": "ParameterList", 543 | "parameters": [], 544 | "src": "862:2:6" 545 | }, 546 | "returnParameters": { 547 | "id": 1097, 548 | "nodeType": "ParameterList", 549 | "parameters": [ 550 | { 551 | "constant": false, 552 | "id": 1096, 553 | "name": "", 554 | "nodeType": "VariableDeclaration", 555 | "overrides": null, 556 | "scope": 1104, 557 | "src": "896:12:6", 558 | "stateVariable": false, 559 | "storageLocation": "memory", 560 | "typeDescriptions": { 561 | "typeIdentifier": "t_bytes_memory_ptr", 562 | "typeString": "bytes" 563 | }, 564 | "typeName": { 565 | "id": 1095, 566 | "name": "bytes", 567 | "nodeType": "ElementaryTypeName", 568 | "src": "896:5:6", 569 | "typeDescriptions": { 570 | "typeIdentifier": "t_bytes_storage_ptr", 571 | "typeString": "bytes" 572 | } 573 | }, 574 | "value": null, 575 | "visibility": "internal" 576 | } 577 | ], 578 | "src": "895:14:6" 579 | }, 580 | "scope": 1105, 581 | "src": "845:230:6", 582 | "stateMutability": "view", 583 | "virtual": true, 584 | "visibility": "internal" 585 | } 586 | ], 587 | "scope": 1106, 588 | "src": "525:552:6" 589 | } 590 | ], 591 | "src": "0:1078:6" 592 | }, 593 | "compiler": { 594 | "name": "solc", 595 | "version": "0.6.3+commit.8dda9521.Emscripten.clang" 596 | }, 597 | "networks": {}, 598 | "schemaVersion": "3.2.1", 599 | "updatedAt": "2020-07-08T06:32:01.061Z", 600 | "devdoc": { 601 | "methods": {} 602 | }, 603 | "userdoc": { 604 | "methods": {} 605 | } 606 | } -------------------------------------------------------------------------------- /client/src/contracts/Migrations.json: -------------------------------------------------------------------------------- 1 | { 2 | "contractName": "Migrations", 3 | "abi": [ 4 | { 5 | "inputs": [], 6 | "stateMutability": "nonpayable", 7 | "type": "constructor" 8 | }, 9 | { 10 | "inputs": [], 11 | "name": "last_completed_migration", 12 | "outputs": [ 13 | { 14 | "internalType": "uint256", 15 | "name": "", 16 | "type": "uint256" 17 | } 18 | ], 19 | "stateMutability": "view", 20 | "type": "function", 21 | "constant": true 22 | }, 23 | { 24 | "inputs": [], 25 | "name": "owner", 26 | "outputs": [ 27 | { 28 | "internalType": "address", 29 | "name": "", 30 | "type": "address" 31 | } 32 | ], 33 | "stateMutability": "view", 34 | "type": "function", 35 | "constant": true 36 | }, 37 | { 38 | "inputs": [ 39 | { 40 | "internalType": "uint256", 41 | "name": "completed", 42 | "type": "uint256" 43 | } 44 | ], 45 | "name": "setCompleted", 46 | "outputs": [], 47 | "stateMutability": "nonpayable", 48 | "type": "function" 49 | }, 50 | { 51 | "inputs": [ 52 | { 53 | "internalType": "address", 54 | "name": "new_address", 55 | "type": "address" 56 | } 57 | ], 58 | "name": "upgrade", 59 | "outputs": [], 60 | "stateMutability": "nonpayable", 61 | "type": "function" 62 | } 63 | ], 64 | "metadata": "{\"compiler\":{\"version\":\"0.6.3+commit.8dda9521\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"last_completed_migration\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"completed\",\"type\":\"uint256\"}],\"name\":\"setCompleted\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"new_address\",\"type\":\"address\"}],\"name\":\"upgrade\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"methods\":{}},\"userdoc\":{\"methods\":{}}},\"settings\":{\"compilationTarget\":{\"/D/eattheblocks/blockchain-masterclass/dex-3-frontend/12-integrate-wallet-into-app/contracts/Migrations.sol\":\"Migrations\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":false,\"runs\":200},\"remappings\":[]},\"sources\":{\"/D/eattheblocks/blockchain-masterclass/dex-3-frontend/12-integrate-wallet-into-app/contracts/Migrations.sol\":{\"keccak256\":\"0x93305974f35accb3dfa6008c440d1b95df9444a275836009dce75235bf09d767\",\"urls\":[\"bzz-raw://ceba15b32375ba34f9570651bd464e78f3ba8db3d16e3bed70e33291bd28aa17\",\"dweb:/ipfs/QmSQuZr5xb966FAJUU6k7a2KEoCmm4uJpUtzjKKcttWCHC\"]}},\"version\":1}", 65 | "bytecode": "0x608060405234801561001057600080fd5b50336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506102b8806100606000396000f3fe608060405234801561001057600080fd5b506004361061004c5760003560e01c80630900f01014610051578063445df0ac146100955780638da5cb5b146100b3578063fdacd576146100fd575b600080fd5b6100936004803603602081101561006757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061012b565b005b61009d6101f7565b6040518082815260200191505060405180910390f35b6100bb6101fd565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6101296004803603602081101561011357600080fd5b8101908080359060200190929190505050610222565b005b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156101f45760008190508073ffffffffffffffffffffffffffffffffffffffff1663fdacd5766001546040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b1580156101da57600080fd5b505af11580156101ee573d6000803e3d6000fd5b50505050505b50565b60015481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561027f57806001819055505b5056fea26469706673582212207819bdfa5fd79378e89c1c910b70889f66ba87047bfb3b55bb0dd2f99797012e64736f6c63430006030033", 66 | "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061004c5760003560e01c80630900f01014610051578063445df0ac146100955780638da5cb5b146100b3578063fdacd576146100fd575b600080fd5b6100936004803603602081101561006757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061012b565b005b61009d6101f7565b6040518082815260200191505060405180910390f35b6100bb6101fd565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6101296004803603602081101561011357600080fd5b8101908080359060200190929190505050610222565b005b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156101f45760008190508073ffffffffffffffffffffffffffffffffffffffff1663fdacd5766001546040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b1580156101da57600080fd5b505af11580156101ee573d6000803e3d6000fd5b50505050505b50565b60015481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561027f57806001819055505b5056fea26469706673582212207819bdfa5fd79378e89c1c910b70889f66ba87047bfb3b55bb0dd2f99797012e64736f6c63430006030033", 67 | "sourceMap": "26:540:1:-:0;;;125:58;5:9:-1;2:2;;;27:1;24;17:12;2:2;125:58:1;165:10;157:5;;:18;;;;;;;;;;;;;;;;;;26:540;;;;;;", 68 | "deployedSourceMap": "26:540:1:-:0;;;;5:9:-1;2:2;;;27:1;24;17:12;2:2;26:540:1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;12:1:-1;9;2:12;385:178:1;;;;;;15:2:-1;10:3;7:11;4:2;;;31:1;28;21:12;4:2;385:178:1;;;;;;;;;;;;;;;;;;;:::i;:::-;;80:36;;;:::i;:::-;;;;;;;;;;;;;;;;;;;53:20;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;266:111;;;;;;15:2:-1;10:3;7:11;4:2;;;31:1;28;21:12;4:2;266:111:1;;;;;;;;;;;;;;;;;:::i;:::-;;385:178;242:5;;;;;;;;;;;228:19;;:10;:19;;;224:26;;;452:19:::1;485:11;452:45;;508:8;:21;;;530:24;;508:47;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;5:9:-1;2:2;;;27:1;24::::0;17:12:::1;2:2;508:47:1;;;;8:9:-1;5:2;;;45:16;42:1;39::::0;24:38:::1;77:16;74:1;67:27;5:2;508:47:1;;;;249:1;224:26:::0;385:178;:::o;80:36::-;;;;:::o;53:20::-;;;;;;;;;;;;;:::o;266:111::-;242:5;;;;;;;;;;;228:19;;:10;:19;;;224:26;;;360:9:::1;333:24;:36;;;;224:26:::0;266:111;:::o", 69 | "source": "pragma solidity 0.6.3;\r\n\r\ncontract Migrations {\r\n address public owner;\r\n uint public last_completed_migration;\r\n\r\n constructor() public {\r\n owner = msg.sender;\r\n }\r\n\r\n modifier restricted() {\r\n if (msg.sender == owner) _;\r\n }\r\n\r\n function setCompleted(uint completed) public restricted {\r\n last_completed_migration = completed;\r\n }\r\n\r\n function upgrade(address new_address) public restricted {\r\n Migrations upgraded = Migrations(new_address);\r\n upgraded.setCompleted(last_completed_migration);\r\n }\r\n}\r\n", 70 | "sourcePath": "D:\\eattheblocks\\blockchain-masterclass\\dex-3-frontend\\12-integrate-wallet-into-app\\contracts\\Migrations.sol", 71 | "ast": { 72 | "absolutePath": "/D/eattheblocks/blockchain-masterclass/dex-3-frontend/12-integrate-wallet-into-app/contracts/Migrations.sol", 73 | "exportedSymbols": { 74 | "Migrations": [ 75 | 954 76 | ] 77 | }, 78 | "id": 955, 79 | "nodeType": "SourceUnit", 80 | "nodes": [ 81 | { 82 | "id": 899, 83 | "literals": [ 84 | "solidity", 85 | "0.6", 86 | ".3" 87 | ], 88 | "nodeType": "PragmaDirective", 89 | "src": "0:22:1" 90 | }, 91 | { 92 | "abstract": false, 93 | "baseContracts": [], 94 | "contractDependencies": [], 95 | "contractKind": "contract", 96 | "documentation": null, 97 | "fullyImplemented": true, 98 | "id": 954, 99 | "linearizedBaseContracts": [ 100 | 954 101 | ], 102 | "name": "Migrations", 103 | "nodeType": "ContractDefinition", 104 | "nodes": [ 105 | { 106 | "constant": false, 107 | "functionSelector": "8da5cb5b", 108 | "id": 901, 109 | "name": "owner", 110 | "nodeType": "VariableDeclaration", 111 | "overrides": null, 112 | "scope": 954, 113 | "src": "53:20:1", 114 | "stateVariable": true, 115 | "storageLocation": "default", 116 | "typeDescriptions": { 117 | "typeIdentifier": "t_address", 118 | "typeString": "address" 119 | }, 120 | "typeName": { 121 | "id": 900, 122 | "name": "address", 123 | "nodeType": "ElementaryTypeName", 124 | "src": "53:7:1", 125 | "stateMutability": "nonpayable", 126 | "typeDescriptions": { 127 | "typeIdentifier": "t_address", 128 | "typeString": "address" 129 | } 130 | }, 131 | "value": null, 132 | "visibility": "public" 133 | }, 134 | { 135 | "constant": false, 136 | "functionSelector": "445df0ac", 137 | "id": 903, 138 | "name": "last_completed_migration", 139 | "nodeType": "VariableDeclaration", 140 | "overrides": null, 141 | "scope": 954, 142 | "src": "80:36:1", 143 | "stateVariable": true, 144 | "storageLocation": "default", 145 | "typeDescriptions": { 146 | "typeIdentifier": "t_uint256", 147 | "typeString": "uint256" 148 | }, 149 | "typeName": { 150 | "id": 902, 151 | "name": "uint", 152 | "nodeType": "ElementaryTypeName", 153 | "src": "80:4:1", 154 | "typeDescriptions": { 155 | "typeIdentifier": "t_uint256", 156 | "typeString": "uint256" 157 | } 158 | }, 159 | "value": null, 160 | "visibility": "public" 161 | }, 162 | { 163 | "body": { 164 | "id": 911, 165 | "nodeType": "Block", 166 | "src": "146:37:1", 167 | "statements": [ 168 | { 169 | "expression": { 170 | "argumentTypes": null, 171 | "id": 909, 172 | "isConstant": false, 173 | "isLValue": false, 174 | "isPure": false, 175 | "lValueRequested": false, 176 | "leftHandSide": { 177 | "argumentTypes": null, 178 | "id": 906, 179 | "name": "owner", 180 | "nodeType": "Identifier", 181 | "overloadedDeclarations": [], 182 | "referencedDeclaration": 901, 183 | "src": "157:5:1", 184 | "typeDescriptions": { 185 | "typeIdentifier": "t_address", 186 | "typeString": "address" 187 | } 188 | }, 189 | "nodeType": "Assignment", 190 | "operator": "=", 191 | "rightHandSide": { 192 | "argumentTypes": null, 193 | "expression": { 194 | "argumentTypes": null, 195 | "id": 907, 196 | "name": "msg", 197 | "nodeType": "Identifier", 198 | "overloadedDeclarations": [], 199 | "referencedDeclaration": -15, 200 | "src": "165:3:1", 201 | "typeDescriptions": { 202 | "typeIdentifier": "t_magic_message", 203 | "typeString": "msg" 204 | } 205 | }, 206 | "id": 908, 207 | "isConstant": false, 208 | "isLValue": false, 209 | "isPure": false, 210 | "lValueRequested": false, 211 | "memberName": "sender", 212 | "nodeType": "MemberAccess", 213 | "referencedDeclaration": null, 214 | "src": "165:10:1", 215 | "typeDescriptions": { 216 | "typeIdentifier": "t_address_payable", 217 | "typeString": "address payable" 218 | } 219 | }, 220 | "src": "157:18:1", 221 | "typeDescriptions": { 222 | "typeIdentifier": "t_address", 223 | "typeString": "address" 224 | } 225 | }, 226 | "id": 910, 227 | "nodeType": "ExpressionStatement", 228 | "src": "157:18:1" 229 | } 230 | ] 231 | }, 232 | "documentation": null, 233 | "id": 912, 234 | "implemented": true, 235 | "kind": "constructor", 236 | "modifiers": [], 237 | "name": "", 238 | "nodeType": "FunctionDefinition", 239 | "overrides": null, 240 | "parameters": { 241 | "id": 904, 242 | "nodeType": "ParameterList", 243 | "parameters": [], 244 | "src": "136:2:1" 245 | }, 246 | "returnParameters": { 247 | "id": 905, 248 | "nodeType": "ParameterList", 249 | "parameters": [], 250 | "src": "146:0:1" 251 | }, 252 | "scope": 954, 253 | "src": "125:58:1", 254 | "stateMutability": "nonpayable", 255 | "virtual": false, 256 | "visibility": "public" 257 | }, 258 | { 259 | "body": { 260 | "id": 920, 261 | "nodeType": "Block", 262 | "src": "213:45:1", 263 | "statements": [ 264 | { 265 | "condition": { 266 | "argumentTypes": null, 267 | "commonType": { 268 | "typeIdentifier": "t_address", 269 | "typeString": "address" 270 | }, 271 | "id": 917, 272 | "isConstant": false, 273 | "isLValue": false, 274 | "isPure": false, 275 | "lValueRequested": false, 276 | "leftExpression": { 277 | "argumentTypes": null, 278 | "expression": { 279 | "argumentTypes": null, 280 | "id": 914, 281 | "name": "msg", 282 | "nodeType": "Identifier", 283 | "overloadedDeclarations": [], 284 | "referencedDeclaration": -15, 285 | "src": "228:3:1", 286 | "typeDescriptions": { 287 | "typeIdentifier": "t_magic_message", 288 | "typeString": "msg" 289 | } 290 | }, 291 | "id": 915, 292 | "isConstant": false, 293 | "isLValue": false, 294 | "isPure": false, 295 | "lValueRequested": false, 296 | "memberName": "sender", 297 | "nodeType": "MemberAccess", 298 | "referencedDeclaration": null, 299 | "src": "228:10:1", 300 | "typeDescriptions": { 301 | "typeIdentifier": "t_address_payable", 302 | "typeString": "address payable" 303 | } 304 | }, 305 | "nodeType": "BinaryOperation", 306 | "operator": "==", 307 | "rightExpression": { 308 | "argumentTypes": null, 309 | "id": 916, 310 | "name": "owner", 311 | "nodeType": "Identifier", 312 | "overloadedDeclarations": [], 313 | "referencedDeclaration": 901, 314 | "src": "242:5:1", 315 | "typeDescriptions": { 316 | "typeIdentifier": "t_address", 317 | "typeString": "address" 318 | } 319 | }, 320 | "src": "228:19:1", 321 | "typeDescriptions": { 322 | "typeIdentifier": "t_bool", 323 | "typeString": "bool" 324 | } 325 | }, 326 | "falseBody": null, 327 | "id": 919, 328 | "nodeType": "IfStatement", 329 | "src": "224:26:1", 330 | "trueBody": { 331 | "id": 918, 332 | "nodeType": "PlaceholderStatement", 333 | "src": "249:1:1" 334 | } 335 | } 336 | ] 337 | }, 338 | "documentation": null, 339 | "id": 921, 340 | "name": "restricted", 341 | "nodeType": "ModifierDefinition", 342 | "overrides": null, 343 | "parameters": { 344 | "id": 913, 345 | "nodeType": "ParameterList", 346 | "parameters": [], 347 | "src": "210:2:1" 348 | }, 349 | "src": "191:67:1", 350 | "virtual": false, 351 | "visibility": "internal" 352 | }, 353 | { 354 | "body": { 355 | "id": 932, 356 | "nodeType": "Block", 357 | "src": "322:55:1", 358 | "statements": [ 359 | { 360 | "expression": { 361 | "argumentTypes": null, 362 | "id": 930, 363 | "isConstant": false, 364 | "isLValue": false, 365 | "isPure": false, 366 | "lValueRequested": false, 367 | "leftHandSide": { 368 | "argumentTypes": null, 369 | "id": 928, 370 | "name": "last_completed_migration", 371 | "nodeType": "Identifier", 372 | "overloadedDeclarations": [], 373 | "referencedDeclaration": 903, 374 | "src": "333:24:1", 375 | "typeDescriptions": { 376 | "typeIdentifier": "t_uint256", 377 | "typeString": "uint256" 378 | } 379 | }, 380 | "nodeType": "Assignment", 381 | "operator": "=", 382 | "rightHandSide": { 383 | "argumentTypes": null, 384 | "id": 929, 385 | "name": "completed", 386 | "nodeType": "Identifier", 387 | "overloadedDeclarations": [], 388 | "referencedDeclaration": 923, 389 | "src": "360:9:1", 390 | "typeDescriptions": { 391 | "typeIdentifier": "t_uint256", 392 | "typeString": "uint256" 393 | } 394 | }, 395 | "src": "333:36:1", 396 | "typeDescriptions": { 397 | "typeIdentifier": "t_uint256", 398 | "typeString": "uint256" 399 | } 400 | }, 401 | "id": 931, 402 | "nodeType": "ExpressionStatement", 403 | "src": "333:36:1" 404 | } 405 | ] 406 | }, 407 | "documentation": null, 408 | "functionSelector": "fdacd576", 409 | "id": 933, 410 | "implemented": true, 411 | "kind": "function", 412 | "modifiers": [ 413 | { 414 | "arguments": null, 415 | "id": 926, 416 | "modifierName": { 417 | "argumentTypes": null, 418 | "id": 925, 419 | "name": "restricted", 420 | "nodeType": "Identifier", 421 | "overloadedDeclarations": [], 422 | "referencedDeclaration": 921, 423 | "src": "311:10:1", 424 | "typeDescriptions": { 425 | "typeIdentifier": "t_modifier$__$", 426 | "typeString": "modifier ()" 427 | } 428 | }, 429 | "nodeType": "ModifierInvocation", 430 | "src": "311:10:1" 431 | } 432 | ], 433 | "name": "setCompleted", 434 | "nodeType": "FunctionDefinition", 435 | "overrides": null, 436 | "parameters": { 437 | "id": 924, 438 | "nodeType": "ParameterList", 439 | "parameters": [ 440 | { 441 | "constant": false, 442 | "id": 923, 443 | "name": "completed", 444 | "nodeType": "VariableDeclaration", 445 | "overrides": null, 446 | "scope": 933, 447 | "src": "288:14:1", 448 | "stateVariable": false, 449 | "storageLocation": "default", 450 | "typeDescriptions": { 451 | "typeIdentifier": "t_uint256", 452 | "typeString": "uint256" 453 | }, 454 | "typeName": { 455 | "id": 922, 456 | "name": "uint", 457 | "nodeType": "ElementaryTypeName", 458 | "src": "288:4:1", 459 | "typeDescriptions": { 460 | "typeIdentifier": "t_uint256", 461 | "typeString": "uint256" 462 | } 463 | }, 464 | "value": null, 465 | "visibility": "internal" 466 | } 467 | ], 468 | "src": "287:16:1" 469 | }, 470 | "returnParameters": { 471 | "id": 927, 472 | "nodeType": "ParameterList", 473 | "parameters": [], 474 | "src": "322:0:1" 475 | }, 476 | "scope": 954, 477 | "src": "266:111:1", 478 | "stateMutability": "nonpayable", 479 | "virtual": false, 480 | "visibility": "public" 481 | }, 482 | { 483 | "body": { 484 | "id": 952, 485 | "nodeType": "Block", 486 | "src": "441:122:1", 487 | "statements": [ 488 | { 489 | "assignments": [ 490 | 941 491 | ], 492 | "declarations": [ 493 | { 494 | "constant": false, 495 | "id": 941, 496 | "name": "upgraded", 497 | "nodeType": "VariableDeclaration", 498 | "overrides": null, 499 | "scope": 952, 500 | "src": "452:19:1", 501 | "stateVariable": false, 502 | "storageLocation": "default", 503 | "typeDescriptions": { 504 | "typeIdentifier": "t_contract$_Migrations_$954", 505 | "typeString": "contract Migrations" 506 | }, 507 | "typeName": { 508 | "contractScope": null, 509 | "id": 940, 510 | "name": "Migrations", 511 | "nodeType": "UserDefinedTypeName", 512 | "referencedDeclaration": 954, 513 | "src": "452:10:1", 514 | "typeDescriptions": { 515 | "typeIdentifier": "t_contract$_Migrations_$954", 516 | "typeString": "contract Migrations" 517 | } 518 | }, 519 | "value": null, 520 | "visibility": "internal" 521 | } 522 | ], 523 | "id": 945, 524 | "initialValue": { 525 | "argumentTypes": null, 526 | "arguments": [ 527 | { 528 | "argumentTypes": null, 529 | "id": 943, 530 | "name": "new_address", 531 | "nodeType": "Identifier", 532 | "overloadedDeclarations": [], 533 | "referencedDeclaration": 935, 534 | "src": "485:11:1", 535 | "typeDescriptions": { 536 | "typeIdentifier": "t_address", 537 | "typeString": "address" 538 | } 539 | } 540 | ], 541 | "expression": { 542 | "argumentTypes": [ 543 | { 544 | "typeIdentifier": "t_address", 545 | "typeString": "address" 546 | } 547 | ], 548 | "id": 942, 549 | "name": "Migrations", 550 | "nodeType": "Identifier", 551 | "overloadedDeclarations": [], 552 | "referencedDeclaration": 954, 553 | "src": "474:10:1", 554 | "typeDescriptions": { 555 | "typeIdentifier": "t_type$_t_contract$_Migrations_$954_$", 556 | "typeString": "type(contract Migrations)" 557 | } 558 | }, 559 | "id": 944, 560 | "isConstant": false, 561 | "isLValue": false, 562 | "isPure": false, 563 | "kind": "typeConversion", 564 | "lValueRequested": false, 565 | "names": [], 566 | "nodeType": "FunctionCall", 567 | "src": "474:23:1", 568 | "tryCall": false, 569 | "typeDescriptions": { 570 | "typeIdentifier": "t_contract$_Migrations_$954", 571 | "typeString": "contract Migrations" 572 | } 573 | }, 574 | "nodeType": "VariableDeclarationStatement", 575 | "src": "452:45:1" 576 | }, 577 | { 578 | "expression": { 579 | "argumentTypes": null, 580 | "arguments": [ 581 | { 582 | "argumentTypes": null, 583 | "id": 949, 584 | "name": "last_completed_migration", 585 | "nodeType": "Identifier", 586 | "overloadedDeclarations": [], 587 | "referencedDeclaration": 903, 588 | "src": "530:24:1", 589 | "typeDescriptions": { 590 | "typeIdentifier": "t_uint256", 591 | "typeString": "uint256" 592 | } 593 | } 594 | ], 595 | "expression": { 596 | "argumentTypes": [ 597 | { 598 | "typeIdentifier": "t_uint256", 599 | "typeString": "uint256" 600 | } 601 | ], 602 | "expression": { 603 | "argumentTypes": null, 604 | "id": 946, 605 | "name": "upgraded", 606 | "nodeType": "Identifier", 607 | "overloadedDeclarations": [], 608 | "referencedDeclaration": 941, 609 | "src": "508:8:1", 610 | "typeDescriptions": { 611 | "typeIdentifier": "t_contract$_Migrations_$954", 612 | "typeString": "contract Migrations" 613 | } 614 | }, 615 | "id": 948, 616 | "isConstant": false, 617 | "isLValue": false, 618 | "isPure": false, 619 | "lValueRequested": false, 620 | "memberName": "setCompleted", 621 | "nodeType": "MemberAccess", 622 | "referencedDeclaration": 933, 623 | "src": "508:21:1", 624 | "typeDescriptions": { 625 | "typeIdentifier": "t_function_external_nonpayable$_t_uint256_$returns$__$", 626 | "typeString": "function (uint256) external" 627 | } 628 | }, 629 | "id": 950, 630 | "isConstant": false, 631 | "isLValue": false, 632 | "isPure": false, 633 | "kind": "functionCall", 634 | "lValueRequested": false, 635 | "names": [], 636 | "nodeType": "FunctionCall", 637 | "src": "508:47:1", 638 | "tryCall": false, 639 | "typeDescriptions": { 640 | "typeIdentifier": "t_tuple$__$", 641 | "typeString": "tuple()" 642 | } 643 | }, 644 | "id": 951, 645 | "nodeType": "ExpressionStatement", 646 | "src": "508:47:1" 647 | } 648 | ] 649 | }, 650 | "documentation": null, 651 | "functionSelector": "0900f010", 652 | "id": 953, 653 | "implemented": true, 654 | "kind": "function", 655 | "modifiers": [ 656 | { 657 | "arguments": null, 658 | "id": 938, 659 | "modifierName": { 660 | "argumentTypes": null, 661 | "id": 937, 662 | "name": "restricted", 663 | "nodeType": "Identifier", 664 | "overloadedDeclarations": [], 665 | "referencedDeclaration": 921, 666 | "src": "430:10:1", 667 | "typeDescriptions": { 668 | "typeIdentifier": "t_modifier$__$", 669 | "typeString": "modifier ()" 670 | } 671 | }, 672 | "nodeType": "ModifierInvocation", 673 | "src": "430:10:1" 674 | } 675 | ], 676 | "name": "upgrade", 677 | "nodeType": "FunctionDefinition", 678 | "overrides": null, 679 | "parameters": { 680 | "id": 936, 681 | "nodeType": "ParameterList", 682 | "parameters": [ 683 | { 684 | "constant": false, 685 | "id": 935, 686 | "name": "new_address", 687 | "nodeType": "VariableDeclaration", 688 | "overrides": null, 689 | "scope": 953, 690 | "src": "402:19:1", 691 | "stateVariable": false, 692 | "storageLocation": "default", 693 | "typeDescriptions": { 694 | "typeIdentifier": "t_address", 695 | "typeString": "address" 696 | }, 697 | "typeName": { 698 | "id": 934, 699 | "name": "address", 700 | "nodeType": "ElementaryTypeName", 701 | "src": "402:7:1", 702 | "stateMutability": "nonpayable", 703 | "typeDescriptions": { 704 | "typeIdentifier": "t_address", 705 | "typeString": "address" 706 | } 707 | }, 708 | "value": null, 709 | "visibility": "internal" 710 | } 711 | ], 712 | "src": "401:21:1" 713 | }, 714 | "returnParameters": { 715 | "id": 939, 716 | "nodeType": "ParameterList", 717 | "parameters": [], 718 | "src": "441:0:1" 719 | }, 720 | "scope": 954, 721 | "src": "385:178:1", 722 | "stateMutability": "nonpayable", 723 | "virtual": false, 724 | "visibility": "public" 725 | } 726 | ], 727 | "scope": 955, 728 | "src": "26:540:1" 729 | } 730 | ], 731 | "src": "0:568:1" 732 | }, 733 | "legacyAST": { 734 | "absolutePath": "/D/eattheblocks/blockchain-masterclass/dex-3-frontend/12-integrate-wallet-into-app/contracts/Migrations.sol", 735 | "exportedSymbols": { 736 | "Migrations": [ 737 | 954 738 | ] 739 | }, 740 | "id": 955, 741 | "nodeType": "SourceUnit", 742 | "nodes": [ 743 | { 744 | "id": 899, 745 | "literals": [ 746 | "solidity", 747 | "0.6", 748 | ".3" 749 | ], 750 | "nodeType": "PragmaDirective", 751 | "src": "0:22:1" 752 | }, 753 | { 754 | "abstract": false, 755 | "baseContracts": [], 756 | "contractDependencies": [], 757 | "contractKind": "contract", 758 | "documentation": null, 759 | "fullyImplemented": true, 760 | "id": 954, 761 | "linearizedBaseContracts": [ 762 | 954 763 | ], 764 | "name": "Migrations", 765 | "nodeType": "ContractDefinition", 766 | "nodes": [ 767 | { 768 | "constant": false, 769 | "functionSelector": "8da5cb5b", 770 | "id": 901, 771 | "name": "owner", 772 | "nodeType": "VariableDeclaration", 773 | "overrides": null, 774 | "scope": 954, 775 | "src": "53:20:1", 776 | "stateVariable": true, 777 | "storageLocation": "default", 778 | "typeDescriptions": { 779 | "typeIdentifier": "t_address", 780 | "typeString": "address" 781 | }, 782 | "typeName": { 783 | "id": 900, 784 | "name": "address", 785 | "nodeType": "ElementaryTypeName", 786 | "src": "53:7:1", 787 | "stateMutability": "nonpayable", 788 | "typeDescriptions": { 789 | "typeIdentifier": "t_address", 790 | "typeString": "address" 791 | } 792 | }, 793 | "value": null, 794 | "visibility": "public" 795 | }, 796 | { 797 | "constant": false, 798 | "functionSelector": "445df0ac", 799 | "id": 903, 800 | "name": "last_completed_migration", 801 | "nodeType": "VariableDeclaration", 802 | "overrides": null, 803 | "scope": 954, 804 | "src": "80:36:1", 805 | "stateVariable": true, 806 | "storageLocation": "default", 807 | "typeDescriptions": { 808 | "typeIdentifier": "t_uint256", 809 | "typeString": "uint256" 810 | }, 811 | "typeName": { 812 | "id": 902, 813 | "name": "uint", 814 | "nodeType": "ElementaryTypeName", 815 | "src": "80:4:1", 816 | "typeDescriptions": { 817 | "typeIdentifier": "t_uint256", 818 | "typeString": "uint256" 819 | } 820 | }, 821 | "value": null, 822 | "visibility": "public" 823 | }, 824 | { 825 | "body": { 826 | "id": 911, 827 | "nodeType": "Block", 828 | "src": "146:37:1", 829 | "statements": [ 830 | { 831 | "expression": { 832 | "argumentTypes": null, 833 | "id": 909, 834 | "isConstant": false, 835 | "isLValue": false, 836 | "isPure": false, 837 | "lValueRequested": false, 838 | "leftHandSide": { 839 | "argumentTypes": null, 840 | "id": 906, 841 | "name": "owner", 842 | "nodeType": "Identifier", 843 | "overloadedDeclarations": [], 844 | "referencedDeclaration": 901, 845 | "src": "157:5:1", 846 | "typeDescriptions": { 847 | "typeIdentifier": "t_address", 848 | "typeString": "address" 849 | } 850 | }, 851 | "nodeType": "Assignment", 852 | "operator": "=", 853 | "rightHandSide": { 854 | "argumentTypes": null, 855 | "expression": { 856 | "argumentTypes": null, 857 | "id": 907, 858 | "name": "msg", 859 | "nodeType": "Identifier", 860 | "overloadedDeclarations": [], 861 | "referencedDeclaration": -15, 862 | "src": "165:3:1", 863 | "typeDescriptions": { 864 | "typeIdentifier": "t_magic_message", 865 | "typeString": "msg" 866 | } 867 | }, 868 | "id": 908, 869 | "isConstant": false, 870 | "isLValue": false, 871 | "isPure": false, 872 | "lValueRequested": false, 873 | "memberName": "sender", 874 | "nodeType": "MemberAccess", 875 | "referencedDeclaration": null, 876 | "src": "165:10:1", 877 | "typeDescriptions": { 878 | "typeIdentifier": "t_address_payable", 879 | "typeString": "address payable" 880 | } 881 | }, 882 | "src": "157:18:1", 883 | "typeDescriptions": { 884 | "typeIdentifier": "t_address", 885 | "typeString": "address" 886 | } 887 | }, 888 | "id": 910, 889 | "nodeType": "ExpressionStatement", 890 | "src": "157:18:1" 891 | } 892 | ] 893 | }, 894 | "documentation": null, 895 | "id": 912, 896 | "implemented": true, 897 | "kind": "constructor", 898 | "modifiers": [], 899 | "name": "", 900 | "nodeType": "FunctionDefinition", 901 | "overrides": null, 902 | "parameters": { 903 | "id": 904, 904 | "nodeType": "ParameterList", 905 | "parameters": [], 906 | "src": "136:2:1" 907 | }, 908 | "returnParameters": { 909 | "id": 905, 910 | "nodeType": "ParameterList", 911 | "parameters": [], 912 | "src": "146:0:1" 913 | }, 914 | "scope": 954, 915 | "src": "125:58:1", 916 | "stateMutability": "nonpayable", 917 | "virtual": false, 918 | "visibility": "public" 919 | }, 920 | { 921 | "body": { 922 | "id": 920, 923 | "nodeType": "Block", 924 | "src": "213:45:1", 925 | "statements": [ 926 | { 927 | "condition": { 928 | "argumentTypes": null, 929 | "commonType": { 930 | "typeIdentifier": "t_address", 931 | "typeString": "address" 932 | }, 933 | "id": 917, 934 | "isConstant": false, 935 | "isLValue": false, 936 | "isPure": false, 937 | "lValueRequested": false, 938 | "leftExpression": { 939 | "argumentTypes": null, 940 | "expression": { 941 | "argumentTypes": null, 942 | "id": 914, 943 | "name": "msg", 944 | "nodeType": "Identifier", 945 | "overloadedDeclarations": [], 946 | "referencedDeclaration": -15, 947 | "src": "228:3:1", 948 | "typeDescriptions": { 949 | "typeIdentifier": "t_magic_message", 950 | "typeString": "msg" 951 | } 952 | }, 953 | "id": 915, 954 | "isConstant": false, 955 | "isLValue": false, 956 | "isPure": false, 957 | "lValueRequested": false, 958 | "memberName": "sender", 959 | "nodeType": "MemberAccess", 960 | "referencedDeclaration": null, 961 | "src": "228:10:1", 962 | "typeDescriptions": { 963 | "typeIdentifier": "t_address_payable", 964 | "typeString": "address payable" 965 | } 966 | }, 967 | "nodeType": "BinaryOperation", 968 | "operator": "==", 969 | "rightExpression": { 970 | "argumentTypes": null, 971 | "id": 916, 972 | "name": "owner", 973 | "nodeType": "Identifier", 974 | "overloadedDeclarations": [], 975 | "referencedDeclaration": 901, 976 | "src": "242:5:1", 977 | "typeDescriptions": { 978 | "typeIdentifier": "t_address", 979 | "typeString": "address" 980 | } 981 | }, 982 | "src": "228:19:1", 983 | "typeDescriptions": { 984 | "typeIdentifier": "t_bool", 985 | "typeString": "bool" 986 | } 987 | }, 988 | "falseBody": null, 989 | "id": 919, 990 | "nodeType": "IfStatement", 991 | "src": "224:26:1", 992 | "trueBody": { 993 | "id": 918, 994 | "nodeType": "PlaceholderStatement", 995 | "src": "249:1:1" 996 | } 997 | } 998 | ] 999 | }, 1000 | "documentation": null, 1001 | "id": 921, 1002 | "name": "restricted", 1003 | "nodeType": "ModifierDefinition", 1004 | "overrides": null, 1005 | "parameters": { 1006 | "id": 913, 1007 | "nodeType": "ParameterList", 1008 | "parameters": [], 1009 | "src": "210:2:1" 1010 | }, 1011 | "src": "191:67:1", 1012 | "virtual": false, 1013 | "visibility": "internal" 1014 | }, 1015 | { 1016 | "body": { 1017 | "id": 932, 1018 | "nodeType": "Block", 1019 | "src": "322:55:1", 1020 | "statements": [ 1021 | { 1022 | "expression": { 1023 | "argumentTypes": null, 1024 | "id": 930, 1025 | "isConstant": false, 1026 | "isLValue": false, 1027 | "isPure": false, 1028 | "lValueRequested": false, 1029 | "leftHandSide": { 1030 | "argumentTypes": null, 1031 | "id": 928, 1032 | "name": "last_completed_migration", 1033 | "nodeType": "Identifier", 1034 | "overloadedDeclarations": [], 1035 | "referencedDeclaration": 903, 1036 | "src": "333:24:1", 1037 | "typeDescriptions": { 1038 | "typeIdentifier": "t_uint256", 1039 | "typeString": "uint256" 1040 | } 1041 | }, 1042 | "nodeType": "Assignment", 1043 | "operator": "=", 1044 | "rightHandSide": { 1045 | "argumentTypes": null, 1046 | "id": 929, 1047 | "name": "completed", 1048 | "nodeType": "Identifier", 1049 | "overloadedDeclarations": [], 1050 | "referencedDeclaration": 923, 1051 | "src": "360:9:1", 1052 | "typeDescriptions": { 1053 | "typeIdentifier": "t_uint256", 1054 | "typeString": "uint256" 1055 | } 1056 | }, 1057 | "src": "333:36:1", 1058 | "typeDescriptions": { 1059 | "typeIdentifier": "t_uint256", 1060 | "typeString": "uint256" 1061 | } 1062 | }, 1063 | "id": 931, 1064 | "nodeType": "ExpressionStatement", 1065 | "src": "333:36:1" 1066 | } 1067 | ] 1068 | }, 1069 | "documentation": null, 1070 | "functionSelector": "fdacd576", 1071 | "id": 933, 1072 | "implemented": true, 1073 | "kind": "function", 1074 | "modifiers": [ 1075 | { 1076 | "arguments": null, 1077 | "id": 926, 1078 | "modifierName": { 1079 | "argumentTypes": null, 1080 | "id": 925, 1081 | "name": "restricted", 1082 | "nodeType": "Identifier", 1083 | "overloadedDeclarations": [], 1084 | "referencedDeclaration": 921, 1085 | "src": "311:10:1", 1086 | "typeDescriptions": { 1087 | "typeIdentifier": "t_modifier$__$", 1088 | "typeString": "modifier ()" 1089 | } 1090 | }, 1091 | "nodeType": "ModifierInvocation", 1092 | "src": "311:10:1" 1093 | } 1094 | ], 1095 | "name": "setCompleted", 1096 | "nodeType": "FunctionDefinition", 1097 | "overrides": null, 1098 | "parameters": { 1099 | "id": 924, 1100 | "nodeType": "ParameterList", 1101 | "parameters": [ 1102 | { 1103 | "constant": false, 1104 | "id": 923, 1105 | "name": "completed", 1106 | "nodeType": "VariableDeclaration", 1107 | "overrides": null, 1108 | "scope": 933, 1109 | "src": "288:14:1", 1110 | "stateVariable": false, 1111 | "storageLocation": "default", 1112 | "typeDescriptions": { 1113 | "typeIdentifier": "t_uint256", 1114 | "typeString": "uint256" 1115 | }, 1116 | "typeName": { 1117 | "id": 922, 1118 | "name": "uint", 1119 | "nodeType": "ElementaryTypeName", 1120 | "src": "288:4:1", 1121 | "typeDescriptions": { 1122 | "typeIdentifier": "t_uint256", 1123 | "typeString": "uint256" 1124 | } 1125 | }, 1126 | "value": null, 1127 | "visibility": "internal" 1128 | } 1129 | ], 1130 | "src": "287:16:1" 1131 | }, 1132 | "returnParameters": { 1133 | "id": 927, 1134 | "nodeType": "ParameterList", 1135 | "parameters": [], 1136 | "src": "322:0:1" 1137 | }, 1138 | "scope": 954, 1139 | "src": "266:111:1", 1140 | "stateMutability": "nonpayable", 1141 | "virtual": false, 1142 | "visibility": "public" 1143 | }, 1144 | { 1145 | "body": { 1146 | "id": 952, 1147 | "nodeType": "Block", 1148 | "src": "441:122:1", 1149 | "statements": [ 1150 | { 1151 | "assignments": [ 1152 | 941 1153 | ], 1154 | "declarations": [ 1155 | { 1156 | "constant": false, 1157 | "id": 941, 1158 | "name": "upgraded", 1159 | "nodeType": "VariableDeclaration", 1160 | "overrides": null, 1161 | "scope": 952, 1162 | "src": "452:19:1", 1163 | "stateVariable": false, 1164 | "storageLocation": "default", 1165 | "typeDescriptions": { 1166 | "typeIdentifier": "t_contract$_Migrations_$954", 1167 | "typeString": "contract Migrations" 1168 | }, 1169 | "typeName": { 1170 | "contractScope": null, 1171 | "id": 940, 1172 | "name": "Migrations", 1173 | "nodeType": "UserDefinedTypeName", 1174 | "referencedDeclaration": 954, 1175 | "src": "452:10:1", 1176 | "typeDescriptions": { 1177 | "typeIdentifier": "t_contract$_Migrations_$954", 1178 | "typeString": "contract Migrations" 1179 | } 1180 | }, 1181 | "value": null, 1182 | "visibility": "internal" 1183 | } 1184 | ], 1185 | "id": 945, 1186 | "initialValue": { 1187 | "argumentTypes": null, 1188 | "arguments": [ 1189 | { 1190 | "argumentTypes": null, 1191 | "id": 943, 1192 | "name": "new_address", 1193 | "nodeType": "Identifier", 1194 | "overloadedDeclarations": [], 1195 | "referencedDeclaration": 935, 1196 | "src": "485:11:1", 1197 | "typeDescriptions": { 1198 | "typeIdentifier": "t_address", 1199 | "typeString": "address" 1200 | } 1201 | } 1202 | ], 1203 | "expression": { 1204 | "argumentTypes": [ 1205 | { 1206 | "typeIdentifier": "t_address", 1207 | "typeString": "address" 1208 | } 1209 | ], 1210 | "id": 942, 1211 | "name": "Migrations", 1212 | "nodeType": "Identifier", 1213 | "overloadedDeclarations": [], 1214 | "referencedDeclaration": 954, 1215 | "src": "474:10:1", 1216 | "typeDescriptions": { 1217 | "typeIdentifier": "t_type$_t_contract$_Migrations_$954_$", 1218 | "typeString": "type(contract Migrations)" 1219 | } 1220 | }, 1221 | "id": 944, 1222 | "isConstant": false, 1223 | "isLValue": false, 1224 | "isPure": false, 1225 | "kind": "typeConversion", 1226 | "lValueRequested": false, 1227 | "names": [], 1228 | "nodeType": "FunctionCall", 1229 | "src": "474:23:1", 1230 | "tryCall": false, 1231 | "typeDescriptions": { 1232 | "typeIdentifier": "t_contract$_Migrations_$954", 1233 | "typeString": "contract Migrations" 1234 | } 1235 | }, 1236 | "nodeType": "VariableDeclarationStatement", 1237 | "src": "452:45:1" 1238 | }, 1239 | { 1240 | "expression": { 1241 | "argumentTypes": null, 1242 | "arguments": [ 1243 | { 1244 | "argumentTypes": null, 1245 | "id": 949, 1246 | "name": "last_completed_migration", 1247 | "nodeType": "Identifier", 1248 | "overloadedDeclarations": [], 1249 | "referencedDeclaration": 903, 1250 | "src": "530:24:1", 1251 | "typeDescriptions": { 1252 | "typeIdentifier": "t_uint256", 1253 | "typeString": "uint256" 1254 | } 1255 | } 1256 | ], 1257 | "expression": { 1258 | "argumentTypes": [ 1259 | { 1260 | "typeIdentifier": "t_uint256", 1261 | "typeString": "uint256" 1262 | } 1263 | ], 1264 | "expression": { 1265 | "argumentTypes": null, 1266 | "id": 946, 1267 | "name": "upgraded", 1268 | "nodeType": "Identifier", 1269 | "overloadedDeclarations": [], 1270 | "referencedDeclaration": 941, 1271 | "src": "508:8:1", 1272 | "typeDescriptions": { 1273 | "typeIdentifier": "t_contract$_Migrations_$954", 1274 | "typeString": "contract Migrations" 1275 | } 1276 | }, 1277 | "id": 948, 1278 | "isConstant": false, 1279 | "isLValue": false, 1280 | "isPure": false, 1281 | "lValueRequested": false, 1282 | "memberName": "setCompleted", 1283 | "nodeType": "MemberAccess", 1284 | "referencedDeclaration": 933, 1285 | "src": "508:21:1", 1286 | "typeDescriptions": { 1287 | "typeIdentifier": "t_function_external_nonpayable$_t_uint256_$returns$__$", 1288 | "typeString": "function (uint256) external" 1289 | } 1290 | }, 1291 | "id": 950, 1292 | "isConstant": false, 1293 | "isLValue": false, 1294 | "isPure": false, 1295 | "kind": "functionCall", 1296 | "lValueRequested": false, 1297 | "names": [], 1298 | "nodeType": "FunctionCall", 1299 | "src": "508:47:1", 1300 | "tryCall": false, 1301 | "typeDescriptions": { 1302 | "typeIdentifier": "t_tuple$__$", 1303 | "typeString": "tuple()" 1304 | } 1305 | }, 1306 | "id": 951, 1307 | "nodeType": "ExpressionStatement", 1308 | "src": "508:47:1" 1309 | } 1310 | ] 1311 | }, 1312 | "documentation": null, 1313 | "functionSelector": "0900f010", 1314 | "id": 953, 1315 | "implemented": true, 1316 | "kind": "function", 1317 | "modifiers": [ 1318 | { 1319 | "arguments": null, 1320 | "id": 938, 1321 | "modifierName": { 1322 | "argumentTypes": null, 1323 | "id": 937, 1324 | "name": "restricted", 1325 | "nodeType": "Identifier", 1326 | "overloadedDeclarations": [], 1327 | "referencedDeclaration": 921, 1328 | "src": "430:10:1", 1329 | "typeDescriptions": { 1330 | "typeIdentifier": "t_modifier$__$", 1331 | "typeString": "modifier ()" 1332 | } 1333 | }, 1334 | "nodeType": "ModifierInvocation", 1335 | "src": "430:10:1" 1336 | } 1337 | ], 1338 | "name": "upgrade", 1339 | "nodeType": "FunctionDefinition", 1340 | "overrides": null, 1341 | "parameters": { 1342 | "id": 936, 1343 | "nodeType": "ParameterList", 1344 | "parameters": [ 1345 | { 1346 | "constant": false, 1347 | "id": 935, 1348 | "name": "new_address", 1349 | "nodeType": "VariableDeclaration", 1350 | "overrides": null, 1351 | "scope": 953, 1352 | "src": "402:19:1", 1353 | "stateVariable": false, 1354 | "storageLocation": "default", 1355 | "typeDescriptions": { 1356 | "typeIdentifier": "t_address", 1357 | "typeString": "address" 1358 | }, 1359 | "typeName": { 1360 | "id": 934, 1361 | "name": "address", 1362 | "nodeType": "ElementaryTypeName", 1363 | "src": "402:7:1", 1364 | "stateMutability": "nonpayable", 1365 | "typeDescriptions": { 1366 | "typeIdentifier": "t_address", 1367 | "typeString": "address" 1368 | } 1369 | }, 1370 | "value": null, 1371 | "visibility": "internal" 1372 | } 1373 | ], 1374 | "src": "401:21:1" 1375 | }, 1376 | "returnParameters": { 1377 | "id": 939, 1378 | "nodeType": "ParameterList", 1379 | "parameters": [], 1380 | "src": "441:0:1" 1381 | }, 1382 | "scope": 954, 1383 | "src": "385:178:1", 1384 | "stateMutability": "nonpayable", 1385 | "virtual": false, 1386 | "visibility": "public" 1387 | } 1388 | ], 1389 | "scope": 955, 1390 | "src": "26:540:1" 1391 | } 1392 | ], 1393 | "src": "0:568:1" 1394 | }, 1395 | "compiler": { 1396 | "name": "solc", 1397 | "version": "0.6.3+commit.8dda9521.Emscripten.clang" 1398 | }, 1399 | "networks": { 1400 | "5777": { 1401 | "events": {}, 1402 | "links": {}, 1403 | "address": "0xCeaBeC772F1AF93Dac2e8E1AF9Fd795f4885b4d4", 1404 | "transactionHash": "0x5789107f458a31f33158e709813f64e899b6e8485c27a27cdba3d49952520596" 1405 | } 1406 | }, 1407 | "schemaVersion": "3.2.1", 1408 | "updatedAt": "2020-07-08T06:32:28.934Z", 1409 | "networkType": "ethereum", 1410 | "devdoc": { 1411 | "methods": {} 1412 | }, 1413 | "userdoc": { 1414 | "methods": {} 1415 | } 1416 | } -------------------------------------------------------------------------------- /client/src/contracts/ERC20Detailed.json: -------------------------------------------------------------------------------- 1 | { 2 | "contractName": "ERC20Detailed", 3 | "abi": [ 4 | { 5 | "inputs": [ 6 | { 7 | "internalType": "string", 8 | "name": "name", 9 | "type": "string" 10 | }, 11 | { 12 | "internalType": "string", 13 | "name": "symbol", 14 | "type": "string" 15 | }, 16 | { 17 | "internalType": "uint8", 18 | "name": "decimals", 19 | "type": "uint8" 20 | } 21 | ], 22 | "stateMutability": "nonpayable", 23 | "type": "constructor" 24 | }, 25 | { 26 | "anonymous": false, 27 | "inputs": [ 28 | { 29 | "indexed": true, 30 | "internalType": "address", 31 | "name": "owner", 32 | "type": "address" 33 | }, 34 | { 35 | "indexed": true, 36 | "internalType": "address", 37 | "name": "spender", 38 | "type": "address" 39 | }, 40 | { 41 | "indexed": false, 42 | "internalType": "uint256", 43 | "name": "value", 44 | "type": "uint256" 45 | } 46 | ], 47 | "name": "Approval", 48 | "type": "event" 49 | }, 50 | { 51 | "anonymous": false, 52 | "inputs": [ 53 | { 54 | "indexed": true, 55 | "internalType": "address", 56 | "name": "from", 57 | "type": "address" 58 | }, 59 | { 60 | "indexed": true, 61 | "internalType": "address", 62 | "name": "to", 63 | "type": "address" 64 | }, 65 | { 66 | "indexed": false, 67 | "internalType": "uint256", 68 | "name": "value", 69 | "type": "uint256" 70 | } 71 | ], 72 | "name": "Transfer", 73 | "type": "event" 74 | }, 75 | { 76 | "inputs": [ 77 | { 78 | "internalType": "address", 79 | "name": "owner", 80 | "type": "address" 81 | }, 82 | { 83 | "internalType": "address", 84 | "name": "spender", 85 | "type": "address" 86 | } 87 | ], 88 | "name": "allowance", 89 | "outputs": [ 90 | { 91 | "internalType": "uint256", 92 | "name": "", 93 | "type": "uint256" 94 | } 95 | ], 96 | "stateMutability": "view", 97 | "type": "function" 98 | }, 99 | { 100 | "inputs": [ 101 | { 102 | "internalType": "address", 103 | "name": "spender", 104 | "type": "address" 105 | }, 106 | { 107 | "internalType": "uint256", 108 | "name": "amount", 109 | "type": "uint256" 110 | } 111 | ], 112 | "name": "approve", 113 | "outputs": [ 114 | { 115 | "internalType": "bool", 116 | "name": "", 117 | "type": "bool" 118 | } 119 | ], 120 | "stateMutability": "nonpayable", 121 | "type": "function" 122 | }, 123 | { 124 | "inputs": [ 125 | { 126 | "internalType": "address", 127 | "name": "account", 128 | "type": "address" 129 | } 130 | ], 131 | "name": "balanceOf", 132 | "outputs": [ 133 | { 134 | "internalType": "uint256", 135 | "name": "", 136 | "type": "uint256" 137 | } 138 | ], 139 | "stateMutability": "view", 140 | "type": "function" 141 | }, 142 | { 143 | "inputs": [], 144 | "name": "totalSupply", 145 | "outputs": [ 146 | { 147 | "internalType": "uint256", 148 | "name": "", 149 | "type": "uint256" 150 | } 151 | ], 152 | "stateMutability": "view", 153 | "type": "function" 154 | }, 155 | { 156 | "inputs": [ 157 | { 158 | "internalType": "address", 159 | "name": "recipient", 160 | "type": "address" 161 | }, 162 | { 163 | "internalType": "uint256", 164 | "name": "amount", 165 | "type": "uint256" 166 | } 167 | ], 168 | "name": "transfer", 169 | "outputs": [ 170 | { 171 | "internalType": "bool", 172 | "name": "", 173 | "type": "bool" 174 | } 175 | ], 176 | "stateMutability": "nonpayable", 177 | "type": "function" 178 | }, 179 | { 180 | "inputs": [ 181 | { 182 | "internalType": "address", 183 | "name": "sender", 184 | "type": "address" 185 | }, 186 | { 187 | "internalType": "address", 188 | "name": "recipient", 189 | "type": "address" 190 | }, 191 | { 192 | "internalType": "uint256", 193 | "name": "amount", 194 | "type": "uint256" 195 | } 196 | ], 197 | "name": "transferFrom", 198 | "outputs": [ 199 | { 200 | "internalType": "bool", 201 | "name": "", 202 | "type": "bool" 203 | } 204 | ], 205 | "stateMutability": "nonpayable", 206 | "type": "function" 207 | }, 208 | { 209 | "inputs": [], 210 | "name": "name", 211 | "outputs": [ 212 | { 213 | "internalType": "string", 214 | "name": "", 215 | "type": "string" 216 | } 217 | ], 218 | "stateMutability": "view", 219 | "type": "function" 220 | }, 221 | { 222 | "inputs": [], 223 | "name": "symbol", 224 | "outputs": [ 225 | { 226 | "internalType": "string", 227 | "name": "", 228 | "type": "string" 229 | } 230 | ], 231 | "stateMutability": "view", 232 | "type": "function" 233 | }, 234 | { 235 | "inputs": [], 236 | "name": "decimals", 237 | "outputs": [ 238 | { 239 | "internalType": "uint8", 240 | "name": "", 241 | "type": "uint8" 242 | } 243 | ], 244 | "stateMutability": "view", 245 | "type": "function" 246 | } 247 | ], 248 | "metadata": "{\"compiler\":{\"version\":\"0.6.3+commit.8dda9521\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"symbol\",\"type\":\"string\"},{\"internalType\":\"uint8\",\"name\":\"decimals\",\"type\":\"uint8\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"}],\"name\":\"allowance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"decimals\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"details\":\"Optional functions from the ERC20 standard.\",\"methods\":{\"allowance(address,address)\":{\"details\":\"Returns the remaining number of tokens that `spender` will be allowed to spend on behalf of `owner` through {transferFrom}. This is zero by default. * This value changes when {approve} or {transferFrom} are called.\"},\"approve(address,uint256)\":{\"details\":\"Sets `amount` as the allowance of `spender` over the caller's tokens. * Returns a boolean value indicating whether the operation succeeded. * IMPORTANT: Beware that changing an allowance with this method brings the risk that someone may use both the old and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * Emits an {Approval} event.\"},\"balanceOf(address)\":{\"details\":\"Returns the amount of tokens owned by `account`.\"},\"constructor\":{\"details\":\"Sets the values for `name`, `symbol`, and `decimals`. All three of these values are immutable: they can only be set once during construction.\"},\"decimals()\":{\"details\":\"Returns the number of decimals used to get its user representation. For example, if `decimals` equals `2`, a balance of `505` tokens should be displayed to a user as `5,05` (`505 / 10 ** 2`). * Tokens usually opt for a value of 18, imitating the relationship between Ether and Wei. * NOTE: This information is only used for _display_ purposes: it in no way affects any of the arithmetic of the contract, including {IERC20-balanceOf} and {IERC20-transfer}.\"},\"name()\":{\"details\":\"Returns the name of the token.\"},\"symbol()\":{\"details\":\"Returns the symbol of the token, usually a shorter version of the name.\"},\"totalSupply()\":{\"details\":\"Returns the amount of tokens in existence.\"},\"transfer(address,uint256)\":{\"details\":\"Moves `amount` tokens from the caller's account to `recipient`. * Returns a boolean value indicating whether the operation succeeded. * Emits a {Transfer} event.\"},\"transferFrom(address,address,uint256)\":{\"details\":\"Moves `amount` tokens from `sender` to `recipient` using the allowance mechanism. `amount` is then deducted from the caller's allowance. * Returns a boolean value indicating whether the operation succeeded. * Emits a {Transfer} event.\"}}},\"userdoc\":{\"methods\":{}}},\"settings\":{\"compilationTarget\":{\"@openzeppelin/contracts/token/ERC20/ERC20Detailed.sol\":\"ERC20Detailed\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":false,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/token/ERC20/ERC20Detailed.sol\":{\"keccak256\":\"0x060d944bc6f17414d07853a46d056bf594e5b3a7899e0e76b4520cdbe384e231\",\"urls\":[\"bzz-raw://5142118f78f0ea251eabf2d6688a04027898cb1ddfa885e27f781a2fde3a7a86\",\"dweb:/ipfs/QmQjAwm2oREFKkBEZDVod5LVPJ11ucgswnPFoZ1sZwYpTH\"]},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"keccak256\":\"0x708ae901e214e044a5c922748462157b9be162b3620aa56d7c0e7258f66aee1d\",\"urls\":[\"bzz-raw://c287ed9989e5f16114553a30f4ba3794be657f90598f101f7b92ce5859f46978\",\"dweb:/ipfs/QmeFeDCzfhhBTaY9NE9wREmrBRETvn4k3mo2FejqskVMtg\"]}},\"version\":1}", 249 | "bytecode": "0x", 250 | "deployedBytecode": "0x", 251 | "sourceMap": "", 252 | "deployedSourceMap": "", 253 | "source": "pragma solidity ^0.6.0;\n\nimport \"./IERC20.sol\";\n\n/**\n * @dev Optional functions from the ERC20 standard.\n */\nabstract contract ERC20Detailed is IERC20 {\n string private _name;\n string private _symbol;\n uint8 private _decimals;\n\n /**\n * @dev Sets the values for `name`, `symbol`, and `decimals`. All three of\n * these values are immutable: they can only be set once during\n * construction.\n */\n constructor (string memory name, string memory symbol, uint8 decimals) public {\n _name = name;\n _symbol = symbol;\n _decimals = decimals;\n }\n\n /**\n * @dev Returns the name of the token.\n */\n function name() public view returns (string memory) {\n return _name;\n }\n\n /**\n * @dev Returns the symbol of the token, usually a shorter version of the\n * name.\n */\n function symbol() public view returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev Returns the number of decimals used to get its user representation.\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\n * be displayed to a user as `5,05` (`505 / 10 ** 2`).\n *\n * Tokens usually opt for a value of 18, imitating the relationship between\n * Ether and Wei.\n *\n * NOTE: This information is only used for _display_ purposes: it in\n * no way affects any of the arithmetic of the contract, including\n * {IERC20-balanceOf} and {IERC20-transfer}.\n */\n function decimals() public view returns (uint8) {\n return _decimals;\n }\n}\n", 254 | "sourcePath": "@openzeppelin/contracts/token/ERC20/ERC20Detailed.sol", 255 | "ast": { 256 | "absolutePath": "@openzeppelin/contracts/token/ERC20/ERC20Detailed.sol", 257 | "exportedSymbols": { 258 | "ERC20Detailed": [ 259 | 1832 260 | ] 261 | }, 262 | "id": 1833, 263 | "nodeType": "SourceUnit", 264 | "nodes": [ 265 | { 266 | "id": 1771, 267 | "literals": [ 268 | "solidity", 269 | "^", 270 | "0.6", 271 | ".0" 272 | ], 273 | "nodeType": "PragmaDirective", 274 | "src": "0:23:9" 275 | }, 276 | { 277 | "absolutePath": "@openzeppelin/contracts/token/ERC20/IERC20.sol", 278 | "file": "./IERC20.sol", 279 | "id": 1772, 280 | "nodeType": "ImportDirective", 281 | "scope": 1833, 282 | "sourceUnit": 1911, 283 | "src": "25:22:9", 284 | "symbolAliases": [], 285 | "unitAlias": "" 286 | }, 287 | { 288 | "abstract": true, 289 | "baseContracts": [ 290 | { 291 | "arguments": null, 292 | "baseName": { 293 | "contractScope": null, 294 | "id": 1774, 295 | "name": "IERC20", 296 | "nodeType": "UserDefinedTypeName", 297 | "referencedDeclaration": 1910, 298 | "src": "144:6:9", 299 | "typeDescriptions": { 300 | "typeIdentifier": "t_contract$_IERC20_$1910", 301 | "typeString": "contract IERC20" 302 | } 303 | }, 304 | "id": 1775, 305 | "nodeType": "InheritanceSpecifier", 306 | "src": "144:6:9" 307 | } 308 | ], 309 | "contractDependencies": [ 310 | 1910 311 | ], 312 | "contractKind": "contract", 313 | "documentation": { 314 | "id": 1773, 315 | "nodeType": "StructuredDocumentation", 316 | "src": "49:59:9", 317 | "text": "@dev Optional functions from the ERC20 standard." 318 | }, 319 | "fullyImplemented": false, 320 | "id": 1832, 321 | "linearizedBaseContracts": [ 322 | 1832, 323 | 1910 324 | ], 325 | "name": "ERC20Detailed", 326 | "nodeType": "ContractDefinition", 327 | "nodes": [ 328 | { 329 | "constant": false, 330 | "id": 1777, 331 | "name": "_name", 332 | "nodeType": "VariableDeclaration", 333 | "overrides": null, 334 | "scope": 1832, 335 | "src": "157:20:9", 336 | "stateVariable": true, 337 | "storageLocation": "default", 338 | "typeDescriptions": { 339 | "typeIdentifier": "t_string_storage", 340 | "typeString": "string" 341 | }, 342 | "typeName": { 343 | "id": 1776, 344 | "name": "string", 345 | "nodeType": "ElementaryTypeName", 346 | "src": "157:6:9", 347 | "typeDescriptions": { 348 | "typeIdentifier": "t_string_storage_ptr", 349 | "typeString": "string" 350 | } 351 | }, 352 | "value": null, 353 | "visibility": "private" 354 | }, 355 | { 356 | "constant": false, 357 | "id": 1779, 358 | "name": "_symbol", 359 | "nodeType": "VariableDeclaration", 360 | "overrides": null, 361 | "scope": 1832, 362 | "src": "183:22:9", 363 | "stateVariable": true, 364 | "storageLocation": "default", 365 | "typeDescriptions": { 366 | "typeIdentifier": "t_string_storage", 367 | "typeString": "string" 368 | }, 369 | "typeName": { 370 | "id": 1778, 371 | "name": "string", 372 | "nodeType": "ElementaryTypeName", 373 | "src": "183:6:9", 374 | "typeDescriptions": { 375 | "typeIdentifier": "t_string_storage_ptr", 376 | "typeString": "string" 377 | } 378 | }, 379 | "value": null, 380 | "visibility": "private" 381 | }, 382 | { 383 | "constant": false, 384 | "id": 1781, 385 | "name": "_decimals", 386 | "nodeType": "VariableDeclaration", 387 | "overrides": null, 388 | "scope": 1832, 389 | "src": "211:23:9", 390 | "stateVariable": true, 391 | "storageLocation": "default", 392 | "typeDescriptions": { 393 | "typeIdentifier": "t_uint8", 394 | "typeString": "uint8" 395 | }, 396 | "typeName": { 397 | "id": 1780, 398 | "name": "uint8", 399 | "nodeType": "ElementaryTypeName", 400 | "src": "211:5:9", 401 | "typeDescriptions": { 402 | "typeIdentifier": "t_uint8", 403 | "typeString": "uint8" 404 | } 405 | }, 406 | "value": null, 407 | "visibility": "private" 408 | }, 409 | { 410 | "body": { 411 | "id": 1803, 412 | "nodeType": "Block", 413 | "src": "503:85:9", 414 | "statements": [ 415 | { 416 | "expression": { 417 | "argumentTypes": null, 418 | "id": 1793, 419 | "isConstant": false, 420 | "isLValue": false, 421 | "isPure": false, 422 | "lValueRequested": false, 423 | "leftHandSide": { 424 | "argumentTypes": null, 425 | "id": 1791, 426 | "name": "_name", 427 | "nodeType": "Identifier", 428 | "overloadedDeclarations": [], 429 | "referencedDeclaration": 1777, 430 | "src": "513:5:9", 431 | "typeDescriptions": { 432 | "typeIdentifier": "t_string_storage", 433 | "typeString": "string storage ref" 434 | } 435 | }, 436 | "nodeType": "Assignment", 437 | "operator": "=", 438 | "rightHandSide": { 439 | "argumentTypes": null, 440 | "id": 1792, 441 | "name": "name", 442 | "nodeType": "Identifier", 443 | "overloadedDeclarations": [], 444 | "referencedDeclaration": 1784, 445 | "src": "521:4:9", 446 | "typeDescriptions": { 447 | "typeIdentifier": "t_string_memory_ptr", 448 | "typeString": "string memory" 449 | } 450 | }, 451 | "src": "513:12:9", 452 | "typeDescriptions": { 453 | "typeIdentifier": "t_string_storage", 454 | "typeString": "string storage ref" 455 | } 456 | }, 457 | "id": 1794, 458 | "nodeType": "ExpressionStatement", 459 | "src": "513:12:9" 460 | }, 461 | { 462 | "expression": { 463 | "argumentTypes": null, 464 | "id": 1797, 465 | "isConstant": false, 466 | "isLValue": false, 467 | "isPure": false, 468 | "lValueRequested": false, 469 | "leftHandSide": { 470 | "argumentTypes": null, 471 | "id": 1795, 472 | "name": "_symbol", 473 | "nodeType": "Identifier", 474 | "overloadedDeclarations": [], 475 | "referencedDeclaration": 1779, 476 | "src": "535:7:9", 477 | "typeDescriptions": { 478 | "typeIdentifier": "t_string_storage", 479 | "typeString": "string storage ref" 480 | } 481 | }, 482 | "nodeType": "Assignment", 483 | "operator": "=", 484 | "rightHandSide": { 485 | "argumentTypes": null, 486 | "id": 1796, 487 | "name": "symbol", 488 | "nodeType": "Identifier", 489 | "overloadedDeclarations": [], 490 | "referencedDeclaration": 1786, 491 | "src": "545:6:9", 492 | "typeDescriptions": { 493 | "typeIdentifier": "t_string_memory_ptr", 494 | "typeString": "string memory" 495 | } 496 | }, 497 | "src": "535:16:9", 498 | "typeDescriptions": { 499 | "typeIdentifier": "t_string_storage", 500 | "typeString": "string storage ref" 501 | } 502 | }, 503 | "id": 1798, 504 | "nodeType": "ExpressionStatement", 505 | "src": "535:16:9" 506 | }, 507 | { 508 | "expression": { 509 | "argumentTypes": null, 510 | "id": 1801, 511 | "isConstant": false, 512 | "isLValue": false, 513 | "isPure": false, 514 | "lValueRequested": false, 515 | "leftHandSide": { 516 | "argumentTypes": null, 517 | "id": 1799, 518 | "name": "_decimals", 519 | "nodeType": "Identifier", 520 | "overloadedDeclarations": [], 521 | "referencedDeclaration": 1781, 522 | "src": "561:9:9", 523 | "typeDescriptions": { 524 | "typeIdentifier": "t_uint8", 525 | "typeString": "uint8" 526 | } 527 | }, 528 | "nodeType": "Assignment", 529 | "operator": "=", 530 | "rightHandSide": { 531 | "argumentTypes": null, 532 | "id": 1800, 533 | "name": "decimals", 534 | "nodeType": "Identifier", 535 | "overloadedDeclarations": [], 536 | "referencedDeclaration": 1788, 537 | "src": "573:8:9", 538 | "typeDescriptions": { 539 | "typeIdentifier": "t_uint8", 540 | "typeString": "uint8" 541 | } 542 | }, 543 | "src": "561:20:9", 544 | "typeDescriptions": { 545 | "typeIdentifier": "t_uint8", 546 | "typeString": "uint8" 547 | } 548 | }, 549 | "id": 1802, 550 | "nodeType": "ExpressionStatement", 551 | "src": "561:20:9" 552 | } 553 | ] 554 | }, 555 | "documentation": { 556 | "id": 1782, 557 | "nodeType": "StructuredDocumentation", 558 | "src": "241:179:9", 559 | "text": "@dev Sets the values for `name`, `symbol`, and `decimals`. All three of\nthese values are immutable: they can only be set once during\nconstruction." 560 | }, 561 | "id": 1804, 562 | "implemented": true, 563 | "kind": "constructor", 564 | "modifiers": [], 565 | "name": "", 566 | "nodeType": "FunctionDefinition", 567 | "overrides": null, 568 | "parameters": { 569 | "id": 1789, 570 | "nodeType": "ParameterList", 571 | "parameters": [ 572 | { 573 | "constant": false, 574 | "id": 1784, 575 | "name": "name", 576 | "nodeType": "VariableDeclaration", 577 | "overrides": null, 578 | "scope": 1804, 579 | "src": "438:18:9", 580 | "stateVariable": false, 581 | "storageLocation": "memory", 582 | "typeDescriptions": { 583 | "typeIdentifier": "t_string_memory_ptr", 584 | "typeString": "string" 585 | }, 586 | "typeName": { 587 | "id": 1783, 588 | "name": "string", 589 | "nodeType": "ElementaryTypeName", 590 | "src": "438:6:9", 591 | "typeDescriptions": { 592 | "typeIdentifier": "t_string_storage_ptr", 593 | "typeString": "string" 594 | } 595 | }, 596 | "value": null, 597 | "visibility": "internal" 598 | }, 599 | { 600 | "constant": false, 601 | "id": 1786, 602 | "name": "symbol", 603 | "nodeType": "VariableDeclaration", 604 | "overrides": null, 605 | "scope": 1804, 606 | "src": "458:20:9", 607 | "stateVariable": false, 608 | "storageLocation": "memory", 609 | "typeDescriptions": { 610 | "typeIdentifier": "t_string_memory_ptr", 611 | "typeString": "string" 612 | }, 613 | "typeName": { 614 | "id": 1785, 615 | "name": "string", 616 | "nodeType": "ElementaryTypeName", 617 | "src": "458:6:9", 618 | "typeDescriptions": { 619 | "typeIdentifier": "t_string_storage_ptr", 620 | "typeString": "string" 621 | } 622 | }, 623 | "value": null, 624 | "visibility": "internal" 625 | }, 626 | { 627 | "constant": false, 628 | "id": 1788, 629 | "name": "decimals", 630 | "nodeType": "VariableDeclaration", 631 | "overrides": null, 632 | "scope": 1804, 633 | "src": "480:14:9", 634 | "stateVariable": false, 635 | "storageLocation": "default", 636 | "typeDescriptions": { 637 | "typeIdentifier": "t_uint8", 638 | "typeString": "uint8" 639 | }, 640 | "typeName": { 641 | "id": 1787, 642 | "name": "uint8", 643 | "nodeType": "ElementaryTypeName", 644 | "src": "480:5:9", 645 | "typeDescriptions": { 646 | "typeIdentifier": "t_uint8", 647 | "typeString": "uint8" 648 | } 649 | }, 650 | "value": null, 651 | "visibility": "internal" 652 | } 653 | ], 654 | "src": "437:58:9" 655 | }, 656 | "returnParameters": { 657 | "id": 1790, 658 | "nodeType": "ParameterList", 659 | "parameters": [], 660 | "src": "503:0:9" 661 | }, 662 | "scope": 1832, 663 | "src": "425:163:9", 664 | "stateMutability": "nonpayable", 665 | "virtual": false, 666 | "visibility": "public" 667 | }, 668 | { 669 | "body": { 670 | "id": 1812, 671 | "nodeType": "Block", 672 | "src": "705:29:9", 673 | "statements": [ 674 | { 675 | "expression": { 676 | "argumentTypes": null, 677 | "id": 1810, 678 | "name": "_name", 679 | "nodeType": "Identifier", 680 | "overloadedDeclarations": [], 681 | "referencedDeclaration": 1777, 682 | "src": "722:5:9", 683 | "typeDescriptions": { 684 | "typeIdentifier": "t_string_storage", 685 | "typeString": "string storage ref" 686 | } 687 | }, 688 | "functionReturnParameters": 1809, 689 | "id": 1811, 690 | "nodeType": "Return", 691 | "src": "715:12:9" 692 | } 693 | ] 694 | }, 695 | "documentation": { 696 | "id": 1805, 697 | "nodeType": "StructuredDocumentation", 698 | "src": "594:54:9", 699 | "text": "@dev Returns the name of the token." 700 | }, 701 | "functionSelector": "06fdde03", 702 | "id": 1813, 703 | "implemented": true, 704 | "kind": "function", 705 | "modifiers": [], 706 | "name": "name", 707 | "nodeType": "FunctionDefinition", 708 | "overrides": null, 709 | "parameters": { 710 | "id": 1806, 711 | "nodeType": "ParameterList", 712 | "parameters": [], 713 | "src": "666:2:9" 714 | }, 715 | "returnParameters": { 716 | "id": 1809, 717 | "nodeType": "ParameterList", 718 | "parameters": [ 719 | { 720 | "constant": false, 721 | "id": 1808, 722 | "name": "", 723 | "nodeType": "VariableDeclaration", 724 | "overrides": null, 725 | "scope": 1813, 726 | "src": "690:13:9", 727 | "stateVariable": false, 728 | "storageLocation": "memory", 729 | "typeDescriptions": { 730 | "typeIdentifier": "t_string_memory_ptr", 731 | "typeString": "string" 732 | }, 733 | "typeName": { 734 | "id": 1807, 735 | "name": "string", 736 | "nodeType": "ElementaryTypeName", 737 | "src": "690:6:9", 738 | "typeDescriptions": { 739 | "typeIdentifier": "t_string_storage_ptr", 740 | "typeString": "string" 741 | } 742 | }, 743 | "value": null, 744 | "visibility": "internal" 745 | } 746 | ], 747 | "src": "689:15:9" 748 | }, 749 | "scope": 1832, 750 | "src": "653:81:9", 751 | "stateMutability": "view", 752 | "virtual": false, 753 | "visibility": "public" 754 | }, 755 | { 756 | "body": { 757 | "id": 1821, 758 | "nodeType": "Block", 759 | "src": "901:31:9", 760 | "statements": [ 761 | { 762 | "expression": { 763 | "argumentTypes": null, 764 | "id": 1819, 765 | "name": "_symbol", 766 | "nodeType": "Identifier", 767 | "overloadedDeclarations": [], 768 | "referencedDeclaration": 1779, 769 | "src": "918:7:9", 770 | "typeDescriptions": { 771 | "typeIdentifier": "t_string_storage", 772 | "typeString": "string storage ref" 773 | } 774 | }, 775 | "functionReturnParameters": 1818, 776 | "id": 1820, 777 | "nodeType": "Return", 778 | "src": "911:14:9" 779 | } 780 | ] 781 | }, 782 | "documentation": { 783 | "id": 1814, 784 | "nodeType": "StructuredDocumentation", 785 | "src": "740:102:9", 786 | "text": "@dev Returns the symbol of the token, usually a shorter version of the\nname." 787 | }, 788 | "functionSelector": "95d89b41", 789 | "id": 1822, 790 | "implemented": true, 791 | "kind": "function", 792 | "modifiers": [], 793 | "name": "symbol", 794 | "nodeType": "FunctionDefinition", 795 | "overrides": null, 796 | "parameters": { 797 | "id": 1815, 798 | "nodeType": "ParameterList", 799 | "parameters": [], 800 | "src": "862:2:9" 801 | }, 802 | "returnParameters": { 803 | "id": 1818, 804 | "nodeType": "ParameterList", 805 | "parameters": [ 806 | { 807 | "constant": false, 808 | "id": 1817, 809 | "name": "", 810 | "nodeType": "VariableDeclaration", 811 | "overrides": null, 812 | "scope": 1822, 813 | "src": "886:13:9", 814 | "stateVariable": false, 815 | "storageLocation": "memory", 816 | "typeDescriptions": { 817 | "typeIdentifier": "t_string_memory_ptr", 818 | "typeString": "string" 819 | }, 820 | "typeName": { 821 | "id": 1816, 822 | "name": "string", 823 | "nodeType": "ElementaryTypeName", 824 | "src": "886:6:9", 825 | "typeDescriptions": { 826 | "typeIdentifier": "t_string_storage_ptr", 827 | "typeString": "string" 828 | } 829 | }, 830 | "value": null, 831 | "visibility": "internal" 832 | } 833 | ], 834 | "src": "885:15:9" 835 | }, 836 | "scope": 1832, 837 | "src": "847:85:9", 838 | "stateMutability": "view", 839 | "virtual": false, 840 | "visibility": "public" 841 | }, 842 | { 843 | "body": { 844 | "id": 1830, 845 | "nodeType": "Block", 846 | "src": "1529:33:9", 847 | "statements": [ 848 | { 849 | "expression": { 850 | "argumentTypes": null, 851 | "id": 1828, 852 | "name": "_decimals", 853 | "nodeType": "Identifier", 854 | "overloadedDeclarations": [], 855 | "referencedDeclaration": 1781, 856 | "src": "1546:9:9", 857 | "typeDescriptions": { 858 | "typeIdentifier": "t_uint8", 859 | "typeString": "uint8" 860 | } 861 | }, 862 | "functionReturnParameters": 1827, 863 | "id": 1829, 864 | "nodeType": "Return", 865 | "src": "1539:16:9" 866 | } 867 | ] 868 | }, 869 | "documentation": { 870 | "id": 1823, 871 | "nodeType": "StructuredDocumentation", 872 | "src": "938:538:9", 873 | "text": "@dev Returns the number of decimals used to get its user representation.\nFor example, if `decimals` equals `2`, a balance of `505` tokens should\nbe displayed to a user as `5,05` (`505 / 10 ** 2`).\n * Tokens usually opt for a value of 18, imitating the relationship between\nEther and Wei.\n * NOTE: This information is only used for _display_ purposes: it in\nno way affects any of the arithmetic of the contract, including\n{IERC20-balanceOf} and {IERC20-transfer}." 874 | }, 875 | "functionSelector": "313ce567", 876 | "id": 1831, 877 | "implemented": true, 878 | "kind": "function", 879 | "modifiers": [], 880 | "name": "decimals", 881 | "nodeType": "FunctionDefinition", 882 | "overrides": null, 883 | "parameters": { 884 | "id": 1824, 885 | "nodeType": "ParameterList", 886 | "parameters": [], 887 | "src": "1498:2:9" 888 | }, 889 | "returnParameters": { 890 | "id": 1827, 891 | "nodeType": "ParameterList", 892 | "parameters": [ 893 | { 894 | "constant": false, 895 | "id": 1826, 896 | "name": "", 897 | "nodeType": "VariableDeclaration", 898 | "overrides": null, 899 | "scope": 1831, 900 | "src": "1522:5:9", 901 | "stateVariable": false, 902 | "storageLocation": "default", 903 | "typeDescriptions": { 904 | "typeIdentifier": "t_uint8", 905 | "typeString": "uint8" 906 | }, 907 | "typeName": { 908 | "id": 1825, 909 | "name": "uint8", 910 | "nodeType": "ElementaryTypeName", 911 | "src": "1522:5:9", 912 | "typeDescriptions": { 913 | "typeIdentifier": "t_uint8", 914 | "typeString": "uint8" 915 | } 916 | }, 917 | "value": null, 918 | "visibility": "internal" 919 | } 920 | ], 921 | "src": "1521:7:9" 922 | }, 923 | "scope": 1832, 924 | "src": "1481:81:9", 925 | "stateMutability": "view", 926 | "virtual": false, 927 | "visibility": "public" 928 | } 929 | ], 930 | "scope": 1833, 931 | "src": "109:1455:9" 932 | } 933 | ], 934 | "src": "0:1565:9" 935 | }, 936 | "legacyAST": { 937 | "absolutePath": "@openzeppelin/contracts/token/ERC20/ERC20Detailed.sol", 938 | "exportedSymbols": { 939 | "ERC20Detailed": [ 940 | 1832 941 | ] 942 | }, 943 | "id": 1833, 944 | "nodeType": "SourceUnit", 945 | "nodes": [ 946 | { 947 | "id": 1771, 948 | "literals": [ 949 | "solidity", 950 | "^", 951 | "0.6", 952 | ".0" 953 | ], 954 | "nodeType": "PragmaDirective", 955 | "src": "0:23:9" 956 | }, 957 | { 958 | "absolutePath": "@openzeppelin/contracts/token/ERC20/IERC20.sol", 959 | "file": "./IERC20.sol", 960 | "id": 1772, 961 | "nodeType": "ImportDirective", 962 | "scope": 1833, 963 | "sourceUnit": 1911, 964 | "src": "25:22:9", 965 | "symbolAliases": [], 966 | "unitAlias": "" 967 | }, 968 | { 969 | "abstract": true, 970 | "baseContracts": [ 971 | { 972 | "arguments": null, 973 | "baseName": { 974 | "contractScope": null, 975 | "id": 1774, 976 | "name": "IERC20", 977 | "nodeType": "UserDefinedTypeName", 978 | "referencedDeclaration": 1910, 979 | "src": "144:6:9", 980 | "typeDescriptions": { 981 | "typeIdentifier": "t_contract$_IERC20_$1910", 982 | "typeString": "contract IERC20" 983 | } 984 | }, 985 | "id": 1775, 986 | "nodeType": "InheritanceSpecifier", 987 | "src": "144:6:9" 988 | } 989 | ], 990 | "contractDependencies": [ 991 | 1910 992 | ], 993 | "contractKind": "contract", 994 | "documentation": { 995 | "id": 1773, 996 | "nodeType": "StructuredDocumentation", 997 | "src": "49:59:9", 998 | "text": "@dev Optional functions from the ERC20 standard." 999 | }, 1000 | "fullyImplemented": false, 1001 | "id": 1832, 1002 | "linearizedBaseContracts": [ 1003 | 1832, 1004 | 1910 1005 | ], 1006 | "name": "ERC20Detailed", 1007 | "nodeType": "ContractDefinition", 1008 | "nodes": [ 1009 | { 1010 | "constant": false, 1011 | "id": 1777, 1012 | "name": "_name", 1013 | "nodeType": "VariableDeclaration", 1014 | "overrides": null, 1015 | "scope": 1832, 1016 | "src": "157:20:9", 1017 | "stateVariable": true, 1018 | "storageLocation": "default", 1019 | "typeDescriptions": { 1020 | "typeIdentifier": "t_string_storage", 1021 | "typeString": "string" 1022 | }, 1023 | "typeName": { 1024 | "id": 1776, 1025 | "name": "string", 1026 | "nodeType": "ElementaryTypeName", 1027 | "src": "157:6:9", 1028 | "typeDescriptions": { 1029 | "typeIdentifier": "t_string_storage_ptr", 1030 | "typeString": "string" 1031 | } 1032 | }, 1033 | "value": null, 1034 | "visibility": "private" 1035 | }, 1036 | { 1037 | "constant": false, 1038 | "id": 1779, 1039 | "name": "_symbol", 1040 | "nodeType": "VariableDeclaration", 1041 | "overrides": null, 1042 | "scope": 1832, 1043 | "src": "183:22:9", 1044 | "stateVariable": true, 1045 | "storageLocation": "default", 1046 | "typeDescriptions": { 1047 | "typeIdentifier": "t_string_storage", 1048 | "typeString": "string" 1049 | }, 1050 | "typeName": { 1051 | "id": 1778, 1052 | "name": "string", 1053 | "nodeType": "ElementaryTypeName", 1054 | "src": "183:6:9", 1055 | "typeDescriptions": { 1056 | "typeIdentifier": "t_string_storage_ptr", 1057 | "typeString": "string" 1058 | } 1059 | }, 1060 | "value": null, 1061 | "visibility": "private" 1062 | }, 1063 | { 1064 | "constant": false, 1065 | "id": 1781, 1066 | "name": "_decimals", 1067 | "nodeType": "VariableDeclaration", 1068 | "overrides": null, 1069 | "scope": 1832, 1070 | "src": "211:23:9", 1071 | "stateVariable": true, 1072 | "storageLocation": "default", 1073 | "typeDescriptions": { 1074 | "typeIdentifier": "t_uint8", 1075 | "typeString": "uint8" 1076 | }, 1077 | "typeName": { 1078 | "id": 1780, 1079 | "name": "uint8", 1080 | "nodeType": "ElementaryTypeName", 1081 | "src": "211:5:9", 1082 | "typeDescriptions": { 1083 | "typeIdentifier": "t_uint8", 1084 | "typeString": "uint8" 1085 | } 1086 | }, 1087 | "value": null, 1088 | "visibility": "private" 1089 | }, 1090 | { 1091 | "body": { 1092 | "id": 1803, 1093 | "nodeType": "Block", 1094 | "src": "503:85:9", 1095 | "statements": [ 1096 | { 1097 | "expression": { 1098 | "argumentTypes": null, 1099 | "id": 1793, 1100 | "isConstant": false, 1101 | "isLValue": false, 1102 | "isPure": false, 1103 | "lValueRequested": false, 1104 | "leftHandSide": { 1105 | "argumentTypes": null, 1106 | "id": 1791, 1107 | "name": "_name", 1108 | "nodeType": "Identifier", 1109 | "overloadedDeclarations": [], 1110 | "referencedDeclaration": 1777, 1111 | "src": "513:5:9", 1112 | "typeDescriptions": { 1113 | "typeIdentifier": "t_string_storage", 1114 | "typeString": "string storage ref" 1115 | } 1116 | }, 1117 | "nodeType": "Assignment", 1118 | "operator": "=", 1119 | "rightHandSide": { 1120 | "argumentTypes": null, 1121 | "id": 1792, 1122 | "name": "name", 1123 | "nodeType": "Identifier", 1124 | "overloadedDeclarations": [], 1125 | "referencedDeclaration": 1784, 1126 | "src": "521:4:9", 1127 | "typeDescriptions": { 1128 | "typeIdentifier": "t_string_memory_ptr", 1129 | "typeString": "string memory" 1130 | } 1131 | }, 1132 | "src": "513:12:9", 1133 | "typeDescriptions": { 1134 | "typeIdentifier": "t_string_storage", 1135 | "typeString": "string storage ref" 1136 | } 1137 | }, 1138 | "id": 1794, 1139 | "nodeType": "ExpressionStatement", 1140 | "src": "513:12:9" 1141 | }, 1142 | { 1143 | "expression": { 1144 | "argumentTypes": null, 1145 | "id": 1797, 1146 | "isConstant": false, 1147 | "isLValue": false, 1148 | "isPure": false, 1149 | "lValueRequested": false, 1150 | "leftHandSide": { 1151 | "argumentTypes": null, 1152 | "id": 1795, 1153 | "name": "_symbol", 1154 | "nodeType": "Identifier", 1155 | "overloadedDeclarations": [], 1156 | "referencedDeclaration": 1779, 1157 | "src": "535:7:9", 1158 | "typeDescriptions": { 1159 | "typeIdentifier": "t_string_storage", 1160 | "typeString": "string storage ref" 1161 | } 1162 | }, 1163 | "nodeType": "Assignment", 1164 | "operator": "=", 1165 | "rightHandSide": { 1166 | "argumentTypes": null, 1167 | "id": 1796, 1168 | "name": "symbol", 1169 | "nodeType": "Identifier", 1170 | "overloadedDeclarations": [], 1171 | "referencedDeclaration": 1786, 1172 | "src": "545:6:9", 1173 | "typeDescriptions": { 1174 | "typeIdentifier": "t_string_memory_ptr", 1175 | "typeString": "string memory" 1176 | } 1177 | }, 1178 | "src": "535:16:9", 1179 | "typeDescriptions": { 1180 | "typeIdentifier": "t_string_storage", 1181 | "typeString": "string storage ref" 1182 | } 1183 | }, 1184 | "id": 1798, 1185 | "nodeType": "ExpressionStatement", 1186 | "src": "535:16:9" 1187 | }, 1188 | { 1189 | "expression": { 1190 | "argumentTypes": null, 1191 | "id": 1801, 1192 | "isConstant": false, 1193 | "isLValue": false, 1194 | "isPure": false, 1195 | "lValueRequested": false, 1196 | "leftHandSide": { 1197 | "argumentTypes": null, 1198 | "id": 1799, 1199 | "name": "_decimals", 1200 | "nodeType": "Identifier", 1201 | "overloadedDeclarations": [], 1202 | "referencedDeclaration": 1781, 1203 | "src": "561:9:9", 1204 | "typeDescriptions": { 1205 | "typeIdentifier": "t_uint8", 1206 | "typeString": "uint8" 1207 | } 1208 | }, 1209 | "nodeType": "Assignment", 1210 | "operator": "=", 1211 | "rightHandSide": { 1212 | "argumentTypes": null, 1213 | "id": 1800, 1214 | "name": "decimals", 1215 | "nodeType": "Identifier", 1216 | "overloadedDeclarations": [], 1217 | "referencedDeclaration": 1788, 1218 | "src": "573:8:9", 1219 | "typeDescriptions": { 1220 | "typeIdentifier": "t_uint8", 1221 | "typeString": "uint8" 1222 | } 1223 | }, 1224 | "src": "561:20:9", 1225 | "typeDescriptions": { 1226 | "typeIdentifier": "t_uint8", 1227 | "typeString": "uint8" 1228 | } 1229 | }, 1230 | "id": 1802, 1231 | "nodeType": "ExpressionStatement", 1232 | "src": "561:20:9" 1233 | } 1234 | ] 1235 | }, 1236 | "documentation": { 1237 | "id": 1782, 1238 | "nodeType": "StructuredDocumentation", 1239 | "src": "241:179:9", 1240 | "text": "@dev Sets the values for `name`, `symbol`, and `decimals`. All three of\nthese values are immutable: they can only be set once during\nconstruction." 1241 | }, 1242 | "id": 1804, 1243 | "implemented": true, 1244 | "kind": "constructor", 1245 | "modifiers": [], 1246 | "name": "", 1247 | "nodeType": "FunctionDefinition", 1248 | "overrides": null, 1249 | "parameters": { 1250 | "id": 1789, 1251 | "nodeType": "ParameterList", 1252 | "parameters": [ 1253 | { 1254 | "constant": false, 1255 | "id": 1784, 1256 | "name": "name", 1257 | "nodeType": "VariableDeclaration", 1258 | "overrides": null, 1259 | "scope": 1804, 1260 | "src": "438:18:9", 1261 | "stateVariable": false, 1262 | "storageLocation": "memory", 1263 | "typeDescriptions": { 1264 | "typeIdentifier": "t_string_memory_ptr", 1265 | "typeString": "string" 1266 | }, 1267 | "typeName": { 1268 | "id": 1783, 1269 | "name": "string", 1270 | "nodeType": "ElementaryTypeName", 1271 | "src": "438:6:9", 1272 | "typeDescriptions": { 1273 | "typeIdentifier": "t_string_storage_ptr", 1274 | "typeString": "string" 1275 | } 1276 | }, 1277 | "value": null, 1278 | "visibility": "internal" 1279 | }, 1280 | { 1281 | "constant": false, 1282 | "id": 1786, 1283 | "name": "symbol", 1284 | "nodeType": "VariableDeclaration", 1285 | "overrides": null, 1286 | "scope": 1804, 1287 | "src": "458:20:9", 1288 | "stateVariable": false, 1289 | "storageLocation": "memory", 1290 | "typeDescriptions": { 1291 | "typeIdentifier": "t_string_memory_ptr", 1292 | "typeString": "string" 1293 | }, 1294 | "typeName": { 1295 | "id": 1785, 1296 | "name": "string", 1297 | "nodeType": "ElementaryTypeName", 1298 | "src": "458:6:9", 1299 | "typeDescriptions": { 1300 | "typeIdentifier": "t_string_storage_ptr", 1301 | "typeString": "string" 1302 | } 1303 | }, 1304 | "value": null, 1305 | "visibility": "internal" 1306 | }, 1307 | { 1308 | "constant": false, 1309 | "id": 1788, 1310 | "name": "decimals", 1311 | "nodeType": "VariableDeclaration", 1312 | "overrides": null, 1313 | "scope": 1804, 1314 | "src": "480:14:9", 1315 | "stateVariable": false, 1316 | "storageLocation": "default", 1317 | "typeDescriptions": { 1318 | "typeIdentifier": "t_uint8", 1319 | "typeString": "uint8" 1320 | }, 1321 | "typeName": { 1322 | "id": 1787, 1323 | "name": "uint8", 1324 | "nodeType": "ElementaryTypeName", 1325 | "src": "480:5:9", 1326 | "typeDescriptions": { 1327 | "typeIdentifier": "t_uint8", 1328 | "typeString": "uint8" 1329 | } 1330 | }, 1331 | "value": null, 1332 | "visibility": "internal" 1333 | } 1334 | ], 1335 | "src": "437:58:9" 1336 | }, 1337 | "returnParameters": { 1338 | "id": 1790, 1339 | "nodeType": "ParameterList", 1340 | "parameters": [], 1341 | "src": "503:0:9" 1342 | }, 1343 | "scope": 1832, 1344 | "src": "425:163:9", 1345 | "stateMutability": "nonpayable", 1346 | "virtual": false, 1347 | "visibility": "public" 1348 | }, 1349 | { 1350 | "body": { 1351 | "id": 1812, 1352 | "nodeType": "Block", 1353 | "src": "705:29:9", 1354 | "statements": [ 1355 | { 1356 | "expression": { 1357 | "argumentTypes": null, 1358 | "id": 1810, 1359 | "name": "_name", 1360 | "nodeType": "Identifier", 1361 | "overloadedDeclarations": [], 1362 | "referencedDeclaration": 1777, 1363 | "src": "722:5:9", 1364 | "typeDescriptions": { 1365 | "typeIdentifier": "t_string_storage", 1366 | "typeString": "string storage ref" 1367 | } 1368 | }, 1369 | "functionReturnParameters": 1809, 1370 | "id": 1811, 1371 | "nodeType": "Return", 1372 | "src": "715:12:9" 1373 | } 1374 | ] 1375 | }, 1376 | "documentation": { 1377 | "id": 1805, 1378 | "nodeType": "StructuredDocumentation", 1379 | "src": "594:54:9", 1380 | "text": "@dev Returns the name of the token." 1381 | }, 1382 | "functionSelector": "06fdde03", 1383 | "id": 1813, 1384 | "implemented": true, 1385 | "kind": "function", 1386 | "modifiers": [], 1387 | "name": "name", 1388 | "nodeType": "FunctionDefinition", 1389 | "overrides": null, 1390 | "parameters": { 1391 | "id": 1806, 1392 | "nodeType": "ParameterList", 1393 | "parameters": [], 1394 | "src": "666:2:9" 1395 | }, 1396 | "returnParameters": { 1397 | "id": 1809, 1398 | "nodeType": "ParameterList", 1399 | "parameters": [ 1400 | { 1401 | "constant": false, 1402 | "id": 1808, 1403 | "name": "", 1404 | "nodeType": "VariableDeclaration", 1405 | "overrides": null, 1406 | "scope": 1813, 1407 | "src": "690:13:9", 1408 | "stateVariable": false, 1409 | "storageLocation": "memory", 1410 | "typeDescriptions": { 1411 | "typeIdentifier": "t_string_memory_ptr", 1412 | "typeString": "string" 1413 | }, 1414 | "typeName": { 1415 | "id": 1807, 1416 | "name": "string", 1417 | "nodeType": "ElementaryTypeName", 1418 | "src": "690:6:9", 1419 | "typeDescriptions": { 1420 | "typeIdentifier": "t_string_storage_ptr", 1421 | "typeString": "string" 1422 | } 1423 | }, 1424 | "value": null, 1425 | "visibility": "internal" 1426 | } 1427 | ], 1428 | "src": "689:15:9" 1429 | }, 1430 | "scope": 1832, 1431 | "src": "653:81:9", 1432 | "stateMutability": "view", 1433 | "virtual": false, 1434 | "visibility": "public" 1435 | }, 1436 | { 1437 | "body": { 1438 | "id": 1821, 1439 | "nodeType": "Block", 1440 | "src": "901:31:9", 1441 | "statements": [ 1442 | { 1443 | "expression": { 1444 | "argumentTypes": null, 1445 | "id": 1819, 1446 | "name": "_symbol", 1447 | "nodeType": "Identifier", 1448 | "overloadedDeclarations": [], 1449 | "referencedDeclaration": 1779, 1450 | "src": "918:7:9", 1451 | "typeDescriptions": { 1452 | "typeIdentifier": "t_string_storage", 1453 | "typeString": "string storage ref" 1454 | } 1455 | }, 1456 | "functionReturnParameters": 1818, 1457 | "id": 1820, 1458 | "nodeType": "Return", 1459 | "src": "911:14:9" 1460 | } 1461 | ] 1462 | }, 1463 | "documentation": { 1464 | "id": 1814, 1465 | "nodeType": "StructuredDocumentation", 1466 | "src": "740:102:9", 1467 | "text": "@dev Returns the symbol of the token, usually a shorter version of the\nname." 1468 | }, 1469 | "functionSelector": "95d89b41", 1470 | "id": 1822, 1471 | "implemented": true, 1472 | "kind": "function", 1473 | "modifiers": [], 1474 | "name": "symbol", 1475 | "nodeType": "FunctionDefinition", 1476 | "overrides": null, 1477 | "parameters": { 1478 | "id": 1815, 1479 | "nodeType": "ParameterList", 1480 | "parameters": [], 1481 | "src": "862:2:9" 1482 | }, 1483 | "returnParameters": { 1484 | "id": 1818, 1485 | "nodeType": "ParameterList", 1486 | "parameters": [ 1487 | { 1488 | "constant": false, 1489 | "id": 1817, 1490 | "name": "", 1491 | "nodeType": "VariableDeclaration", 1492 | "overrides": null, 1493 | "scope": 1822, 1494 | "src": "886:13:9", 1495 | "stateVariable": false, 1496 | "storageLocation": "memory", 1497 | "typeDescriptions": { 1498 | "typeIdentifier": "t_string_memory_ptr", 1499 | "typeString": "string" 1500 | }, 1501 | "typeName": { 1502 | "id": 1816, 1503 | "name": "string", 1504 | "nodeType": "ElementaryTypeName", 1505 | "src": "886:6:9", 1506 | "typeDescriptions": { 1507 | "typeIdentifier": "t_string_storage_ptr", 1508 | "typeString": "string" 1509 | } 1510 | }, 1511 | "value": null, 1512 | "visibility": "internal" 1513 | } 1514 | ], 1515 | "src": "885:15:9" 1516 | }, 1517 | "scope": 1832, 1518 | "src": "847:85:9", 1519 | "stateMutability": "view", 1520 | "virtual": false, 1521 | "visibility": "public" 1522 | }, 1523 | { 1524 | "body": { 1525 | "id": 1830, 1526 | "nodeType": "Block", 1527 | "src": "1529:33:9", 1528 | "statements": [ 1529 | { 1530 | "expression": { 1531 | "argumentTypes": null, 1532 | "id": 1828, 1533 | "name": "_decimals", 1534 | "nodeType": "Identifier", 1535 | "overloadedDeclarations": [], 1536 | "referencedDeclaration": 1781, 1537 | "src": "1546:9:9", 1538 | "typeDescriptions": { 1539 | "typeIdentifier": "t_uint8", 1540 | "typeString": "uint8" 1541 | } 1542 | }, 1543 | "functionReturnParameters": 1827, 1544 | "id": 1829, 1545 | "nodeType": "Return", 1546 | "src": "1539:16:9" 1547 | } 1548 | ] 1549 | }, 1550 | "documentation": { 1551 | "id": 1823, 1552 | "nodeType": "StructuredDocumentation", 1553 | "src": "938:538:9", 1554 | "text": "@dev Returns the number of decimals used to get its user representation.\nFor example, if `decimals` equals `2`, a balance of `505` tokens should\nbe displayed to a user as `5,05` (`505 / 10 ** 2`).\n * Tokens usually opt for a value of 18, imitating the relationship between\nEther and Wei.\n * NOTE: This information is only used for _display_ purposes: it in\nno way affects any of the arithmetic of the contract, including\n{IERC20-balanceOf} and {IERC20-transfer}." 1555 | }, 1556 | "functionSelector": "313ce567", 1557 | "id": 1831, 1558 | "implemented": true, 1559 | "kind": "function", 1560 | "modifiers": [], 1561 | "name": "decimals", 1562 | "nodeType": "FunctionDefinition", 1563 | "overrides": null, 1564 | "parameters": { 1565 | "id": 1824, 1566 | "nodeType": "ParameterList", 1567 | "parameters": [], 1568 | "src": "1498:2:9" 1569 | }, 1570 | "returnParameters": { 1571 | "id": 1827, 1572 | "nodeType": "ParameterList", 1573 | "parameters": [ 1574 | { 1575 | "constant": false, 1576 | "id": 1826, 1577 | "name": "", 1578 | "nodeType": "VariableDeclaration", 1579 | "overrides": null, 1580 | "scope": 1831, 1581 | "src": "1522:5:9", 1582 | "stateVariable": false, 1583 | "storageLocation": "default", 1584 | "typeDescriptions": { 1585 | "typeIdentifier": "t_uint8", 1586 | "typeString": "uint8" 1587 | }, 1588 | "typeName": { 1589 | "id": 1825, 1590 | "name": "uint8", 1591 | "nodeType": "ElementaryTypeName", 1592 | "src": "1522:5:9", 1593 | "typeDescriptions": { 1594 | "typeIdentifier": "t_uint8", 1595 | "typeString": "uint8" 1596 | } 1597 | }, 1598 | "value": null, 1599 | "visibility": "internal" 1600 | } 1601 | ], 1602 | "src": "1521:7:9" 1603 | }, 1604 | "scope": 1832, 1605 | "src": "1481:81:9", 1606 | "stateMutability": "view", 1607 | "virtual": false, 1608 | "visibility": "public" 1609 | } 1610 | ], 1611 | "scope": 1833, 1612 | "src": "109:1455:9" 1613 | } 1614 | ], 1615 | "src": "0:1565:9" 1616 | }, 1617 | "compiler": { 1618 | "name": "solc", 1619 | "version": "0.6.3+commit.8dda9521.Emscripten.clang" 1620 | }, 1621 | "networks": {}, 1622 | "schemaVersion": "3.2.1", 1623 | "updatedAt": "2020-07-08T06:32:01.083Z", 1624 | "devdoc": { 1625 | "details": "Optional functions from the ERC20 standard.", 1626 | "methods": { 1627 | "allowance(address,address)": { 1628 | "details": "Returns the remaining number of tokens that `spender` will be allowed to spend on behalf of `owner` through {transferFrom}. This is zero by default. * This value changes when {approve} or {transferFrom} are called." 1629 | }, 1630 | "approve(address,uint256)": { 1631 | "details": "Sets `amount` as the allowance of `spender` over the caller's tokens. * Returns a boolean value indicating whether the operation succeeded. * IMPORTANT: Beware that changing an allowance with this method brings the risk that someone may use both the old and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * Emits an {Approval} event." 1632 | }, 1633 | "balanceOf(address)": { 1634 | "details": "Returns the amount of tokens owned by `account`." 1635 | }, 1636 | "constructor": { 1637 | "details": "Sets the values for `name`, `symbol`, and `decimals`. All three of these values are immutable: they can only be set once during construction." 1638 | }, 1639 | "decimals()": { 1640 | "details": "Returns the number of decimals used to get its user representation. For example, if `decimals` equals `2`, a balance of `505` tokens should be displayed to a user as `5,05` (`505 / 10 ** 2`). * Tokens usually opt for a value of 18, imitating the relationship between Ether and Wei. * NOTE: This information is only used for _display_ purposes: it in no way affects any of the arithmetic of the contract, including {IERC20-balanceOf} and {IERC20-transfer}." 1641 | }, 1642 | "name()": { 1643 | "details": "Returns the name of the token." 1644 | }, 1645 | "symbol()": { 1646 | "details": "Returns the symbol of the token, usually a shorter version of the name." 1647 | }, 1648 | "totalSupply()": { 1649 | "details": "Returns the amount of tokens in existence." 1650 | }, 1651 | "transfer(address,uint256)": { 1652 | "details": "Moves `amount` tokens from the caller's account to `recipient`. * Returns a boolean value indicating whether the operation succeeded. * Emits a {Transfer} event." 1653 | }, 1654 | "transferFrom(address,address,uint256)": { 1655 | "details": "Moves `amount` tokens from `sender` to `recipient` using the allowance mechanism. `amount` is then deducted from the caller's allowance. * Returns a boolean value indicating whether the operation succeeded. * Emits a {Transfer} event." 1656 | } 1657 | } 1658 | }, 1659 | "userdoc": { 1660 | "methods": {} 1661 | } 1662 | } --------------------------------------------------------------------------------