-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhardhat.config.js
94 lines (82 loc) · 2.64 KB
/
hardhat.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
require("@nomicfoundation/hardhat-toolbox");
require("@openzeppelin/hardhat-upgrades");
require("@vechain/hardhat-vechain");
require('@vechain/hardhat-ethers');
require('dotenv/config');
require('hardhat-deploy');
const ethUtil = require('ethereumjs-util');
const PRIVATE_KEY = process.env.PRIVATE_KEY;
//check deployer public address
if (!process.env.PRIVATE_KEY) {
throw new Error(
"Please set your PRIVATE_KEY in a .env file or in your environment variables"
);
} else {
// Replace the following private key with your actual private key.
const hexKey = process.env.PRIVATE_KEY.replace("0x","")
const privateKey = Buffer.from(hexKey, 'hex');
// Derive the public key
const publicKey = ethUtil.privateToPublic(privateKey);
// Derive the Ethereum address from the public key
const my_address = ethUtil.publicToAddress(publicKey, true); // The 'true' parameter here ensures the address is returned as a Buffer.
// Convert the address to a hexadecimal string
const my_addressHex = ethUtil.bufferToHex(my_address);
// Convert public key to hex string
const publicKeyString = publicKey.toString('hex');
const ethereumAddressString = ethUtil.bufferToHex(my_addressHex);
console.log("Deployer Public Key:", publicKeyString);
console.log("Deployer address: ", ethereumAddressString );
}
const accounts = [
process.env.PRIVATE_KEY ?? PRIVATE_KEY, // deployer
process.env.DEPLOYER_PRIVATE_KEY ?? PRIVATE_KEY, // proxyOwner
process.env.OWNER_PRIVATE_KEY ?? PRIVATE_KEY, // owner
];
// see https://github.com/wighawag/hardhat-deploy?tab=readme-ov-file#1-namedaccounts-ability-to-name-addresses
const namedAccounts = {
deployer: { default: 0 },
proxyOwner: { default: 1 },
owner: { default: 2 },
};
const config = {
solidity: {
version : "0.8.19",
settings: {
optimizer: {
enabled: true,
runs: 200,
},
viaIR: true,
},
},
defaultNetwork: "vechain_testnet",
networks: {
localdev : {
url : "http://localhost:8669",
accounts,
restful: true,
gas: 10000000 ,
loggingEnabled : true
},
vechain_testnet: {
url: "https://node-testnet.vechain.energy",
accounts,
restful: true,
gas: 10000000,
// optionally use fee delegation to let someone else pay the gas fees
// visit vechain.energy for a public fee delegation service
delegate: {
url: "https://sponsor-testnet.vechain.energy/by/90"
},
loggingEnabled: true
},
vechain_mainnet: {
url: "https://node-mainnet.vechain.energy",
accounts,
restful: true,
gas: 10000000,
},
},
namedAccounts
};
module.exports = config;