@ayanworks/polygon-did-registry-contract 0.0.2 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,7 +3,8 @@
3
3
  */
4
4
 
5
5
  //SPDX-License-Identifier: MIT
6
- pragma solidity ^0.8.0;
6
+ pragma solidity ^0.8.15;
7
+ // import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
7
8
 
8
9
  /**
9
10
  *@title PolygonDidRegistry
@@ -17,9 +18,10 @@ contract PolygonDidRegistry {
17
18
  uint256 updated;
18
19
  string did_doc;
19
20
  }
21
+
20
22
  modifier onlyController(address _id) {
21
23
  require(
22
- did[_id].controller == msg.sender, "message sender is not the controller"
24
+ did[_id].controller == msg.sender, "message sender is not the controller of the DID Doc"
23
25
  );
24
26
  _;
25
27
  }
@@ -29,8 +31,11 @@ contract PolygonDidRegistry {
29
31
  event DidUpdated(address id, string doc);
30
32
  event DidDeleted(address id);
31
33
  event TransferOwnership(address newOwner);
34
+ bool private initialized;
32
35
 
33
- constructor (){
36
+ function initialize() public {
37
+ require(!initialized, "Contract instance has already been initialized");
38
+ initialized = true;
34
39
  owner = msg.sender;
35
40
  }
36
41
 
@@ -39,17 +44,28 @@ contract PolygonDidRegistry {
39
44
  _;
40
45
  }
41
46
 
42
- function transferOwnership(address newOwner)public onlyOwner() returns (string memory){
43
- if(owner != newOwner){
44
- owner = newOwner;
47
+ /**
48
+ *@dev transfer the ownership of contract
49
+ *@param _newOwner - Address of the new owner to whom the ownership needs to be passed
50
+ **/
51
+ function transferOwnership(address _newOwner)public onlyOwner() returns (string memory){
52
+ if(owner != _newOwner){
53
+ owner = _newOwner;
45
54
  emit TransferOwnership(owner);
46
- return ("Ownership transffered successfully");
55
+ return ("Ownership transferred successfully");
47
56
  }
48
57
  else {
49
58
  return ("New Owner address is equal to original owner address");
50
59
  }
51
60
  }
52
61
 
62
+ /**
63
+ *@dev Reads contract owner from chain
64
+ */
65
+ function getOwner() public view returns (address _owner){
66
+ return owner;
67
+ }
68
+
53
69
  /**
54
70
  *@dev Register a new DID
55
71
  *@param _id - Address that will refer the DID doc
@@ -98,4 +114,4 @@ contract PolygonDidRegistry {
98
114
  delete did[_id];
99
115
  emit DidDeleted(_id);
100
116
  }
101
- }
117
+ }
@@ -1,5 +1,8 @@
1
+ const { deployProxy } = require('@openzeppelin/truffle-upgrades');
2
+
1
3
  const PolygonDidRegistry = artifacts.require("PolygonDidRegistry");
2
4
 
3
- module.exports = function(deployer){
4
- deployer.deploy(PolygonDidRegistry);
5
+ module.exports = async function (deployer) {
6
+ const instance = await deployProxy(PolygonDidRegistry, { deployer });
7
+ console.log('Deployed', instance.address);
5
8
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ayanworks/polygon-did-registry-contract",
3
- "version": "0.0.2",
3
+ "version": "1.1.0",
4
4
  "description": "Smart Contract to register DID on Polygon",
5
5
  "main": "build/contracts/PolygonDidRegistry.json",
6
6
  "directories": {
@@ -13,13 +13,20 @@
13
13
  },
14
14
  "license": "MIT",
15
15
  "dependencies": {
16
- "ganache-cli": "6.8.1",
16
+ "@openzeppelin/contracts": "^4.7.0",
17
+ "@truffle/hdwallet-provider": "^2.0.10",
18
+ "fs-extra": "8.1.0",
19
+ "ganache-cli": "6.12.2",
17
20
  "mocha": "^7.0.0",
18
21
  "solc": "0.8.0",
19
- "ethers": "^4.0.41",
20
- "fs-extra": "8.1.0"
22
+ "truffle": "^5.5.20"
23
+ },
24
+ "devDependencies": {
25
+ "@openzeppelin/truffle-upgrades": "^1.15.0",
26
+ "chai": "^4.3.6",
27
+ "ethers": "^5.6.9",
28
+ "truffle": "^5.5.20"
21
29
  },
22
- "devDependencies": {},
23
30
  "repository": {
24
31
  "type": "git",
25
32
  "url": "git+https://github.com/ayanworks/polygon-did-registry-contract"
@@ -28,7 +35,9 @@
28
35
  "did-method"
29
36
  ],
30
37
  "author": "Ajay Jadhav <ajay@ayanworks.com>",
31
- "contributors": ["Anusha Garg <anusha.garg@ayanworks.com>, Shashank Kulkarni <shashank.kulkarni@ayanworks.com>"],
38
+ "contributors": [
39
+ "Anusha Garg <anusha.garg@ayanworks.com>, Shashank Kulkarni <shashank.kulkarni@ayanworks.com>"
40
+ ],
32
41
  "bugs": {
33
42
  "url": "https://github.com/ayanworks/polygon-did-registry-contract/issues"
34
43
  },
package/sst-config.json CHANGED
@@ -1 +1 @@
1
- {"sourceHash":"0x14a03c371f47729ebf07341b2e088ba55fbf26b5cb30651e577e7b75727b89fc"}
1
+ {"sourceHash":"0xc8790162aa577d0b4d7d5c07565d0921f14a5fd07e896fb2cafd79ec8317eb54"}
@@ -1,16 +1,15 @@
1
1
  const ethers = require('ethers');
2
2
  const ganache = require('ganache-cli');
3
3
  const assert = require('assert');
4
-
4
+ const { deployProxy } = require('@openzeppelin/truffle-upgrades');
5
+ const PolygonDidRegistry = artifacts.require("PolygonDidRegistry");
5
6
 
6
7
  // Library initialization that will talk with Blockchain
7
8
  const provider = new ethers.providers.Web3Provider(ganache.provider({ gasLimit: 8000000 }));
8
-
9
9
  // Initializing the build files
10
- const PolygonDIDRegistryJSON = require('../build/PolygonDidRegistry_PolygonDidRegistry.json');
11
- // const { it } = require('ethers/wordlists');
10
+ const PolygonDIDRegistryJSON = require('../build/contracts/PolygonDidRegistry.json');
12
11
 
13
- let accounts, PolygonDIDRegistryInstance, PolygonDIDRegistryInstance_test;
12
+ let accounts, PolygonDIDRegistryInstance, PolygonDIDRegistryInstance_test, PolygonUpgradableInstance, PolygonUpgradableInstance_test;
14
13
 
15
14
  // Describing the 1st Test
16
15
  // This will setup Ganache with some test address
@@ -26,8 +25,218 @@ describe('Ganache Setup', async () => {
26
25
  });
27
26
  });
28
27
 
29
- // 2nd Test starts here
30
- describe('Basic Contract Testing', () => {
28
+ // Upgradable with Proxy
29
+ // Deployment Testing 1.0
30
+ describe('Setting up the Upgradable Smart Contract', async () => {
31
+
32
+ describe('Setting up the contract', async () => {
33
+
34
+ it("Should deploy contract with Proxy, with no parameters/Constructor", async () => {
35
+ PolygonUpgradableInstance = await deployProxy( PolygonDidRegistry );
36
+ PolygonUpgradableInstance_test = new ethers.Contract(PolygonUpgradableInstance.address, PolygonDIDRegistryJSON.abi, provider.getSigner(accounts[3]));
37
+ assert.ok(PolygonUpgradableInstance.address, 'Upgradeable contract is deployed');
38
+ });
39
+ });
40
+
41
+ //Check Create Function test 1.1
42
+ describe('Checking the Create function using Upgradeable Contract', async () => {
43
+
44
+ it('This should store the DID doc on Upgradable Contract and will read and check if the value stored is correct', async () => {
45
+
46
+ // This will send the value to local ganache blockchain
47
+ const did = '0x2f65b747440deaf596892dfc7965040be8b99100';
48
+ const doc = '{"@context":"https://w3id.org/did/v1","id":"did:polygon:0x2f65b747440deaf596892dfc7965040be8b99100","verificationMethod":[{"id":"did:polygon:0x2f65b747440deaf596892dfc7965040be8b99100","type":"EcdsaSecp256k1VerificationKey2019","controller":"did:polygon:0x2f65b747440deaf596892dfc7965040be8b99100","publicKeyBase58":"NDaEdTguJV39Ns8BZkxQ3XR6GUinZAJfVoyEMkK9fP7XQmpSkT3UsLHB52cFpDqoM6m4Hevtba8pkmjvEG3Ur7ji"}]}';
49
+ const tx = await PolygonUpgradableInstance.createDID(did, doc);
50
+
51
+ // Getting the set value in ganache blockchain
52
+ const currentValue = await PolygonUpgradableInstance.getDID(did);
53
+
54
+ // Comparing the set value to confirm
55
+ assert.equal(
56
+ currentValue,
57
+ doc,
58
+ 'value set must be able to get'
59
+ );
60
+
61
+ assert.notEqual(
62
+ currentValue,
63
+ null,
64
+ 'value should not be empty'
65
+ );
66
+ });
67
+ });
68
+
69
+ // Describing the 1.2 Test case
70
+ describe('Checking the Update function in Upgradable Contract', async () => {
71
+
72
+ it('This should update the DID doc on Upgradable Contract and will read and check if the value stored is correct', async () => {
73
+
74
+ // This will send the value to local ganache blockchain
75
+ const did = '0x2f65b747440deaf596892dfc7965040be8b99100';
76
+ //changed the controller
77
+ const doc = '{"@context":"https://w3id.org/did/v1","id":"did:polygon:0x2f65b747440deaf596892dfc7965040be8b99100","verificationMethod":[{"id":"did:polygon:0x2f65b747440deaf596892dfc7965040be8b99100","type":"EcdsaSecp256k1VerificationKey2019","controller":"did:polygon:0x2f65b747440deaf596892dfc7965040be8c66666","publicKeyBase58":"NDaEdTguJV39Ns8BZkxQ3XR6GUinZAJfVoyEMkK9fP7XQmpSkT3UsLHB52cFpDqoM6m4Hevtba8pkmjvEG3Ur7ji"}]}';
78
+ const tx = await PolygonUpgradableInstance.updateDID(did, doc);
79
+
80
+ // Getting the set value in ganache blockchain
81
+ const currentValue = await PolygonUpgradableInstance.getDID(did);
82
+
83
+ // Comparing the set value to confirm
84
+ assert.equal(
85
+ currentValue,
86
+ doc,
87
+ 'value set must be able to get'
88
+ );
89
+ });
90
+ });
91
+
92
+ //Describing test 1.3 to check if test fails if we update with different controller
93
+ describe('Checking update with wrong controller', async () => {
94
+
95
+ it('This should not update DID doc ', async () => {
96
+
97
+ const did = '0x2f65b747440deaf596892dfc7965040be8b99100';
98
+ const doc = '{"@context":"https://w3id.org/did/v1","id":"did:polygon:0x2f65b747440deaf596892dfc7965040be8b99100","verificationMethod":[{"id":"did:polygon:0x2f65b747440deaf596892dfc7965040be8b99100","type":"EcdsaSecp256k1VerificationKey2019","controller":"did:polygon:0x2f65b747440deaf596892dfc7965040be8c66666","publicKeyBase58":"NDaEdTguJV39Ns8BZkxQ3XR6GUinZAJfVoyEMkK9fP7XQmpSkT3UsLHB52cFpDqoM6m4Hevtba8pkmjvEG3Ur7ji"}]}';
99
+ try {
100
+ assert.ifError(
101
+
102
+ //sending transaction using different controller
103
+ await PolygonUpgradableInstance_test.functions.updateDID(did, doc));
104
+ } catch (error) {
105
+ }
106
+ });
107
+ });
108
+
109
+ // Describing the 1.4 Test case
110
+ describe('Checking the Delete function in Upgradable Contract', async () => {
111
+
112
+ it('This should delete the DID doc on Upgradable Contract and will read and check if the value is now an empty string', async () => {
113
+
114
+ // This will send the value to local ganache blockchain
115
+ const did = '0x2f65b747440deaf596892dfc7965040be8b99100';
116
+ const tx = await PolygonUpgradableInstance.deleteDID(did);
117
+
118
+ // Getting the set value in ganache blockchain
119
+ const currentValue = await PolygonUpgradableInstance.getDID(did);
120
+
121
+ // Comparing the set value to confirm
122
+ assert.equal(
123
+ currentValue,
124
+ "",
125
+ 'value should be matching'
126
+ );
127
+ });
128
+ });
129
+
130
+ // Describing the 1.5 Test case
131
+ describe('Checking the Create function in Upgradable Contract', async () => {
132
+
133
+ it('This should store the DID doc on Upgradable Contract and will read and check if the value stored is not null', async () => {
134
+
135
+ // This will send the value to local ganache blockchain
136
+ const did = '0x54ec7be8b24f7139f870f277cf99c527ff43892b';
137
+ const doc = '{"@context":"https://w3id.org/did/v1","id":"did:polygon:0x54ec7be8b24f7139f870f277cf99c527ff43892b","verificationMethod":[{"id":"did:polygon:0x54ec7be8b24f7139f870f277cf99c527ff43892b","type":"EcdsaSecp256k1VerificationKey2019","controller":"did:polygon:0x54ec7be8b24f7139f870f277cf99c527ff43892b","publicKeyBase58":"RwHysxjkzFdJDqi2irHRVRFHX9uUj5aVAXVoufnk5PDA4qcn1ejJMgGhqCsFdQqXRCTdi4TbEQFJjDUAdi2JvYmH"}]}';
138
+ const doctest = '{"@context":"https://w3id.org/did/v1","id":"did:polygon:0x2f65b747440deaf596892dfc7965040be8b99100","verificationMethod":[{"id":"did:polygon:0x2f65b747440deaf596892dfc7965040be8b99100","type":"EcdsaSecp256k1VerificationKey2019","controller":"did:polygon:0x2f65b747440deaf596892dfc7965040be8c66666","publicKeyBase58":"NDaEdTguJV39Ns8BZkxQ3XR6GUinZAJfVoyEMkK9fP7XQmpSkT3UsLHB52cFpDqoM6m4Hevtba8pkmjvEG3Ur7ji"}]}';
139
+ const tx = await PolygonUpgradableInstance.createDID(did, doc);
140
+
141
+ // Getting the set value in ganache blockchain
142
+ const currentValue = await PolygonUpgradableInstance.getDID(did);
143
+
144
+ // Checking value is not null
145
+
146
+ assert.notEqual(
147
+ currentValue,
148
+ "",
149
+ 'value should not match'
150
+ );
151
+ });
152
+ });
153
+
154
+ // Describing the 1.6 Test case
155
+ describe('Checking the Update function in Upgradable Contract', async () => {
156
+
157
+ it('This should update the DID doc on Upgradable Contract and will read and check if the value stored has changed', async () => {
158
+
159
+ // This will send the value to local ganache blockchain
160
+ const did = '0x54ec7be8b24f7139f870f277cf99c527ff43892b';
161
+ //changed the controller
162
+ const doc = '{"@context":"https://w3id.org/did/v1","id":"did:polygon:0x2f65b747440deaf596892dfc7965040be8b99100","verificationMethod":[{"id":"did:polygon:0x2f65b747440deaf596892dfc7965040be8b99100","type":"EcdsaSecp256k1VerificationKey2019","controller":"did:polygon:0x2f65b747440deaf596892dfc7965040be8c66666","publicKeyBase58":"NDaEdTguJV39Ns8BZkxQ3XR6GUinZAJfVoyEMkK9fP7XQmpSkT3UsLHB52cFpDqoM6m4Hevtba8pkmjvEG3Ur7ji"}]}';
163
+ const docoriginal = '{"@context":"https://w3id.org/did/v1","id":"did:polygon:0x54ec7be8b24f7139f870f277cf99c527ff43892b","verificationMethod":[{"id":"did:polygon:0x54ec7be8b24f7139f870f277cf99c527ff43892b","type":"EcdsaSecp256k1VerificationKey2019","controller":"did:polygon:0x54ec7be8b24f7139f870f277cf99c527ff43892b","publicKeyBase58":"RwHysxjkzFdJDqi2irHRVRFHX9uUj5aVAXVoufnk5PDA4qcn1ejJMgGhqCsFdQqXRCTdi4TbEQFJjDUAdi2JvYmH"}]}';
164
+ const tx = await PolygonUpgradableInstance.updateDID(did, doc);
165
+
166
+ // Getting the set value in ganache blockchain
167
+ const currentValue = await PolygonUpgradableInstance.getDID(did);
168
+
169
+ // Comparing the set value to confirm
170
+ assert.notEqual(
171
+ currentValue,
172
+ docoriginal,
173
+ 'value should not match'
174
+ );
175
+ });
176
+ });
177
+
178
+
179
+ // Describing the 1.7 Test Case
180
+ describe('Checking the Delete function in Upgradable Contract', async () => {
181
+
182
+ it('This should delete the DID doc on Upgradable Contract and will read and check if the value is now not equal to the updated doc', async () => {
183
+
184
+ // This will send the value to local ganache blockchain
185
+ const did = '0x54ec7be8b24f7139f870f277cf99c527ff43892b';
186
+ const doc = '{"@context":"https://w3id.org/did/v1","id":"did:polygon:0x2f65b747440deaf596892dfc7965040be8b99100","verificationMethod":[{"id":"did:polygon:0x2f65b747440deaf596892dfc7965040be8b99100","type":"EcdsaSecp256k1VerificationKey2019","controller":"did:polygon:0x2f65b747440deaf596892dfc7965040be8c66666","publicKeyBase58":"NDaEdTguJV39Ns8BZkxQ3XR6GUinZAJfVoyEMkK9fP7XQmpSkT3UsLHB52cFpDqoM6m4Hevtba8pkmjvEG3Ur7ji"}]}';
187
+ const tx = await PolygonUpgradableInstance.deleteDID(did);
188
+
189
+ // Getting the set value in ganache blockchain
190
+ const currentValue = await PolygonUpgradableInstance.getDID(did);
191
+
192
+ // Comparing the set value to confirm
193
+ assert.notEqual(
194
+ currentValue,
195
+ doc,
196
+ 'value should not be matching'
197
+ );
198
+ });
199
+ });
200
+
201
+
202
+ //Describing the 1.8 Test Case
203
+ describe('Checking the Transafer Ownership Function', async () => {
204
+ it('This should transfer ownership of contract to another user', async () => {
205
+
206
+ const newOwner = accounts[5];
207
+ const owner = await PolygonUpgradableInstance.getOwner();
208
+ const tx = await PolygonUpgradableInstance.transferOwnership(newOwner);
209
+ const currentOwner = await PolygonUpgradableInstance.getOwner();
210
+
211
+ assert.notEqual(
212
+ owner,
213
+ currentOwner,
214
+ 'value should not be equal'
215
+ );
216
+ });
217
+ });
218
+
219
+ //Describing the 1.9 Test Case
220
+ describe('Checking the Transafer Ownership Function', async () => {
221
+ it('This should not transfer ownership of contract to another user since the transaction is being initiated by different owner', async () => {
222
+
223
+ const newOwner = accounts[6];
224
+ try {
225
+ assert.ifError(
226
+ //sending transaction using different controller
227
+ await PolygonUpgradableInstance_test.functions.transferOwnership(newOwner));
228
+ } catch (error) {
229
+ }
230
+ });
231
+ });
232
+
233
+ })
234
+
235
+
236
+
237
+ // basic Contract Testing
238
+ // Deployment Testing 2.0
239
+ describe('Basic Contract Testing', async () => {
31
240
 
32
241
  // Describing a SubTest case
33
242
  describe('Setting up the contract', async () => {
@@ -37,17 +246,17 @@ describe('Basic Contract Testing', () => {
37
246
  // Creating a contract factory for deploying contract.
38
247
  const PolygonDIDRegistry = new ethers.ContractFactory(
39
248
  PolygonDIDRegistryJSON.abi,
40
- PolygonDIDRegistryJSON.evm.bytecode.object,
41
- provider.getSigner(accounts[0])
249
+ PolygonDIDRegistryJSON.bytecode,
250
+ provider.getSigner(accounts[2])
42
251
  );
43
252
  PolygonDIDRegistryInstance = await PolygonDIDRegistry.deploy();
44
- PolygonDIDRegistryInstance_test = new ethers.Contract(PolygonDIDRegistryInstance.address, PolygonDIDRegistryJSON.abi, provider.getSigner(accounts[1]));
253
+ PolygonDIDRegistryInstance_test = new ethers.Contract(PolygonDIDRegistryInstance.address, PolygonDIDRegistryJSON.abi, provider.getSigner(accounts[3]));
45
254
  assert.ok(PolygonDIDRegistryInstance.address, 'conract address should be present');
46
255
  });
47
256
 
48
257
  });
49
258
 
50
- // Describing the 3rd Test case
259
+ // Describing the 2.1 Test case
51
260
  describe('Checking the Create function in Contract', async () => {
52
261
 
53
262
  it('This should store the DID doc on Contract and will read and check if the value stored is correct', async () => {
@@ -78,7 +287,7 @@ describe('Basic Contract Testing', () => {
78
287
  });
79
288
  });
80
289
 
81
- // Describing the 4th Test case
290
+ // Describing the 2.2 Test case
82
291
  describe('Checking the Update function in Contract', async () => {
83
292
 
84
293
  it('This should update the DID doc on Contract and will read and check if the value stored is correct', async () => {
@@ -103,7 +312,7 @@ describe('Basic Contract Testing', () => {
103
312
  );
104
313
  });
105
314
  });
106
- //Describing test 5 to check if test fails if we update with different controller
315
+ //Describing test 2.3 to check if test fails if we update with different controller
107
316
  describe('Checking update with wrong controller', async () => {
108
317
 
109
318
  it('This should not update DID doc ', async () => {
@@ -119,7 +328,7 @@ describe('Basic Contract Testing', () => {
119
328
  });
120
329
  });
121
330
 
122
- // Describing the 6th Test case
331
+ // Describing the 2.4 Test case
123
332
  describe('Checking the Delete function in Contract', async () => {
124
333
 
125
334
  it('This should delete the DID doc on Contract and will read and check if the value is now an empty string', async () => {
@@ -143,7 +352,7 @@ describe('Basic Contract Testing', () => {
143
352
  });
144
353
  });
145
354
 
146
- // Describing the 7th Test case
355
+ // Describing the 2.5 Test case
147
356
  describe('Checking the Create function in Contract', async () => {
148
357
 
149
358
  it('This should store the DID doc on Contract and will read and check if the value stored is not null', async () => {
@@ -170,7 +379,7 @@ describe('Basic Contract Testing', () => {
170
379
  });
171
380
  });
172
381
 
173
- // Describing the 8th Test case
382
+ // Describing the 2.6 Test case
174
383
  describe('Checking the Update function in Contract', async () => {
175
384
 
176
385
  it('This should update the DID doc on Contract and will read and check if the value stored has changed', async () => {
@@ -198,7 +407,7 @@ describe('Basic Contract Testing', () => {
198
407
  });
199
408
 
200
409
 
201
- // Describing the 9th Test case
410
+ // Describing the 2.7 Test case
202
411
  describe('Checking the Delete function in Contract', async () => {
203
412
 
204
413
  it('This should delete the DID doc on Contract and will read and check if the value is now not equal to the updated doc', async () => {
package/truffle-config.js CHANGED
@@ -17,13 +17,10 @@
17
17
  * phrase from a file you've .gitignored so it doesn't accidentally become public.
18
18
  *
19
19
  */
20
+ require("dotenv").config();
20
21
  const HDWalletProvider = require("@truffle/hdwallet-provider");
21
- const mnemonic = "";
22
- // const HDWalletProvider = require('@truffle/hdwallet-provider');
23
- // const infuraKey = "fj4jll3k.....";
24
- //
25
- // const fs = require('fs');
26
- // const mnemonic = fs.readFileSync(".secret").toString().trim();
22
+ const { rpcUrl, mnemonic } = process.env;
23
+
27
24
 
28
25
  module.exports = {
29
26
  /**
@@ -35,8 +32,6 @@
35
32
  *
36
33
  * $ truffle test --network <network-name>
37
34
  */
38
-
39
-
40
35
  networks: {
41
36
 
42
37
  development: {
@@ -46,53 +41,16 @@
46
41
  },
47
42
  matic: {
48
43
  provider: function () {
49
- return new HDWalletProvider(mnemonic, "https://rpc-mumbai.matic.today");
44
+ return new HDWalletProvider(mnemonic, rpcUrl);
50
45
  },
51
46
  network_id: '80001',
52
47
  },
53
48
  matic_mainnet: {
54
49
  provider: function () {
55
- return new HDWalletProvider(mnemonic, "https://rpc-mainnet.maticvigil.com/");
50
+ return new HDWalletProvider(mnemonic, rpcUrl);
56
51
  },
57
52
  network_id: '137',
58
53
  }
59
-
60
- // Useful for testing. The `development` name is special - truffle uses it by default
61
- // if it's defined here and no other network is specified at the command line.
62
- // You should run a client (like ganache-cli, geth or parity) in a separate terminal
63
- // tab if you use this network and you must also set the `host`, `port` and `network_id`
64
- // options below to some value.
65
- //
66
- // development: {
67
- // host: "127.0.0.1", // Localhost (default: none)
68
- // port: 8545, // Standard Ethereum port (default: none)
69
- // network_id: "*", // Any network (default: none)
70
- // },
71
- // Another network with more advanced options...
72
- // advanced: {
73
- // port: 8777, // Custom port
74
- // network_id: 1342, // Custom network
75
- // gas: 8500000, // Gas sent with each transaction (default: ~6700000)
76
- // gasPrice: 20000000000, // 20 gwei (in wei) (default: 100 gwei)
77
- // from: <address>, // Account to send txs from (default: accounts[0])
78
- // websocket: true // Enable EventEmitter interface for web3 (default: false)
79
- // },
80
- // Useful for deploying to a public network.
81
- // NB: It's important to wrap the provider as a function.
82
- // ropsten: {
83
- // provider: () => new HDWalletProvider(mnemonic, `https://ropsten.infura.io/v3/YOUR-PROJECT-ID`),
84
- // network_id: 3, // Ropsten's id
85
- // gas: 5500000, // Ropsten has a lower block limit than mainnet
86
- // confirmations: 2, // # of confs to wait between deployments. (default: 0)
87
- // timeoutBlocks: 200, // # of blocks before a deployment times out (minimum/default: 50)
88
- // skipDryRun: true // Skip dry run before migrations? (default: false for public nets )
89
- // },
90
- // Useful for private networks
91
- // private: {
92
- // provider: () => new HDWalletProvider(mnemonic, `https://network.io`),
93
- // network_id: 2111, // This network is yours, in the cloud.
94
- // production: true // Treats this network as if it was a public net. (default: false)
95
- // }
96
54
  },
97
55
 
98
56
  // Set default mocha options here, use special reporters etc.
@@ -104,23 +62,9 @@
104
62
  compilers: {
105
63
  solc: {
106
64
  version: "0.8.0", // Fetch exact version from solc-bin (default: truffle's version)
107
- // docker: true, // Use "0.5.1" you've installed locally with docker (default: false)
108
- // settings: { // See the solidity docs for advice about optimization and evmVersion
109
- // optimizer: {
110
- // enabled: false,
111
- // runs: 200
112
- // },
113
- // evmVersion: "byzantium"
114
- // }
115
65
  }
116
66
  },
117
67
 
118
- // Truffle DB is currently disabled by default; to enable it, change enabled: false to enabled: true
119
- //
120
- // Note: if you migrated your contracts prior to enabling this field in your Truffle project and want
121
- // those previously migrated contracts available in the .db directory, you will need to run the following:
122
- // $ truffle migrate --reset --compile-all
123
-
124
68
  db: {
125
69
  enabled: false
126
70
  }