-
Notifications
You must be signed in to change notification settings - Fork 0
/
blockchain_config.js
76 lines (65 loc) · 2.34 KB
/
blockchain_config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
```javascript
// Importing necessary libraries and modules
const Web3 = require('web3');
const Besu = require('besu-js');
// Defining the chain IDs
const QUANTUM_UNITY_FRAMEWORK_CHAIN_ID = '0x0';
const GLOBAL_DIGITAL_CURRENCY_NETWORK_CHAIN_ID = '0x9';
const CONTUDO_CHAIN_ID = '0x8A';
// Defining the provider
const provider = new Web3.providers.HttpProvider('http://localhost:8545');
// Creating an instance of Web3
const web3 = new Web3(provider);
// Creating an instance of Besu
const besu = new Besu(provider);
// Function to create a new blockchain
async function createBlockchain(chainId) {
try {
// Creating a new blockchain
const result = await besu.blockchain.create({
chainId: chainId,
networkId: chainId,
genesis: {
timestamp: Math.round((new Date()).getTime() / 1000),
gasLimit: 5000,
difficulty: 1,
alloc: {},
config: {
chainId: chainId,
homesteadBlock: 0,
eip150Block: 0,
eip155Block: 0,
eip158Block: 0,
byzantiumBlock: 0,
constantinopleBlock: 0,
petersburgBlock: 0,
istanbulBlock: 0,
muirGlacierBlock: 0,
berlinBlock: 0,
londonBlock: 0
}
}
});
console.log(`Blockchain with Chain ID ${chainId} created successfully.`);
return result;
} catch (error) {
console.error(`Error creating blockchain with Chain ID ${chainId}: `, error);
}
}
// Function to replace the existing blockchain
async function replaceExistingBlockchain() {
try {
// Creating the Quantum Unity Framework blockchain
await createBlockchain(QUANTUM_UNITY_FRAMEWORK_CHAIN_ID);
// Creating the Global Digital Currency Network blockchain
await createBlockchain(GLOBAL_DIGITAL_CURRENCY_NETWORK_CHAIN_ID);
// Creating the Contudo blockchain
await createBlockchain(CONTUDO_CHAIN_ID);
console.log('All blockchains created successfully.');
} catch (error) {
console.error('Error replacing the existing blockchain: ', error);
}
}
// Replacing the existing blockchain
replaceExistingBlockchain();
```