├── src
├── ethereum
│ └── faucet.js
├── address.txt
├── images
│ ├── bg-1.png
│ └── bg.png
├── setupTests.js
├── App.test.js
├── index.css
├── reportWebVitals.js
├── App.css
├── index.js
├── logo.svg
├── abi.json
└── App.js
├── public
├── robots.txt
├── favicon.ico
├── logo192.png
├── logo512.png
├── manifest.json
└── index.html
├── README.md
├── .gitignore
└── package.json
/src/ethereum/faucet.js:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/address.txt:
--------------------------------------------------------------------------------
1 | 0xE16738Fb636c83b198A71368dd0D580FBc3B993B
--------------------------------------------------------------------------------
/public/robots.txt:
--------------------------------------------------------------------------------
1 | # https://www.robotstxt.org/robotstxt.html
2 | User-agent: *
3 | Disallow:
4 |
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jspruance/faucet-dapp-starter-code-connect-wallet/main/public/favicon.ico
--------------------------------------------------------------------------------
/public/logo192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jspruance/faucet-dapp-starter-code-connect-wallet/main/public/logo192.png
--------------------------------------------------------------------------------
/public/logo512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jspruance/faucet-dapp-starter-code-connect-wallet/main/public/logo512.png
--------------------------------------------------------------------------------
/src/images/bg-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jspruance/faucet-dapp-starter-code-connect-wallet/main/src/images/bg-1.png
--------------------------------------------------------------------------------
/src/images/bg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jspruance/faucet-dapp-starter-code-connect-wallet/main/src/images/bg.png
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Starter code for Faucet dApp tutorial
2 |
3 | Boilerplate code consisting of a new create-react-app project and some basic HTML and CSS.
4 |
--------------------------------------------------------------------------------
/src/setupTests.js:
--------------------------------------------------------------------------------
1 | // jest-dom adds custom jest matchers for asserting on DOM nodes.
2 | // allows you to do things like:
3 | // expect(element).toHaveTextContent(/react/i)
4 | // learn more: https://github.com/testing-library/jest-dom
5 | import '@testing-library/jest-dom';
6 |
--------------------------------------------------------------------------------
/src/App.test.js:
--------------------------------------------------------------------------------
1 | import { render, screen } from '@testing-library/react';
2 | import App from './App';
3 |
4 | test('renders learn react link', () => {
5 | render();
6 | const linkElement = screen.getByText(/learn react/i);
7 | expect(linkElement).toBeInTheDocument();
8 | });
9 |
--------------------------------------------------------------------------------
/.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 |
--------------------------------------------------------------------------------
/src/index.css:
--------------------------------------------------------------------------------
1 | body {
2 | margin: 0;
3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
5 | sans-serif;
6 | -webkit-font-smoothing: antialiased;
7 | -moz-osx-font-smoothing: grayscale;
8 | }
9 |
10 | code {
11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
12 | monospace;
13 | }
14 |
--------------------------------------------------------------------------------
/src/reportWebVitals.js:
--------------------------------------------------------------------------------
1 | const reportWebVitals = onPerfEntry => {
2 | if (onPerfEntry && onPerfEntry instanceof Function) {
3 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
4 | getCLS(onPerfEntry);
5 | getFID(onPerfEntry);
6 | getFCP(onPerfEntry);
7 | getLCP(onPerfEntry);
8 | getTTFB(onPerfEntry);
9 | });
10 | }
11 | };
12 |
13 | export default reportWebVitals;
14 |
--------------------------------------------------------------------------------
/public/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "short_name": "React App",
3 | "name": "Create React App Sample",
4 | "icons": [
5 | {
6 | "src": "favicon.ico",
7 | "sizes": "64x64 32x32 24x24 16x16",
8 | "type": "image/x-icon"
9 | },
10 | {
11 | "src": "logo192.png",
12 | "type": "image/png",
13 | "sizes": "192x192"
14 | },
15 | {
16 | "src": "logo512.png",
17 | "type": "image/png",
18 | "sizes": "512x512"
19 | }
20 | ],
21 | "start_url": ".",
22 | "display": "standalone",
23 | "theme_color": "#000000",
24 | "background_color": "#ffffff"
25 | }
26 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "faucet-ui",
3 | "version": "0.1.0",
4 | "private": true,
5 | "dependencies": {
6 | "@testing-library/jest-dom": "^5.16.5",
7 | "@testing-library/react": "^13.4.0",
8 | "@testing-library/user-event": "^13.5.0",
9 | "bulma": "^0.9.4",
10 | "ethers": "^5.7.1",
11 | "react": "^18.2.0",
12 | "react-dom": "^18.2.0",
13 | "react-scripts": "5.0.1",
14 | "web-vitals": "^2.1.4"
15 | },
16 | "scripts": {
17 | "start": "react-scripts start",
18 | "build": "react-scripts build",
19 | "test": "react-scripts test",
20 | "eject": "react-scripts eject"
21 | },
22 | "eslintConfig": {
23 | "extends": [
24 | "react-app",
25 | "react-app/jest"
26 | ]
27 | },
28 | "browserslist": {
29 | "production": [
30 | ">0.2%",
31 | "not dead",
32 | "not op_mini all"
33 | ],
34 | "development": [
35 | "last 1 chrome version",
36 | "last 1 firefox version",
37 | "last 1 safari version"
38 | ]
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/App.css:
--------------------------------------------------------------------------------
1 | body {
2 | background: url("./images/bg-1.png") no-repeat;
3 | background-color: #070709;
4 | color: white;
5 | }
6 |
7 | .title {
8 | color: white;
9 | margin-bottom: 1 rem;
10 | }
11 |
12 | .box {
13 | margin-top: 50px;
14 | }
15 |
16 | .panel {
17 | margin-top: 2em;
18 | }
19 |
20 | .panel-heading {
21 | xbackground-image: linear-gradient(to left,#38052F, #070709);
22 | background-color: black;
23 | color: white;
24 | }
25 |
26 | .address-box {
27 | padding: 3em;
28 | }
29 |
30 | .box .title {
31 | color: #333;
32 | }
33 |
34 | .navbar {
35 | background-color: black;
36 | }
37 |
38 | .navbar .navbar-item {
39 | color: white;
40 | }
41 |
42 | .connect-wallet span {
43 | color: #E10859;
44 | }
45 |
46 | .connect-wallet:hover {
47 | background-color: #e1e1e1 !important;
48 | }
49 |
50 | .container.main-content {
51 | max-width: 1000px !important;
52 | }
53 |
54 | .faucet-hero-body {
55 | margin-top: 100px;
56 | }
57 |
58 | .withdraw-error {
59 | color: red;
60 | }
61 |
62 | .withdraw-success {
63 | color: green;
64 | }
--------------------------------------------------------------------------------
/src/index.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import ReactDOM from "react-dom/client";
3 | import "bulma/css/bulma.min.css";
4 | import "./index.css";
5 | import App from "./App";
6 | import reportWebVitals from "./reportWebVitals";
7 |
8 | const root = ReactDOM.createRoot(document.getElementById("root"));
9 | root.render(
10 |
11 |
12 |
13 | );
14 |
15 | //****** ** ** ******** **
16 | ///*////** /** /** /**///// ****** /**
17 | ///* /** /** ****** ***** /** ** /** ** **/**///** /** ****** ****** ***** ******
18 | ///****** /** **////** **///**/** ** /******* //** ** /** /** /** **////**//**//* **///**//**//*
19 | ///*//// ** /**/** /**/** // /**** /**//// //*** /****** /**/** /** /** / /******* /** /
20 | ///* /** /**/** /**/** **/**/** /** **/** /**/// /**/** /** /** /**//// /**
21 | ///******* ***//****** //***** /**//** /******** ** //**/** ***//****** /*** //******/***
22 | ///////// /// ////// ///// // // //////// // // // /// ////// /// ////// ///
23 | reportWebVitals();
24 |
--------------------------------------------------------------------------------
/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
12 |
13 |
17 |
18 |
27 | React App
28 |
29 |
30 |
31 |
32 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/src/logo.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/abi.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | inputs: [
4 | {
5 | internalType: "address",
6 | name: "tokenAddress",
7 | type: "address",
8 | },
9 | ],
10 | stateMutability: "payable",
11 | type: "constructor",
12 | },
13 | {
14 | anonymous: false,
15 | inputs: [
16 | {
17 | indexed: true,
18 | internalType: "address",
19 | name: "from",
20 | type: "address",
21 | },
22 | {
23 | indexed: true,
24 | internalType: "uint256",
25 | name: "amount",
26 | type: "uint256",
27 | },
28 | ],
29 | name: "Deposit",
30 | type: "event",
31 | },
32 | {
33 | anonymous: false,
34 | inputs: [
35 | {
36 | indexed: true,
37 | internalType: "address",
38 | name: "to",
39 | type: "address",
40 | },
41 | {
42 | indexed: true,
43 | internalType: "uint256",
44 | name: "amount",
45 | type: "uint256",
46 | },
47 | ],
48 | name: "Withdrawal",
49 | type: "event",
50 | },
51 | {
52 | inputs: [],
53 | name: "getBalance",
54 | outputs: [
55 | {
56 | internalType: "uint256",
57 | name: "",
58 | type: "uint256",
59 | },
60 | ],
61 | stateMutability: "view",
62 | type: "function",
63 | },
64 | {
65 | inputs: [],
66 | name: "lockTime",
67 | outputs: [
68 | {
69 | internalType: "uint256",
70 | name: "",
71 | type: "uint256",
72 | },
73 | ],
74 | stateMutability: "view",
75 | type: "function",
76 | },
77 | {
78 | inputs: [],
79 | name: "requestTokens",
80 | outputs: [],
81 | stateMutability: "nonpayable",
82 | type: "function",
83 | },
84 | {
85 | inputs: [
86 | {
87 | internalType: "uint256",
88 | name: "amount",
89 | type: "uint256",
90 | },
91 | ],
92 | name: "setLockTime",
93 | outputs: [],
94 | stateMutability: "nonpayable",
95 | type: "function",
96 | },
97 | {
98 | inputs: [
99 | {
100 | internalType: "uint256",
101 | name: "amount",
102 | type: "uint256",
103 | },
104 | ],
105 | name: "setWithdrawalAmount",
106 | outputs: [],
107 | stateMutability: "nonpayable",
108 | type: "function",
109 | },
110 | {
111 | inputs: [],
112 | name: "token",
113 | outputs: [
114 | {
115 | internalType: "contract IERC20",
116 | name: "",
117 | type: "address",
118 | },
119 | ],
120 | stateMutability: "view",
121 | type: "function",
122 | },
123 | {
124 | inputs: [],
125 | name: "withdraw",
126 | outputs: [],
127 | stateMutability: "nonpayable",
128 | type: "function",
129 | },
130 | {
131 | inputs: [],
132 | name: "withdrawalAmount",
133 | outputs: [
134 | {
135 | internalType: "uint256",
136 | name: "",
137 | type: "uint256",
138 | },
139 | ],
140 | stateMutability: "view",
141 | type: "function",
142 | },
143 | {
144 | stateMutability: "payable",
145 | type: "receive",
146 | },
147 | ];
--------------------------------------------------------------------------------
/src/App.js:
--------------------------------------------------------------------------------
1 | import { useEffect, useState } from "react";
2 | import "./App.css";
3 |
4 | function App() {
5 | const [walletAddress, setWalletAddress] = useState("");
6 |
7 | useEffect(() => {
8 | getCurrentWalletConnected();
9 | addWalletListener();
10 | }, [walletAddress]);
11 |
12 | const connectWallet = async () => {
13 | if (typeof window != "undefined" && typeof window.ethereum != "undefined") {
14 | try {
15 | /* MetaMask is installed */
16 | const accounts = await window.ethereum.request({
17 | method: "eth_requestAccounts",
18 | });
19 | setWalletAddress(accounts[0]);
20 | console.log(accounts[0]);
21 | } catch (err) {
22 | console.error(err.message);
23 | }
24 | } else {
25 | /* MetaMask is not installed */
26 | console.log("Please install MetaMask");
27 | }
28 | };
29 |
30 | const getCurrentWalletConnected = async () => {
31 | if (typeof window != "undefined" && typeof window.ethereum != "undefined") {
32 | try {
33 | const accounts = await window.ethereum.request({
34 | method: "eth_accounts",
35 | });
36 | if (accounts.length > 0) {
37 | setWalletAddress(accounts[0]);
38 | console.log(accounts[0]);
39 | } else {
40 | console.log("Connect to MetaMask using the Connect button");
41 | }
42 | } catch (err) {
43 | console.error(err.message);
44 | }
45 | } else {
46 | /* MetaMask is not installed */
47 | console.log("Please install MetaMask");
48 | }
49 | };
50 |
51 | const addWalletListener = async () => {
52 | if (typeof window != "undefined" && typeof window.ethereum != "undefined") {
53 | window.ethereum.on("accountsChanged", (accounts) => {
54 | setWalletAddress(accounts[0]);
55 | console.log(accounts[0]);
56 | });
57 | } else {
58 | /* MetaMask is not installed */
59 | setWalletAddress("");
60 | console.log("Please install MetaMask");
61 | }
62 | };
63 |
64 | return (
65 |
66 |
90 |
91 |
92 |
93 |
Faucet
94 |
Fast and reliable. 50 OCT/day.
95 |
96 |
97 |
98 |
103 |
104 |
105 |
108 |
109 |
110 |
111 | Transaction Data
112 |
113 |
transaction data
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 | );
122 | }
123 |
124 | export default App;
125 |
--------------------------------------------------------------------------------