├── .gitignore
├── README.md
├── migrations
├── 1_initial_migration.js
└── 2_deploy_contracts.js
├── package-lock.json
├── package.json
├── public
├── favicon.ico
├── index.html
└── manifest.json
├── src
├── abis
│ ├── DStorage.json
│ └── Migrations.json
├── box.png
├── components
│ ├── App.css
│ ├── App.js
│ ├── Main.js
│ ├── Navbar.js
│ └── helpers.js
├── contracts
│ ├── DStorage.sol
│ └── Migrations.sol
├── index.js
├── logo.png
└── serviceWorker.js
├── test
└── test.js
└── truffle-config.js
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_STORE
2 | node_modules
3 | scripts/flow/*/.flowconfig
4 | .flowconfig
5 | *~
6 | *.pyc
7 | .grunt
8 | _SpecRunner.html
9 | __benchmarks__
10 | build/
11 | remote-repo/
12 | coverage/
13 | .module-cache
14 | fixtures/dom/public/react-dom.js
15 | fixtures/dom/public/react.js
16 | test/the-files-to-test.generated.js
17 | *.log*
18 | chrome-user-data
19 | *.sublime-project
20 | *.sublime-workspace
21 | .idea
22 | *.iml
23 | .vscode
24 | *.swp
25 | *.swo
26 |
27 | packages/react-devtools-core/dist
28 | packages/react-devtools-extensions/chrome/build
29 | packages/react-devtools-extensions/chrome/*.crx
30 | packages/react-devtools-extensions/chrome/*.pem
31 | packages/react-devtools-extensions/firefox/build
32 | packages/react-devtools-extensions/firefox/*.xpi
33 | packages/react-devtools-extensions/firefox/*.pem
34 | packages/react-devtools-extensions/shared/build
35 | packages/react-devtools-extensions/.tempUserDataDir
36 | packages/react-devtools-inline/dist
37 | packages/react-devtools-shell/dist
38 | packages/react-devtools-timeline/dist
39 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # dropbox-blockchain
2 |
3 |
4 |
5 |
6 | # requirements
7 | - download nodejs [🔗](https://nodejs.org/en/download/ "🔗")
8 | - install truffle
9 | `npm install --g truffle`
10 | - download ganache [🔗](https://trufflesuite.com/ganache/ " 🔗")
11 | - add metamask extension [🔗](https://chrome.google.com/webstore/detail/metamask/nkbihfbeogaeaoehlefnkodbefgpgknn "🔗")
12 |
13 |
14 | # prepare the project
15 |
16 | - `cd Desktop`
17 |
18 | - `git clone git@github.com:yenilikci/dropbox-blockchain.git`
19 |
20 | - `cd dropbox-blockchain`
21 |
22 | - `npm i`
23 |
24 | - `npm run start`
25 |
26 | > start ganache
27 |
28 | > set host and port in truffle config file (dropbox-blockchain > truffle-config.js)
29 |
30 |
31 | networks: {
32 | development: {
33 | host: "127.0.0.1",
34 | port: 7545,
35 | network_id: "*"
36 | }
37 | }
38 |
39 | don't forget to add your network
40 |
41 | Metamask > Settings > Networks > Add a network
42 |
43 | enter the rpc server connection and client id information
44 |
45 | connect to your account :)
46 |
--------------------------------------------------------------------------------
/migrations/1_initial_migration.js:
--------------------------------------------------------------------------------
1 | const Migrations = artifacts.require("Migrations");
2 |
3 | module.exports = function (deployer) {
4 | deployer.deploy(Migrations);
5 | };
6 |
--------------------------------------------------------------------------------
/migrations/2_deploy_contracts.js:
--------------------------------------------------------------------------------
1 | const DStorage = artifacts.require("DStorage");
2 |
3 | module.exports = function (deployer) {
4 | deployer.deploy(DStorage);
5 | };
6 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "dropbox-blockchain",
3 | "version": "0.1.0",
4 | "description": "Decentralized File Storage",
5 | "author": "yenilikci",
6 | "homepage": ".",
7 | "dependencies": {
8 | "@truffle/hdwallet-provider": "^1.7.0",
9 | "babel-polyfill": "6.26.0",
10 | "babel-preset-env": "1.7.0",
11 | "babel-preset-es2015": "6.24.1",
12 | "babel-preset-stage-2": "6.24.1",
13 | "babel-preset-stage-3": "6.24.1",
14 | "babel-register": "6.26.0",
15 | "bootstrap": "^4.5.2",
16 | "chai": "4.2.0",
17 | "chai-as-promised": "7.1.1",
18 | "chai-bignumber": "3.0.0",
19 | "dotenv": "^8.2.0",
20 | "identicon.js": "^2.3.3",
21 | "ipfs-http-client": "^33.1.1",
22 | "moment": "^2.29.1",
23 | "react": "^16.13.1",
24 | "react-bootstrap": "^1.3.0",
25 | "react-dom": "^16.13.1",
26 | "react-scripts": "^3.4.3",
27 | "truffle": "^5.1.45",
28 | "truffle-hdwallet-provider-privkey": "^0.3.0",
29 | "web3": "^1.6.1"
30 | },
31 | "scripts": {
32 | "start": "react-scripts start",
33 | "build": "react-scripts build",
34 | "test": "react-scripts test",
35 | "eject": "react-scripts eject",
36 | "predeploy": "npm run build",
37 | "deploy": "gh-pages -d build"
38 | },
39 | "eslintConfig": {
40 | "extends": "react-app"
41 | },
42 | "browserslist": [
43 | ">0.2%",
44 | "not dead",
45 | "not ie <= 11",
46 | "not op_mini all"
47 | ],
48 | "devDependencies": {
49 | "gh-pages": "^2.2.0"
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yenilikci/dropbox-clone-blockchain-reactjs-solidity/6d2fefb439a4cbf025c50cbbbf82c5ff79bd2aac/public/favicon.ico
--------------------------------------------------------------------------------
/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
10 |
11 |
15 |
16 |
25 | DStorage
26 |
27 |
28 |
29 |
30 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/public/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "short_name": "Starter Kit",
3 | "name": "Starter Kit",
4 | "icons": [
5 | {
6 | "src": "favicon.ico",
7 | "sizes": "64x64 32x32 24x24 16x16",
8 | "type": "image/x-icon"
9 | }
10 | ],
11 | "start_url": ".",
12 | "display": "standalone",
13 | "theme_color": "#000000",
14 | "background_color": "#ffffff"
15 | }
16 |
--------------------------------------------------------------------------------
/src/abis/Migrations.json:
--------------------------------------------------------------------------------
1 | {
2 | "contractName": "Migrations",
3 | "abi": [
4 | {
5 | "inputs": [],
6 | "payable": false,
7 | "stateMutability": "nonpayable",
8 | "type": "constructor"
9 | },
10 | {
11 | "constant": true,
12 | "inputs": [],
13 | "name": "last_completed_migration",
14 | "outputs": [
15 | {
16 | "internalType": "uint256",
17 | "name": "",
18 | "type": "uint256"
19 | }
20 | ],
21 | "payable": false,
22 | "stateMutability": "view",
23 | "type": "function"
24 | },
25 | {
26 | "constant": true,
27 | "inputs": [],
28 | "name": "owner",
29 | "outputs": [
30 | {
31 | "internalType": "address",
32 | "name": "",
33 | "type": "address"
34 | }
35 | ],
36 | "payable": false,
37 | "stateMutability": "view",
38 | "type": "function"
39 | },
40 | {
41 | "constant": false,
42 | "inputs": [
43 | {
44 | "internalType": "uint256",
45 | "name": "completed",
46 | "type": "uint256"
47 | }
48 | ],
49 | "name": "setCompleted",
50 | "outputs": [],
51 | "payable": false,
52 | "stateMutability": "nonpayable",
53 | "type": "function"
54 | },
55 | {
56 | "constant": false,
57 | "inputs": [
58 | {
59 | "internalType": "address",
60 | "name": "new_address",
61 | "type": "address"
62 | }
63 | ],
64 | "name": "upgrade",
65 | "outputs": [],
66 | "payable": false,
67 | "stateMutability": "nonpayable",
68 | "type": "function"
69 | }
70 | ],
71 | "metadata": "{\"compiler\":{\"version\":\"0.5.16+commit.9c3226ce\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"constant\":true,\"inputs\":[],\"name\":\"last_completed_migration\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"completed\",\"type\":\"uint256\"}],\"name\":\"setCompleted\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"new_address\",\"type\":\"address\"}],\"name\":\"upgrade\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"methods\":{}},\"userdoc\":{\"methods\":{}}},\"settings\":{\"compilationTarget\":{\"project:/src/contracts/Migrations.sol\":\"Migrations\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"optimizer\":{\"enabled\":false,\"runs\":200},\"remappings\":[]},\"sources\":{\"project:/src/contracts/Migrations.sol\":{\"keccak256\":\"0xfdb731592344e2a2890faf03baec7b4bee7057ffba18ba6dbb6eec8db85f8f4c\",\"urls\":[\"bzz-raw://f9b488bbb84816dd04c1b155e943319758db16ee943943648fb264bccecc9879\",\"dweb:/ipfs/QmbW34mYrj3uLteyHf3S46pnp9bnwovtCXHbdBHfzMkSZx\"]}},\"version\":1}",
72 | "bytecode": "0x608060405234801561001057600080fd5b50336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506102b7806100606000396000f3fe608060405234801561001057600080fd5b506004361061004c5760003560e01c80630900f01014610051578063445df0ac146100955780638da5cb5b146100b3578063fdacd576146100fd575b600080fd5b6100936004803603602081101561006757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061012b565b005b61009d6101f7565b6040518082815260200191505060405180910390f35b6100bb6101fd565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6101296004803603602081101561011357600080fd5b8101908080359060200190929190505050610222565b005b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156101f45760008190508073ffffffffffffffffffffffffffffffffffffffff1663fdacd5766001546040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b1580156101da57600080fd5b505af11580156101ee573d6000803e3d6000fd5b50505050505b50565b60015481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561027f57806001819055505b5056fea265627a7a723158203b272c850cd9bf772823c6a54bad93d16007cae7e9f5c4528652852676941d8964736f6c63430005100032",
73 | "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061004c5760003560e01c80630900f01014610051578063445df0ac146100955780638da5cb5b146100b3578063fdacd576146100fd575b600080fd5b6100936004803603602081101561006757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061012b565b005b61009d6101f7565b6040518082815260200191505060405180910390f35b6100bb6101fd565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6101296004803603602081101561011357600080fd5b8101908080359060200190929190505050610222565b005b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156101f45760008190508073ffffffffffffffffffffffffffffffffffffffff1663fdacd5766001546040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b1580156101da57600080fd5b505af11580156101ee573d6000803e3d6000fd5b50505050505b50565b60015481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561027f57806001819055505b5056fea265627a7a723158203b272c850cd9bf772823c6a54bad93d16007cae7e9f5c4528652852676941d8964736f6c63430005100032",
74 | "sourceMap": "34:480:1:-;;;123:50;8:9:-1;5:2;;;30:1;27;20:12;5:2;123:50:1;158:10;150:5;;:18;;;;;;;;;;;;;;;;;;34:480;;;;;;",
75 | "deployedSourceMap": "34:480:1:-;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;34:480:1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;347:165;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;347:165:1;;;;;;;;;;;;;;;;;;;:::i;:::-;;82:36;;;:::i;:::-;;;;;;;;;;;;;;;;;;;58:20;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;240:103;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;240:103:1;;;;;;;;;;;;;;;;;:::i;:::-;;347:165;223:5;;;;;;;;;;;209:19;;:10;:19;;;205:26;;;409:19;442:11;409:45;;460:8;:21;;;482:24;;460:47;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;460:47:1;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;460:47:1;;;;230:1;205:26;347:165;:::o;82:36::-;;;;:::o;58:20::-;;;;;;;;;;;;;:::o;240:103::-;223:5;;;;;;;;;;;209:19;;:10;:19;;;205:26;;;329:9;302:24;:36;;;;205:26;240:103;:::o",
76 | "source": "pragma solidity >=0.4.21 <0.6.0;\n\ncontract Migrations {\n address public owner;\n uint public last_completed_migration;\n\n constructor() public {\n owner = msg.sender;\n }\n\n modifier restricted() {\n if (msg.sender == owner) _;\n }\n\n function setCompleted(uint completed) public restricted {\n last_completed_migration = completed;\n }\n\n function upgrade(address new_address) public restricted {\n Migrations upgraded = Migrations(new_address);\n upgraded.setCompleted(last_completed_migration);\n }\n}\n",
77 | "sourcePath": "/Users/melihcelik/Desktop/dropbox-blockchain/src/contracts/Migrations.sol",
78 | "ast": {
79 | "absolutePath": "project:/src/contracts/Migrations.sol",
80 | "exportedSymbols": {
81 | "Migrations": [
82 | 66
83 | ]
84 | },
85 | "id": 67,
86 | "nodeType": "SourceUnit",
87 | "nodes": [
88 | {
89 | "id": 11,
90 | "literals": [
91 | "solidity",
92 | ">=",
93 | "0.4",
94 | ".21",
95 | "<",
96 | "0.6",
97 | ".0"
98 | ],
99 | "nodeType": "PragmaDirective",
100 | "src": "0:32:1"
101 | },
102 | {
103 | "baseContracts": [],
104 | "contractDependencies": [],
105 | "contractKind": "contract",
106 | "documentation": null,
107 | "fullyImplemented": true,
108 | "id": 66,
109 | "linearizedBaseContracts": [
110 | 66
111 | ],
112 | "name": "Migrations",
113 | "nodeType": "ContractDefinition",
114 | "nodes": [
115 | {
116 | "constant": false,
117 | "id": 13,
118 | "name": "owner",
119 | "nodeType": "VariableDeclaration",
120 | "scope": 66,
121 | "src": "58:20:1",
122 | "stateVariable": true,
123 | "storageLocation": "default",
124 | "typeDescriptions": {
125 | "typeIdentifier": "t_address",
126 | "typeString": "address"
127 | },
128 | "typeName": {
129 | "id": 12,
130 | "name": "address",
131 | "nodeType": "ElementaryTypeName",
132 | "src": "58:7:1",
133 | "stateMutability": "nonpayable",
134 | "typeDescriptions": {
135 | "typeIdentifier": "t_address",
136 | "typeString": "address"
137 | }
138 | },
139 | "value": null,
140 | "visibility": "public"
141 | },
142 | {
143 | "constant": false,
144 | "id": 15,
145 | "name": "last_completed_migration",
146 | "nodeType": "VariableDeclaration",
147 | "scope": 66,
148 | "src": "82:36:1",
149 | "stateVariable": true,
150 | "storageLocation": "default",
151 | "typeDescriptions": {
152 | "typeIdentifier": "t_uint256",
153 | "typeString": "uint256"
154 | },
155 | "typeName": {
156 | "id": 14,
157 | "name": "uint",
158 | "nodeType": "ElementaryTypeName",
159 | "src": "82:4:1",
160 | "typeDescriptions": {
161 | "typeIdentifier": "t_uint256",
162 | "typeString": "uint256"
163 | }
164 | },
165 | "value": null,
166 | "visibility": "public"
167 | },
168 | {
169 | "body": {
170 | "id": 23,
171 | "nodeType": "Block",
172 | "src": "144:29:1",
173 | "statements": [
174 | {
175 | "expression": {
176 | "argumentTypes": null,
177 | "id": 21,
178 | "isConstant": false,
179 | "isLValue": false,
180 | "isPure": false,
181 | "lValueRequested": false,
182 | "leftHandSide": {
183 | "argumentTypes": null,
184 | "id": 18,
185 | "name": "owner",
186 | "nodeType": "Identifier",
187 | "overloadedDeclarations": [],
188 | "referencedDeclaration": 13,
189 | "src": "150:5:1",
190 | "typeDescriptions": {
191 | "typeIdentifier": "t_address",
192 | "typeString": "address"
193 | }
194 | },
195 | "nodeType": "Assignment",
196 | "operator": "=",
197 | "rightHandSide": {
198 | "argumentTypes": null,
199 | "expression": {
200 | "argumentTypes": null,
201 | "id": 19,
202 | "name": "msg",
203 | "nodeType": "Identifier",
204 | "overloadedDeclarations": [],
205 | "referencedDeclaration": 81,
206 | "src": "158:3:1",
207 | "typeDescriptions": {
208 | "typeIdentifier": "t_magic_message",
209 | "typeString": "msg"
210 | }
211 | },
212 | "id": 20,
213 | "isConstant": false,
214 | "isLValue": false,
215 | "isPure": false,
216 | "lValueRequested": false,
217 | "memberName": "sender",
218 | "nodeType": "MemberAccess",
219 | "referencedDeclaration": null,
220 | "src": "158:10:1",
221 | "typeDescriptions": {
222 | "typeIdentifier": "t_address_payable",
223 | "typeString": "address payable"
224 | }
225 | },
226 | "src": "150:18:1",
227 | "typeDescriptions": {
228 | "typeIdentifier": "t_address",
229 | "typeString": "address"
230 | }
231 | },
232 | "id": 22,
233 | "nodeType": "ExpressionStatement",
234 | "src": "150:18:1"
235 | }
236 | ]
237 | },
238 | "documentation": null,
239 | "id": 24,
240 | "implemented": true,
241 | "kind": "constructor",
242 | "modifiers": [],
243 | "name": "",
244 | "nodeType": "FunctionDefinition",
245 | "parameters": {
246 | "id": 16,
247 | "nodeType": "ParameterList",
248 | "parameters": [],
249 | "src": "134:2:1"
250 | },
251 | "returnParameters": {
252 | "id": 17,
253 | "nodeType": "ParameterList",
254 | "parameters": [],
255 | "src": "144:0:1"
256 | },
257 | "scope": 66,
258 | "src": "123:50:1",
259 | "stateMutability": "nonpayable",
260 | "superFunction": null,
261 | "visibility": "public"
262 | },
263 | {
264 | "body": {
265 | "id": 32,
266 | "nodeType": "Block",
267 | "src": "199:37:1",
268 | "statements": [
269 | {
270 | "condition": {
271 | "argumentTypes": null,
272 | "commonType": {
273 | "typeIdentifier": "t_address",
274 | "typeString": "address"
275 | },
276 | "id": 29,
277 | "isConstant": false,
278 | "isLValue": false,
279 | "isPure": false,
280 | "lValueRequested": false,
281 | "leftExpression": {
282 | "argumentTypes": null,
283 | "expression": {
284 | "argumentTypes": null,
285 | "id": 26,
286 | "name": "msg",
287 | "nodeType": "Identifier",
288 | "overloadedDeclarations": [],
289 | "referencedDeclaration": 81,
290 | "src": "209:3:1",
291 | "typeDescriptions": {
292 | "typeIdentifier": "t_magic_message",
293 | "typeString": "msg"
294 | }
295 | },
296 | "id": 27,
297 | "isConstant": false,
298 | "isLValue": false,
299 | "isPure": false,
300 | "lValueRequested": false,
301 | "memberName": "sender",
302 | "nodeType": "MemberAccess",
303 | "referencedDeclaration": null,
304 | "src": "209:10:1",
305 | "typeDescriptions": {
306 | "typeIdentifier": "t_address_payable",
307 | "typeString": "address payable"
308 | }
309 | },
310 | "nodeType": "BinaryOperation",
311 | "operator": "==",
312 | "rightExpression": {
313 | "argumentTypes": null,
314 | "id": 28,
315 | "name": "owner",
316 | "nodeType": "Identifier",
317 | "overloadedDeclarations": [],
318 | "referencedDeclaration": 13,
319 | "src": "223:5:1",
320 | "typeDescriptions": {
321 | "typeIdentifier": "t_address",
322 | "typeString": "address"
323 | }
324 | },
325 | "src": "209:19:1",
326 | "typeDescriptions": {
327 | "typeIdentifier": "t_bool",
328 | "typeString": "bool"
329 | }
330 | },
331 | "falseBody": null,
332 | "id": 31,
333 | "nodeType": "IfStatement",
334 | "src": "205:26:1",
335 | "trueBody": {
336 | "id": 30,
337 | "nodeType": "PlaceholderStatement",
338 | "src": "230:1:1"
339 | }
340 | }
341 | ]
342 | },
343 | "documentation": null,
344 | "id": 33,
345 | "name": "restricted",
346 | "nodeType": "ModifierDefinition",
347 | "parameters": {
348 | "id": 25,
349 | "nodeType": "ParameterList",
350 | "parameters": [],
351 | "src": "196:2:1"
352 | },
353 | "src": "177:59:1",
354 | "visibility": "internal"
355 | },
356 | {
357 | "body": {
358 | "id": 44,
359 | "nodeType": "Block",
360 | "src": "296:47:1",
361 | "statements": [
362 | {
363 | "expression": {
364 | "argumentTypes": null,
365 | "id": 42,
366 | "isConstant": false,
367 | "isLValue": false,
368 | "isPure": false,
369 | "lValueRequested": false,
370 | "leftHandSide": {
371 | "argumentTypes": null,
372 | "id": 40,
373 | "name": "last_completed_migration",
374 | "nodeType": "Identifier",
375 | "overloadedDeclarations": [],
376 | "referencedDeclaration": 15,
377 | "src": "302:24:1",
378 | "typeDescriptions": {
379 | "typeIdentifier": "t_uint256",
380 | "typeString": "uint256"
381 | }
382 | },
383 | "nodeType": "Assignment",
384 | "operator": "=",
385 | "rightHandSide": {
386 | "argumentTypes": null,
387 | "id": 41,
388 | "name": "completed",
389 | "nodeType": "Identifier",
390 | "overloadedDeclarations": [],
391 | "referencedDeclaration": 35,
392 | "src": "329:9:1",
393 | "typeDescriptions": {
394 | "typeIdentifier": "t_uint256",
395 | "typeString": "uint256"
396 | }
397 | },
398 | "src": "302:36:1",
399 | "typeDescriptions": {
400 | "typeIdentifier": "t_uint256",
401 | "typeString": "uint256"
402 | }
403 | },
404 | "id": 43,
405 | "nodeType": "ExpressionStatement",
406 | "src": "302:36:1"
407 | }
408 | ]
409 | },
410 | "documentation": null,
411 | "id": 45,
412 | "implemented": true,
413 | "kind": "function",
414 | "modifiers": [
415 | {
416 | "arguments": null,
417 | "id": 38,
418 | "modifierName": {
419 | "argumentTypes": null,
420 | "id": 37,
421 | "name": "restricted",
422 | "nodeType": "Identifier",
423 | "overloadedDeclarations": [],
424 | "referencedDeclaration": 33,
425 | "src": "285:10:1",
426 | "typeDescriptions": {
427 | "typeIdentifier": "t_modifier$__$",
428 | "typeString": "modifier ()"
429 | }
430 | },
431 | "nodeType": "ModifierInvocation",
432 | "src": "285:10:1"
433 | }
434 | ],
435 | "name": "setCompleted",
436 | "nodeType": "FunctionDefinition",
437 | "parameters": {
438 | "id": 36,
439 | "nodeType": "ParameterList",
440 | "parameters": [
441 | {
442 | "constant": false,
443 | "id": 35,
444 | "name": "completed",
445 | "nodeType": "VariableDeclaration",
446 | "scope": 45,
447 | "src": "262:14:1",
448 | "stateVariable": false,
449 | "storageLocation": "default",
450 | "typeDescriptions": {
451 | "typeIdentifier": "t_uint256",
452 | "typeString": "uint256"
453 | },
454 | "typeName": {
455 | "id": 34,
456 | "name": "uint",
457 | "nodeType": "ElementaryTypeName",
458 | "src": "262:4:1",
459 | "typeDescriptions": {
460 | "typeIdentifier": "t_uint256",
461 | "typeString": "uint256"
462 | }
463 | },
464 | "value": null,
465 | "visibility": "internal"
466 | }
467 | ],
468 | "src": "261:16:1"
469 | },
470 | "returnParameters": {
471 | "id": 39,
472 | "nodeType": "ParameterList",
473 | "parameters": [],
474 | "src": "296:0:1"
475 | },
476 | "scope": 66,
477 | "src": "240:103:1",
478 | "stateMutability": "nonpayable",
479 | "superFunction": null,
480 | "visibility": "public"
481 | },
482 | {
483 | "body": {
484 | "id": 64,
485 | "nodeType": "Block",
486 | "src": "403:109:1",
487 | "statements": [
488 | {
489 | "assignments": [
490 | 53
491 | ],
492 | "declarations": [
493 | {
494 | "constant": false,
495 | "id": 53,
496 | "name": "upgraded",
497 | "nodeType": "VariableDeclaration",
498 | "scope": 64,
499 | "src": "409:19:1",
500 | "stateVariable": false,
501 | "storageLocation": "default",
502 | "typeDescriptions": {
503 | "typeIdentifier": "t_contract$_Migrations_$66",
504 | "typeString": "contract Migrations"
505 | },
506 | "typeName": {
507 | "contractScope": null,
508 | "id": 52,
509 | "name": "Migrations",
510 | "nodeType": "UserDefinedTypeName",
511 | "referencedDeclaration": 66,
512 | "src": "409:10:1",
513 | "typeDescriptions": {
514 | "typeIdentifier": "t_contract$_Migrations_$66",
515 | "typeString": "contract Migrations"
516 | }
517 | },
518 | "value": null,
519 | "visibility": "internal"
520 | }
521 | ],
522 | "id": 57,
523 | "initialValue": {
524 | "argumentTypes": null,
525 | "arguments": [
526 | {
527 | "argumentTypes": null,
528 | "id": 55,
529 | "name": "new_address",
530 | "nodeType": "Identifier",
531 | "overloadedDeclarations": [],
532 | "referencedDeclaration": 47,
533 | "src": "442:11:1",
534 | "typeDescriptions": {
535 | "typeIdentifier": "t_address",
536 | "typeString": "address"
537 | }
538 | }
539 | ],
540 | "expression": {
541 | "argumentTypes": [
542 | {
543 | "typeIdentifier": "t_address",
544 | "typeString": "address"
545 | }
546 | ],
547 | "id": 54,
548 | "name": "Migrations",
549 | "nodeType": "Identifier",
550 | "overloadedDeclarations": [],
551 | "referencedDeclaration": 66,
552 | "src": "431:10:1",
553 | "typeDescriptions": {
554 | "typeIdentifier": "t_type$_t_contract$_Migrations_$66_$",
555 | "typeString": "type(contract Migrations)"
556 | }
557 | },
558 | "id": 56,
559 | "isConstant": false,
560 | "isLValue": false,
561 | "isPure": false,
562 | "kind": "typeConversion",
563 | "lValueRequested": false,
564 | "names": [],
565 | "nodeType": "FunctionCall",
566 | "src": "431:23:1",
567 | "typeDescriptions": {
568 | "typeIdentifier": "t_contract$_Migrations_$66",
569 | "typeString": "contract Migrations"
570 | }
571 | },
572 | "nodeType": "VariableDeclarationStatement",
573 | "src": "409:45:1"
574 | },
575 | {
576 | "expression": {
577 | "argumentTypes": null,
578 | "arguments": [
579 | {
580 | "argumentTypes": null,
581 | "id": 61,
582 | "name": "last_completed_migration",
583 | "nodeType": "Identifier",
584 | "overloadedDeclarations": [],
585 | "referencedDeclaration": 15,
586 | "src": "482:24:1",
587 | "typeDescriptions": {
588 | "typeIdentifier": "t_uint256",
589 | "typeString": "uint256"
590 | }
591 | }
592 | ],
593 | "expression": {
594 | "argumentTypes": [
595 | {
596 | "typeIdentifier": "t_uint256",
597 | "typeString": "uint256"
598 | }
599 | ],
600 | "expression": {
601 | "argumentTypes": null,
602 | "id": 58,
603 | "name": "upgraded",
604 | "nodeType": "Identifier",
605 | "overloadedDeclarations": [],
606 | "referencedDeclaration": 53,
607 | "src": "460:8:1",
608 | "typeDescriptions": {
609 | "typeIdentifier": "t_contract$_Migrations_$66",
610 | "typeString": "contract Migrations"
611 | }
612 | },
613 | "id": 60,
614 | "isConstant": false,
615 | "isLValue": false,
616 | "isPure": false,
617 | "lValueRequested": false,
618 | "memberName": "setCompleted",
619 | "nodeType": "MemberAccess",
620 | "referencedDeclaration": 45,
621 | "src": "460:21:1",
622 | "typeDescriptions": {
623 | "typeIdentifier": "t_function_external_nonpayable$_t_uint256_$returns$__$",
624 | "typeString": "function (uint256) external"
625 | }
626 | },
627 | "id": 62,
628 | "isConstant": false,
629 | "isLValue": false,
630 | "isPure": false,
631 | "kind": "functionCall",
632 | "lValueRequested": false,
633 | "names": [],
634 | "nodeType": "FunctionCall",
635 | "src": "460:47:1",
636 | "typeDescriptions": {
637 | "typeIdentifier": "t_tuple$__$",
638 | "typeString": "tuple()"
639 | }
640 | },
641 | "id": 63,
642 | "nodeType": "ExpressionStatement",
643 | "src": "460:47:1"
644 | }
645 | ]
646 | },
647 | "documentation": null,
648 | "id": 65,
649 | "implemented": true,
650 | "kind": "function",
651 | "modifiers": [
652 | {
653 | "arguments": null,
654 | "id": 50,
655 | "modifierName": {
656 | "argumentTypes": null,
657 | "id": 49,
658 | "name": "restricted",
659 | "nodeType": "Identifier",
660 | "overloadedDeclarations": [],
661 | "referencedDeclaration": 33,
662 | "src": "392:10:1",
663 | "typeDescriptions": {
664 | "typeIdentifier": "t_modifier$__$",
665 | "typeString": "modifier ()"
666 | }
667 | },
668 | "nodeType": "ModifierInvocation",
669 | "src": "392:10:1"
670 | }
671 | ],
672 | "name": "upgrade",
673 | "nodeType": "FunctionDefinition",
674 | "parameters": {
675 | "id": 48,
676 | "nodeType": "ParameterList",
677 | "parameters": [
678 | {
679 | "constant": false,
680 | "id": 47,
681 | "name": "new_address",
682 | "nodeType": "VariableDeclaration",
683 | "scope": 65,
684 | "src": "364:19:1",
685 | "stateVariable": false,
686 | "storageLocation": "default",
687 | "typeDescriptions": {
688 | "typeIdentifier": "t_address",
689 | "typeString": "address"
690 | },
691 | "typeName": {
692 | "id": 46,
693 | "name": "address",
694 | "nodeType": "ElementaryTypeName",
695 | "src": "364:7:1",
696 | "stateMutability": "nonpayable",
697 | "typeDescriptions": {
698 | "typeIdentifier": "t_address",
699 | "typeString": "address"
700 | }
701 | },
702 | "value": null,
703 | "visibility": "internal"
704 | }
705 | ],
706 | "src": "363:21:1"
707 | },
708 | "returnParameters": {
709 | "id": 51,
710 | "nodeType": "ParameterList",
711 | "parameters": [],
712 | "src": "403:0:1"
713 | },
714 | "scope": 66,
715 | "src": "347:165:1",
716 | "stateMutability": "nonpayable",
717 | "superFunction": null,
718 | "visibility": "public"
719 | }
720 | ],
721 | "scope": 67,
722 | "src": "34:480:1"
723 | }
724 | ],
725 | "src": "0:515:1"
726 | },
727 | "legacyAST": {
728 | "attributes": {
729 | "absolutePath": "project:/src/contracts/Migrations.sol",
730 | "exportedSymbols": {
731 | "Migrations": [
732 | 66
733 | ]
734 | }
735 | },
736 | "children": [
737 | {
738 | "attributes": {
739 | "literals": [
740 | "solidity",
741 | ">=",
742 | "0.4",
743 | ".21",
744 | "<",
745 | "0.6",
746 | ".0"
747 | ]
748 | },
749 | "id": 11,
750 | "name": "PragmaDirective",
751 | "src": "0:32:1"
752 | },
753 | {
754 | "attributes": {
755 | "baseContracts": [
756 | null
757 | ],
758 | "contractDependencies": [
759 | null
760 | ],
761 | "contractKind": "contract",
762 | "documentation": null,
763 | "fullyImplemented": true,
764 | "linearizedBaseContracts": [
765 | 66
766 | ],
767 | "name": "Migrations",
768 | "scope": 67
769 | },
770 | "children": [
771 | {
772 | "attributes": {
773 | "constant": false,
774 | "name": "owner",
775 | "scope": 66,
776 | "stateVariable": true,
777 | "storageLocation": "default",
778 | "type": "address",
779 | "value": null,
780 | "visibility": "public"
781 | },
782 | "children": [
783 | {
784 | "attributes": {
785 | "name": "address",
786 | "stateMutability": "nonpayable",
787 | "type": "address"
788 | },
789 | "id": 12,
790 | "name": "ElementaryTypeName",
791 | "src": "58:7:1"
792 | }
793 | ],
794 | "id": 13,
795 | "name": "VariableDeclaration",
796 | "src": "58:20:1"
797 | },
798 | {
799 | "attributes": {
800 | "constant": false,
801 | "name": "last_completed_migration",
802 | "scope": 66,
803 | "stateVariable": true,
804 | "storageLocation": "default",
805 | "type": "uint256",
806 | "value": null,
807 | "visibility": "public"
808 | },
809 | "children": [
810 | {
811 | "attributes": {
812 | "name": "uint",
813 | "type": "uint256"
814 | },
815 | "id": 14,
816 | "name": "ElementaryTypeName",
817 | "src": "82:4:1"
818 | }
819 | ],
820 | "id": 15,
821 | "name": "VariableDeclaration",
822 | "src": "82:36:1"
823 | },
824 | {
825 | "attributes": {
826 | "documentation": null,
827 | "implemented": true,
828 | "isConstructor": true,
829 | "kind": "constructor",
830 | "modifiers": [
831 | null
832 | ],
833 | "name": "",
834 | "scope": 66,
835 | "stateMutability": "nonpayable",
836 | "superFunction": null,
837 | "visibility": "public"
838 | },
839 | "children": [
840 | {
841 | "attributes": {
842 | "parameters": [
843 | null
844 | ]
845 | },
846 | "children": [],
847 | "id": 16,
848 | "name": "ParameterList",
849 | "src": "134:2:1"
850 | },
851 | {
852 | "attributes": {
853 | "parameters": [
854 | null
855 | ]
856 | },
857 | "children": [],
858 | "id": 17,
859 | "name": "ParameterList",
860 | "src": "144:0:1"
861 | },
862 | {
863 | "children": [
864 | {
865 | "children": [
866 | {
867 | "attributes": {
868 | "argumentTypes": null,
869 | "isConstant": false,
870 | "isLValue": false,
871 | "isPure": false,
872 | "lValueRequested": false,
873 | "operator": "=",
874 | "type": "address"
875 | },
876 | "children": [
877 | {
878 | "attributes": {
879 | "argumentTypes": null,
880 | "overloadedDeclarations": [
881 | null
882 | ],
883 | "referencedDeclaration": 13,
884 | "type": "address",
885 | "value": "owner"
886 | },
887 | "id": 18,
888 | "name": "Identifier",
889 | "src": "150:5:1"
890 | },
891 | {
892 | "attributes": {
893 | "argumentTypes": null,
894 | "isConstant": false,
895 | "isLValue": false,
896 | "isPure": false,
897 | "lValueRequested": false,
898 | "member_name": "sender",
899 | "referencedDeclaration": null,
900 | "type": "address payable"
901 | },
902 | "children": [
903 | {
904 | "attributes": {
905 | "argumentTypes": null,
906 | "overloadedDeclarations": [
907 | null
908 | ],
909 | "referencedDeclaration": 81,
910 | "type": "msg",
911 | "value": "msg"
912 | },
913 | "id": 19,
914 | "name": "Identifier",
915 | "src": "158:3:1"
916 | }
917 | ],
918 | "id": 20,
919 | "name": "MemberAccess",
920 | "src": "158:10:1"
921 | }
922 | ],
923 | "id": 21,
924 | "name": "Assignment",
925 | "src": "150:18:1"
926 | }
927 | ],
928 | "id": 22,
929 | "name": "ExpressionStatement",
930 | "src": "150:18:1"
931 | }
932 | ],
933 | "id": 23,
934 | "name": "Block",
935 | "src": "144:29:1"
936 | }
937 | ],
938 | "id": 24,
939 | "name": "FunctionDefinition",
940 | "src": "123:50:1"
941 | },
942 | {
943 | "attributes": {
944 | "documentation": null,
945 | "name": "restricted",
946 | "visibility": "internal"
947 | },
948 | "children": [
949 | {
950 | "attributes": {
951 | "parameters": [
952 | null
953 | ]
954 | },
955 | "children": [],
956 | "id": 25,
957 | "name": "ParameterList",
958 | "src": "196:2:1"
959 | },
960 | {
961 | "children": [
962 | {
963 | "attributes": {
964 | "falseBody": null
965 | },
966 | "children": [
967 | {
968 | "attributes": {
969 | "argumentTypes": null,
970 | "commonType": {
971 | "typeIdentifier": "t_address",
972 | "typeString": "address"
973 | },
974 | "isConstant": false,
975 | "isLValue": false,
976 | "isPure": false,
977 | "lValueRequested": false,
978 | "operator": "==",
979 | "type": "bool"
980 | },
981 | "children": [
982 | {
983 | "attributes": {
984 | "argumentTypes": null,
985 | "isConstant": false,
986 | "isLValue": false,
987 | "isPure": false,
988 | "lValueRequested": false,
989 | "member_name": "sender",
990 | "referencedDeclaration": null,
991 | "type": "address payable"
992 | },
993 | "children": [
994 | {
995 | "attributes": {
996 | "argumentTypes": null,
997 | "overloadedDeclarations": [
998 | null
999 | ],
1000 | "referencedDeclaration": 81,
1001 | "type": "msg",
1002 | "value": "msg"
1003 | },
1004 | "id": 26,
1005 | "name": "Identifier",
1006 | "src": "209:3:1"
1007 | }
1008 | ],
1009 | "id": 27,
1010 | "name": "MemberAccess",
1011 | "src": "209:10:1"
1012 | },
1013 | {
1014 | "attributes": {
1015 | "argumentTypes": null,
1016 | "overloadedDeclarations": [
1017 | null
1018 | ],
1019 | "referencedDeclaration": 13,
1020 | "type": "address",
1021 | "value": "owner"
1022 | },
1023 | "id": 28,
1024 | "name": "Identifier",
1025 | "src": "223:5:1"
1026 | }
1027 | ],
1028 | "id": 29,
1029 | "name": "BinaryOperation",
1030 | "src": "209:19:1"
1031 | },
1032 | {
1033 | "id": 30,
1034 | "name": "PlaceholderStatement",
1035 | "src": "230:1:1"
1036 | }
1037 | ],
1038 | "id": 31,
1039 | "name": "IfStatement",
1040 | "src": "205:26:1"
1041 | }
1042 | ],
1043 | "id": 32,
1044 | "name": "Block",
1045 | "src": "199:37:1"
1046 | }
1047 | ],
1048 | "id": 33,
1049 | "name": "ModifierDefinition",
1050 | "src": "177:59:1"
1051 | },
1052 | {
1053 | "attributes": {
1054 | "documentation": null,
1055 | "implemented": true,
1056 | "isConstructor": false,
1057 | "kind": "function",
1058 | "name": "setCompleted",
1059 | "scope": 66,
1060 | "stateMutability": "nonpayable",
1061 | "superFunction": null,
1062 | "visibility": "public"
1063 | },
1064 | "children": [
1065 | {
1066 | "children": [
1067 | {
1068 | "attributes": {
1069 | "constant": false,
1070 | "name": "completed",
1071 | "scope": 45,
1072 | "stateVariable": false,
1073 | "storageLocation": "default",
1074 | "type": "uint256",
1075 | "value": null,
1076 | "visibility": "internal"
1077 | },
1078 | "children": [
1079 | {
1080 | "attributes": {
1081 | "name": "uint",
1082 | "type": "uint256"
1083 | },
1084 | "id": 34,
1085 | "name": "ElementaryTypeName",
1086 | "src": "262:4:1"
1087 | }
1088 | ],
1089 | "id": 35,
1090 | "name": "VariableDeclaration",
1091 | "src": "262:14:1"
1092 | }
1093 | ],
1094 | "id": 36,
1095 | "name": "ParameterList",
1096 | "src": "261:16:1"
1097 | },
1098 | {
1099 | "attributes": {
1100 | "parameters": [
1101 | null
1102 | ]
1103 | },
1104 | "children": [],
1105 | "id": 39,
1106 | "name": "ParameterList",
1107 | "src": "296:0:1"
1108 | },
1109 | {
1110 | "attributes": {
1111 | "arguments": null
1112 | },
1113 | "children": [
1114 | {
1115 | "attributes": {
1116 | "argumentTypes": null,
1117 | "overloadedDeclarations": [
1118 | null
1119 | ],
1120 | "referencedDeclaration": 33,
1121 | "type": "modifier ()",
1122 | "value": "restricted"
1123 | },
1124 | "id": 37,
1125 | "name": "Identifier",
1126 | "src": "285:10:1"
1127 | }
1128 | ],
1129 | "id": 38,
1130 | "name": "ModifierInvocation",
1131 | "src": "285:10:1"
1132 | },
1133 | {
1134 | "children": [
1135 | {
1136 | "children": [
1137 | {
1138 | "attributes": {
1139 | "argumentTypes": null,
1140 | "isConstant": false,
1141 | "isLValue": false,
1142 | "isPure": false,
1143 | "lValueRequested": false,
1144 | "operator": "=",
1145 | "type": "uint256"
1146 | },
1147 | "children": [
1148 | {
1149 | "attributes": {
1150 | "argumentTypes": null,
1151 | "overloadedDeclarations": [
1152 | null
1153 | ],
1154 | "referencedDeclaration": 15,
1155 | "type": "uint256",
1156 | "value": "last_completed_migration"
1157 | },
1158 | "id": 40,
1159 | "name": "Identifier",
1160 | "src": "302:24:1"
1161 | },
1162 | {
1163 | "attributes": {
1164 | "argumentTypes": null,
1165 | "overloadedDeclarations": [
1166 | null
1167 | ],
1168 | "referencedDeclaration": 35,
1169 | "type": "uint256",
1170 | "value": "completed"
1171 | },
1172 | "id": 41,
1173 | "name": "Identifier",
1174 | "src": "329:9:1"
1175 | }
1176 | ],
1177 | "id": 42,
1178 | "name": "Assignment",
1179 | "src": "302:36:1"
1180 | }
1181 | ],
1182 | "id": 43,
1183 | "name": "ExpressionStatement",
1184 | "src": "302:36:1"
1185 | }
1186 | ],
1187 | "id": 44,
1188 | "name": "Block",
1189 | "src": "296:47:1"
1190 | }
1191 | ],
1192 | "id": 45,
1193 | "name": "FunctionDefinition",
1194 | "src": "240:103:1"
1195 | },
1196 | {
1197 | "attributes": {
1198 | "documentation": null,
1199 | "implemented": true,
1200 | "isConstructor": false,
1201 | "kind": "function",
1202 | "name": "upgrade",
1203 | "scope": 66,
1204 | "stateMutability": "nonpayable",
1205 | "superFunction": null,
1206 | "visibility": "public"
1207 | },
1208 | "children": [
1209 | {
1210 | "children": [
1211 | {
1212 | "attributes": {
1213 | "constant": false,
1214 | "name": "new_address",
1215 | "scope": 65,
1216 | "stateVariable": false,
1217 | "storageLocation": "default",
1218 | "type": "address",
1219 | "value": null,
1220 | "visibility": "internal"
1221 | },
1222 | "children": [
1223 | {
1224 | "attributes": {
1225 | "name": "address",
1226 | "stateMutability": "nonpayable",
1227 | "type": "address"
1228 | },
1229 | "id": 46,
1230 | "name": "ElementaryTypeName",
1231 | "src": "364:7:1"
1232 | }
1233 | ],
1234 | "id": 47,
1235 | "name": "VariableDeclaration",
1236 | "src": "364:19:1"
1237 | }
1238 | ],
1239 | "id": 48,
1240 | "name": "ParameterList",
1241 | "src": "363:21:1"
1242 | },
1243 | {
1244 | "attributes": {
1245 | "parameters": [
1246 | null
1247 | ]
1248 | },
1249 | "children": [],
1250 | "id": 51,
1251 | "name": "ParameterList",
1252 | "src": "403:0:1"
1253 | },
1254 | {
1255 | "attributes": {
1256 | "arguments": null
1257 | },
1258 | "children": [
1259 | {
1260 | "attributes": {
1261 | "argumentTypes": null,
1262 | "overloadedDeclarations": [
1263 | null
1264 | ],
1265 | "referencedDeclaration": 33,
1266 | "type": "modifier ()",
1267 | "value": "restricted"
1268 | },
1269 | "id": 49,
1270 | "name": "Identifier",
1271 | "src": "392:10:1"
1272 | }
1273 | ],
1274 | "id": 50,
1275 | "name": "ModifierInvocation",
1276 | "src": "392:10:1"
1277 | },
1278 | {
1279 | "children": [
1280 | {
1281 | "attributes": {
1282 | "assignments": [
1283 | 53
1284 | ]
1285 | },
1286 | "children": [
1287 | {
1288 | "attributes": {
1289 | "constant": false,
1290 | "name": "upgraded",
1291 | "scope": 64,
1292 | "stateVariable": false,
1293 | "storageLocation": "default",
1294 | "type": "contract Migrations",
1295 | "value": null,
1296 | "visibility": "internal"
1297 | },
1298 | "children": [
1299 | {
1300 | "attributes": {
1301 | "contractScope": null,
1302 | "name": "Migrations",
1303 | "referencedDeclaration": 66,
1304 | "type": "contract Migrations"
1305 | },
1306 | "id": 52,
1307 | "name": "UserDefinedTypeName",
1308 | "src": "409:10:1"
1309 | }
1310 | ],
1311 | "id": 53,
1312 | "name": "VariableDeclaration",
1313 | "src": "409:19:1"
1314 | },
1315 | {
1316 | "attributes": {
1317 | "argumentTypes": null,
1318 | "isConstant": false,
1319 | "isLValue": false,
1320 | "isPure": false,
1321 | "isStructConstructorCall": false,
1322 | "lValueRequested": false,
1323 | "names": [
1324 | null
1325 | ],
1326 | "type": "contract Migrations",
1327 | "type_conversion": true
1328 | },
1329 | "children": [
1330 | {
1331 | "attributes": {
1332 | "argumentTypes": [
1333 | {
1334 | "typeIdentifier": "t_address",
1335 | "typeString": "address"
1336 | }
1337 | ],
1338 | "overloadedDeclarations": [
1339 | null
1340 | ],
1341 | "referencedDeclaration": 66,
1342 | "type": "type(contract Migrations)",
1343 | "value": "Migrations"
1344 | },
1345 | "id": 54,
1346 | "name": "Identifier",
1347 | "src": "431:10:1"
1348 | },
1349 | {
1350 | "attributes": {
1351 | "argumentTypes": null,
1352 | "overloadedDeclarations": [
1353 | null
1354 | ],
1355 | "referencedDeclaration": 47,
1356 | "type": "address",
1357 | "value": "new_address"
1358 | },
1359 | "id": 55,
1360 | "name": "Identifier",
1361 | "src": "442:11:1"
1362 | }
1363 | ],
1364 | "id": 56,
1365 | "name": "FunctionCall",
1366 | "src": "431:23:1"
1367 | }
1368 | ],
1369 | "id": 57,
1370 | "name": "VariableDeclarationStatement",
1371 | "src": "409:45:1"
1372 | },
1373 | {
1374 | "children": [
1375 | {
1376 | "attributes": {
1377 | "argumentTypes": null,
1378 | "isConstant": false,
1379 | "isLValue": false,
1380 | "isPure": false,
1381 | "isStructConstructorCall": false,
1382 | "lValueRequested": false,
1383 | "names": [
1384 | null
1385 | ],
1386 | "type": "tuple()",
1387 | "type_conversion": false
1388 | },
1389 | "children": [
1390 | {
1391 | "attributes": {
1392 | "argumentTypes": [
1393 | {
1394 | "typeIdentifier": "t_uint256",
1395 | "typeString": "uint256"
1396 | }
1397 | ],
1398 | "isConstant": false,
1399 | "isLValue": false,
1400 | "isPure": false,
1401 | "lValueRequested": false,
1402 | "member_name": "setCompleted",
1403 | "referencedDeclaration": 45,
1404 | "type": "function (uint256) external"
1405 | },
1406 | "children": [
1407 | {
1408 | "attributes": {
1409 | "argumentTypes": null,
1410 | "overloadedDeclarations": [
1411 | null
1412 | ],
1413 | "referencedDeclaration": 53,
1414 | "type": "contract Migrations",
1415 | "value": "upgraded"
1416 | },
1417 | "id": 58,
1418 | "name": "Identifier",
1419 | "src": "460:8:1"
1420 | }
1421 | ],
1422 | "id": 60,
1423 | "name": "MemberAccess",
1424 | "src": "460:21:1"
1425 | },
1426 | {
1427 | "attributes": {
1428 | "argumentTypes": null,
1429 | "overloadedDeclarations": [
1430 | null
1431 | ],
1432 | "referencedDeclaration": 15,
1433 | "type": "uint256",
1434 | "value": "last_completed_migration"
1435 | },
1436 | "id": 61,
1437 | "name": "Identifier",
1438 | "src": "482:24:1"
1439 | }
1440 | ],
1441 | "id": 62,
1442 | "name": "FunctionCall",
1443 | "src": "460:47:1"
1444 | }
1445 | ],
1446 | "id": 63,
1447 | "name": "ExpressionStatement",
1448 | "src": "460:47:1"
1449 | }
1450 | ],
1451 | "id": 64,
1452 | "name": "Block",
1453 | "src": "403:109:1"
1454 | }
1455 | ],
1456 | "id": 65,
1457 | "name": "FunctionDefinition",
1458 | "src": "347:165:1"
1459 | }
1460 | ],
1461 | "id": 66,
1462 | "name": "ContractDefinition",
1463 | "src": "34:480:1"
1464 | }
1465 | ],
1466 | "id": 67,
1467 | "name": "SourceUnit",
1468 | "src": "0:515:1"
1469 | },
1470 | "compiler": {
1471 | "name": "solc",
1472 | "version": "0.5.16+commit.9c3226ce.Emscripten.clang"
1473 | },
1474 | "networks": {
1475 | "5777": {
1476 | "events": {},
1477 | "links": {},
1478 | "address": "0x68A0e7AdCEFF447B60D25b79BDDf06aEd67DA1DD",
1479 | "transactionHash": "0x57ce86b551deaff5ae907d7716016a660d828d1fc2b07546004831b0d0563fa9"
1480 | }
1481 | },
1482 | "schemaVersion": "3.4.4",
1483 | "updatedAt": "2022-01-16T23:09:16.239Z",
1484 | "networkType": "ethereum",
1485 | "devdoc": {
1486 | "methods": {}
1487 | },
1488 | "userdoc": {
1489 | "methods": {}
1490 | }
1491 | }
--------------------------------------------------------------------------------
/src/box.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yenilikci/dropbox-clone-blockchain-reactjs-solidity/6d2fefb439a4cbf025c50cbbbf82c5ff79bd2aac/src/box.png
--------------------------------------------------------------------------------
/src/components/App.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yenilikci/dropbox-clone-blockchain-reactjs-solidity/6d2fefb439a4cbf025c50cbbbf82c5ff79bd2aac/src/components/App.css
--------------------------------------------------------------------------------
/src/components/App.js:
--------------------------------------------------------------------------------
1 | import DStorage from '../abis/DStorage.json'
2 | import React, {Component} from 'react';
3 | import Navbar from './Navbar'
4 | import Main from './Main'
5 | import Web3 from 'web3';
6 | import './App.css';
7 |
8 | const ipfsClient = require('ipfs-http-client')
9 | const ipfs = ipfsClient({host: 'ipfs.infura.io', port: 5001, protocol: 'https'}) // leaving out the arguments will default to these values
10 |
11 | class App extends Component {
12 |
13 | async componentWillMount() {
14 | await this.loadWeb3()
15 | await this.loadBlockchainData()
16 | }
17 |
18 | async loadWeb3() {
19 | if (window.ethereum) {
20 | window.web3 = new Web3(window.ethereum)
21 | await window.ethereum.enable()
22 | } else if (window.web3) {
23 | window.web3 = new Web3(window.web3.currentProvider)
24 | } else {
25 | window.alert('Non-Ethereum browser detected. You should consider trying MetaMask!')
26 | }
27 | }
28 |
29 | async loadBlockchainData() {
30 | const web3 = window.web3
31 | // Load account
32 | const accounts = await web3.eth.getAccounts()
33 | this.setState({account: accounts[0]})
34 | // Network ID
35 | const networkId = await web3.eth.net.getId()
36 | const networkData = DStorage.networks[networkId]
37 | if (networkData) {
38 | // Assign contract
39 | const dstorage = new web3.eth.Contract(DStorage.abi, networkData.address)
40 | this.setState({dstorage})
41 | // Get files amount
42 | const filesCount = await dstorage.methods.fileCount().call()
43 | this.setState({filesCount})
44 | // Load files&sort by the newest
45 | for (var i = filesCount; i >= 1; i--) {
46 | const file = await dstorage.methods.files(i).call()
47 | this.setState({
48 | files: [...this.state.files, file]
49 | })
50 | }
51 | } else {
52 | window.alert('DStorage contract not deployed to detected network.')
53 | }
54 | }
55 |
56 | // Get file from user
57 | captureFile = event => {
58 | event.preventDefault()
59 |
60 | const file = event.target.files[0]
61 | const reader = new window.FileReader()
62 |
63 | reader.readAsArrayBuffer(file)
64 | reader.onloadend = () => {
65 | this.setState({
66 | buffer: Buffer(reader.result),
67 | type: file.type,
68 | name: file.name
69 | })
70 | console.log('buffer', this.state.buffer)
71 | }
72 | }
73 |
74 | uploadFile = description => {
75 | console.log("Submitting file to IPFS...")
76 |
77 | // Add file to the IPFS
78 | ipfs.add(this.state.buffer, (error, result) => {
79 | console.log('IPFS result', result.size)
80 | if (error) {
81 | console.error(error)
82 | return
83 | }
84 |
85 | this.setState({loading: true})
86 | // Assign value for the file without extension
87 | if (this.state.type === '') {
88 | this.setState({type: 'none'})
89 | }
90 | this.state.dstorage.methods.uploadFile(result[0].hash, result[0].size, this.state.type, this.state.name, description).send({from: this.state.account}).on('transactionHash', (hash) => {
91 | this.setState({
92 | loading: false,
93 | type: null,
94 | name: null
95 | })
96 | window.location.reload()
97 | }).on('error', (e) => {
98 | window.alert('Error')
99 | this.setState({loading: false})
100 | })
101 | })
102 | }
103 |
104 | constructor(props) {
105 | super(props)
106 | this.state = {
107 | account: '',
108 | dstorage: null,
109 | files: [],
110 | loading: false,
111 | type: null,
112 | name: null
113 | }
114 | this.uploadFile = this.uploadFile.bind(this)
115 | this.captureFile = this.captureFile.bind(this)
116 | }
117 |
118 | render() {
119 | return (
120 |
121 |
122 | {this.state.loading
123 | ?
124 | :
129 | }
130 |
131 | );
132 | }
133 | }
134 |
135 | export default App;
136 |
--------------------------------------------------------------------------------
/src/components/Main.js:
--------------------------------------------------------------------------------
1 | import React, {Component} from 'react';
2 | import {convertBytes} from './helpers';
3 | import moment from 'moment'
4 |
5 | class Main extends Component {
6 |
7 | render() {
8 | return (
9 |
10 |
11 |
12 |
13 |
14 | Share File
15 |
16 |
38 |
39 |
40 |
41 |
42 |
43 | Id |
44 | Name |
45 | Description |
46 | Type |
47 | Size |
48 | Date |
49 | Uploader/View |
50 | Hash/View/Get |
51 |
52 |
53 | {this.props.files.map((file, key) => {
54 | return (
55 |
56 |
57 | {file.fileId} |
58 | {file.fileName} |
59 | {file.fileDescription} |
60 | {file.fileType} |
61 | {convertBytes(file.fileSize)} |
62 | {moment.unix(file.uploadTime).format('h:mm:ss A M/D/Y')} |
63 |
64 |
68 | {file.uploader.substring(0, 10)}...
69 |
70 | |
71 |
72 |
76 | {file.fileHash.substring(0, 10)}...
77 |
78 | |
79 |
80 |
81 | )
82 | })}
83 |
84 |
85 |
86 |
87 |
88 | );
89 | }
90 | }
91 |
92 | export default Main;
93 |
--------------------------------------------------------------------------------
/src/components/Navbar.js:
--------------------------------------------------------------------------------
1 | import React, {Component} from 'react';
2 | import Identicon from 'identicon.js';
3 | import box from '../box.png'
4 |
5 | class Navbar extends Component {
6 |
7 | render() {
8 | return (
9 |
42 | );
43 | }
44 | }
45 |
46 | export default Navbar;
47 |
--------------------------------------------------------------------------------
/src/components/helpers.js:
--------------------------------------------------------------------------------
1 | export function convertBytes(bytes) {
2 | var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
3 | if (bytes === 0) return '0 Byte';
4 | var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)));
5 | return Math.round(bytes / Math.pow(1024, i), 2) + ' ' + sizes[i];
6 | }
--------------------------------------------------------------------------------
/src/contracts/DStorage.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | contract DStorage {
4 | string public name = 'DStorage';
5 | uint public fileCount = 0;
6 | mapping(uint => File) public files;
7 |
8 | struct File {
9 | uint fileId;
10 | string fileHash;
11 | uint fileSize;
12 | string fileType;
13 | string fileName;
14 | string fileDescription;
15 | uint uploadTime;
16 | address payable uploader;
17 | }
18 |
19 | event FileUploaded(
20 | uint fileId,
21 | string fileHash,
22 | uint fileSize,
23 | string fileType,
24 | string fileName,
25 | string fileDescription,
26 | uint uploadTime,
27 | address payable uploader
28 | );
29 |
30 | constructor() public {
31 | }
32 |
33 | function uploadFile(string memory _fileHash, uint _fileSize, string memory _fileType, string memory _fileName, string memory _fileDescription) public {
34 | // Make sure the file hash exists
35 | require(bytes(_fileHash).length > 0);
36 | // Make sure file type exists
37 | require(bytes(_fileType).length > 0);
38 | // Make sure file description exists
39 | require(bytes(_fileDescription).length > 0);
40 | // Make sure file fileName exists
41 | require(bytes(_fileName).length > 0);
42 | // Make sure uploader address exists
43 | require(msg.sender != address(0));
44 | // Make sure file size is more than 0
45 | require(_fileSize > 0);
46 |
47 | // Increment file id
48 | fileCount ++;
49 |
50 | // Add File to the contract
51 | files[fileCount] = File(fileCount, _fileHash, _fileSize, _fileType, _fileName, _fileDescription, now, msg.sender);
52 | // Trigger an event
53 | emit FileUploaded(fileCount, _fileHash, _fileSize, _fileType, _fileName, _fileDescription, now, msg.sender);
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/src/contracts/Migrations.sol:
--------------------------------------------------------------------------------
1 | pragma solidity >=0.4.21 <0.6.0;
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 |
--------------------------------------------------------------------------------
/src/index.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom';
3 | import 'bootstrap/dist/css/bootstrap.css'
4 | import App from './components/App';
5 | import * as serviceWorker from './serviceWorker';
6 |
7 | ReactDOM.render(, document.getElementById('root'));
8 |
9 | // If you want your app to work offline and load faster, you can change
10 | // unregister() to register() below. Note this comes with some pitfalls.
11 | // Learn more about service workers: https://bit.ly/CRA-PWA
12 | serviceWorker.unregister();
13 |
--------------------------------------------------------------------------------
/src/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yenilikci/dropbox-clone-blockchain-reactjs-solidity/6d2fefb439a4cbf025c50cbbbf82c5ff79bd2aac/src/logo.png
--------------------------------------------------------------------------------
/src/serviceWorker.js:
--------------------------------------------------------------------------------
1 | // This optional code is used to register a service worker.
2 | // register() is not called by default.
3 |
4 | // This lets the app load faster on subsequent visits in production, and gives
5 | // it offline capabilities. However, it also means that developers (and users)
6 | // will only see deployed updates on subsequent visits to a page, after all the
7 | // existing tabs open on the page have been closed, since previously cached
8 | // resources are updated in the background.
9 |
10 | // To learn more about the benefits of this model and instructions on how to
11 | // opt-in, read https://bit.ly/CRA-PWA
12 |
13 | const isLocalhost = Boolean(
14 | window.location.hostname === 'localhost' ||
15 | // [::1] is the IPv6 localhost address.
16 | window.location.hostname === '[::1]' ||
17 | // 127.0.0.1/8 is considered localhost for IPv4.
18 | window.location.hostname.match(
19 | /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
20 | )
21 | );
22 |
23 | export function register(config) {
24 | if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
25 | // The URL constructor is available in all browsers that support SW.
26 | const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);
27 | if (publicUrl.origin !== window.location.origin) {
28 | // Our service worker won't work if PUBLIC_URL is on a different origin
29 | // from what our page is served on. This might happen if a CDN is used to
30 | // serve assets; see https://github.com/facebook/create-react-app/issues/2374
31 | return;
32 | }
33 |
34 | window.addEventListener('load', () => {
35 | const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
36 |
37 | if (isLocalhost) {
38 | // This is running on localhost. Let's check if a service worker still exists or not.
39 | checkValidServiceWorker(swUrl, config);
40 |
41 | // Add some additional logging to localhost, pointing developers to the
42 | // service worker/PWA documentation.
43 | navigator.serviceWorker.ready.then(() => {
44 | console.log(
45 | 'This web app is being served cache-first by a service ' +
46 | 'worker. To learn more, visit https://bit.ly/CRA-PWA'
47 | );
48 | });
49 | } else {
50 | // Is not localhost. Just register service worker
51 | registerValidSW(swUrl, config);
52 | }
53 | });
54 | }
55 | }
56 |
57 | function registerValidSW(swUrl, config) {
58 | navigator.serviceWorker
59 | .register(swUrl)
60 | .then(registration => {
61 | registration.onupdatefound = () => {
62 | const installingWorker = registration.installing;
63 | if (installingWorker == null) {
64 | return;
65 | }
66 | installingWorker.onstatechange = () => {
67 | if (installingWorker.state === 'installed') {
68 | if (navigator.serviceWorker.controller) {
69 | // At this point, the updated precached content has been fetched,
70 | // but the previous service worker will still serve the older
71 | // content until all client tabs are closed.
72 | console.log(
73 | 'New content is available and will be used when all ' +
74 | 'tabs for this page are closed. See https://bit.ly/CRA-PWA.'
75 | );
76 |
77 | // Execute callback
78 | if (config && config.onUpdate) {
79 | config.onUpdate(registration);
80 | }
81 | } else {
82 | // At this point, everything has been precached.
83 | // It's the perfect time to display a
84 | // "Content is cached for offline use." message.
85 | console.log('Content is cached for offline use.');
86 |
87 | // Execute callback
88 | if (config && config.onSuccess) {
89 | config.onSuccess(registration);
90 | }
91 | }
92 | }
93 | };
94 | };
95 | })
96 | .catch(error => {
97 | console.error('Error during service worker registration:', error);
98 | });
99 | }
100 |
101 | function checkValidServiceWorker(swUrl, config) {
102 | // Check if the service worker can be found. If it can't reload the page.
103 | fetch(swUrl)
104 | .then(response => {
105 | // Ensure service worker exists, and that we really are getting a JS file.
106 | const contentType = response.headers.get('content-type');
107 | if (
108 | response.status === 404 ||
109 | (contentType != null && contentType.indexOf('javascript') === -1)
110 | ) {
111 | // No service worker found. Probably a different app. Reload the page.
112 | navigator.serviceWorker.ready.then(registration => {
113 | registration.unregister().then(() => {
114 | window.location.reload();
115 | });
116 | });
117 | } else {
118 | // Service worker found. Proceed as normal.
119 | registerValidSW(swUrl, config);
120 | }
121 | })
122 | .catch(() => {
123 | console.log(
124 | 'No internet connection found. App is running in offline mode.'
125 | );
126 | });
127 | }
128 |
129 | export function unregister() {
130 | if ('serviceWorker' in navigator) {
131 | navigator.serviceWorker.ready.then(registration => {
132 | registration.unregister();
133 | });
134 | }
135 | }
136 |
--------------------------------------------------------------------------------
/test/test.js:
--------------------------------------------------------------------------------
1 | const DStorage = artifacts.require('./DStorage.sol')
2 |
3 | require('chai')
4 | .use(require('chai-as-promised'))
5 | .should()
6 |
7 | contract('DStorage', ([deployer, uploader]) => {
8 | let dstorage
9 |
10 | before(async () => {
11 | dstorage = await DStorage.deployed()
12 | })
13 |
14 | describe('deployment', async () => {
15 | it('deploys successfully', async () => {
16 | const address = await dstorage.address
17 | assert.notEqual(address, 0x0)
18 | assert.notEqual(address, '')
19 | assert.notEqual(address, null)
20 | assert.notEqual(address, undefined)
21 | })
22 |
23 | it('has a name', async () => {
24 | const name = await dstorage.name()
25 | assert.equal(name, 'DStorage')
26 | })
27 | })
28 |
29 | describe('file', async () => {
30 | let result, fileCount
31 | const fileHash = 'QmV8cfu6n4NT5xRr2AHdKxFMTZEJrA44qgrBCr739BN9Wb'
32 | const fileSize = '1'
33 | const fileType = 'TypeOfTheFile'
34 | const fileName = 'NameOfTheFile'
35 | const fileDescription = 'DescriptionOfTheFile'
36 |
37 | before(async () => {
38 | result = await dstorage.uploadFile(fileHash, fileSize, fileType, fileName, fileDescription, {from: uploader})
39 | fileCount = await dstorage.fileCount()
40 | })
41 |
42 | //check event
43 | it('upload file', async () => {
44 | // SUCESS
45 | assert.equal(fileCount, 1)
46 | const event = result.logs[0].args
47 | assert.equal(event.fileId.toNumber(), fileCount.toNumber(), 'Id is correct')
48 | assert.equal(event.fileHash, fileHash, 'Hash is correct')
49 | assert.equal(event.fileSize, fileSize, 'Size is correct')
50 | assert.equal(event.fileType, fileType, 'Type is correct')
51 | assert.equal(event.fileName, fileName, 'Name is correct')
52 | assert.equal(event.fileDescription, fileDescription, 'Description is correct')
53 | assert.equal(event.uploader, uploader, 'Uploader is correct')
54 |
55 | // FAILURE: File must have hash
56 | await dstorage.uploadFile('', fileSize, fileType, fileName, fileDescription, {from: uploader}).should.be.rejected;
57 |
58 | // FAILURE: File must have size
59 | await dstorage.uploadFile(fileHash, '', fileType, fileName, fileDescription, {from: uploader}).should.be.rejected;
60 |
61 | // FAILURE: File must have type
62 | await dstorage.uploadFile(fileHash, fileSize, '', fileName, fileDescription, {from: uploader}).should.be.rejected;
63 |
64 | // FAILURE: File must have name
65 | await dstorage.uploadFile(fileHash, fileSize, fileType, '', fileDescription, {from: uploader}).should.be.rejected;
66 |
67 | // FAILURE: File must have description
68 | await dstorage.uploadFile(fileHash, fileSize, fileType, fileName, '', {from: uploader}).should.be.rejected;
69 | })
70 |
71 | //check from Struct
72 | it('lists file', async () => {
73 | const file = await dstorage.files(fileCount)
74 | assert.equal(file.fileId.toNumber(), fileCount.toNumber(), 'id is correct')
75 | assert.equal(file.fileHash, fileHash, 'Hash is correct')
76 | assert.equal(file.fileSize, fileSize, 'Size is correct')
77 | assert.equal(file.fileName, fileName, 'Size is correct')
78 | assert.equal(file.fileDescription, fileDescription, 'description is correct')
79 | assert.equal(file.uploader, uploader, 'uploader is correct')
80 | })
81 | })
82 | })
83 |
--------------------------------------------------------------------------------
/truffle-config.js:
--------------------------------------------------------------------------------
1 | require('babel-register');
2 | require('babel-polyfill');
3 | require('dotenv').config();
4 | // const HDWalletProvider = require('truffle-hdwallet-provider-privkey');
5 | const privateKeys = process.env.PRIVATE_KEYS || ""
6 |
7 | module.exports = {
8 | networks: {
9 | development: {
10 | host: "127.0.0.1",
11 | port: 7545,
12 | network_id: "*" // Match any network id
13 | },
14 | // ropsten: {
15 | // provider: function() {
16 | // return new HDWalletProvider(
17 | // privateKeys.split(','), // Array of account private keys
18 | // `https://ropsten.infura.io/v3/${process.env.INFURA_API_KEY}`// Url to an Ethereum Node
19 | // )
20 | // },
21 | // gas: 5000000,
22 | // gasPrice: 25000000000,
23 | // network_id: 3
24 | // }
25 | },
26 | contracts_directory: './src/contracts/',
27 | contracts_build_directory: './src/abis/',
28 | compilers: {
29 | solc: {
30 | optimizer: {
31 | enabled: true,
32 | runs: 200
33 | }
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------