File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change 1+ // migrations/5_deploy_oracle.js
2+
3+ const Oracle = artifacts . require ( "Oracle" ) ;
4+
5+ module . exports = async function ( deployer , network , accounts ) {
6+ try {
7+ // Deploy the Oracle contract
8+ await deployer . deploy ( Oracle ) ;
9+ const oracleInstance = await Oracle . deployed ( ) ;
10+
11+ // Log the deployment
12+ console . log ( `Oracle contract deployed at: ${ oracleInstance . address } ` ) ;
13+
14+ // Set up initial roles
15+ const adminRole = await oracleInstance . ADMIN_ROLE ( ) ;
16+ const oracleRole = await oracleInstance . ORACLE_ROLE ( ) ;
17+
18+ // Grant the deployer the admin role
19+ await oracleInstance . grantRole ( adminRole , accounts [ 0 ] ) ;
20+ console . log ( `Admin role granted to: ${ accounts [ 0 ] } ` ) ;
21+
22+ // Optionally, you can add additional accounts as oracles
23+ const additionalOracles = [ accounts [ 1 ] , accounts [ 2 ] ] ; // Example: Add the next two accounts as oracles
24+
25+ for ( const oracle of additionalOracles ) {
26+ await oracleInstance . grantRole ( oracleRole , oracle ) ;
27+ console . log ( `Oracle role granted to: ${ oracle } ` ) ;
28+ }
29+
30+ // Emit an event for successful deployment (if you have an event in the contract)
31+ // await oracleInstance.emitDeploymentEvent(oracleInstance.address); // Uncomment if you have an event
32+
33+ } catch ( error ) {
34+ console . error ( "Error during Oracle contract deployment:" , error ) ;
35+ }
36+ } ;
You can’t perform that action at this time.
0 commit comments