Skip to content

Commit 2b75df6

Browse files
authored
Create 5_deploy_oracle.js
1 parent e791fb9 commit 2b75df6

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

migrations/5_deploy_oracle.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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+
};

0 commit comments

Comments
 (0)