|
| 1 | +// truffle-config.js |
| 2 | + |
| 3 | +const HDWalletProvider = require('@truffle/hdwallet-provider'); |
| 4 | +const Web3 = require('web3'); |
| 5 | +require('dotenv').config(); // Load environment variables from .env file |
| 6 | + |
| 7 | +const MNEMONIC = process.env.MNEMONIC; // Your wallet mnemonic |
| 8 | +const INFURA_PROJECT_ID = process.env.INFURA_PROJECT_ID; // Infura project ID |
| 9 | +const INFURA_URL = `https://rinkeby.infura.io/v3/${INFURA_PROJECT_ID}`; // Rinkeby testnet URL |
| 10 | +const MAINNET_URL = `https://mainnet.infura.io/v3/${INFURA_PROJECT_ID}`; // Mainnet URL |
| 11 | + |
| 12 | +module.exports = { |
| 13 | + // Configure networks |
| 14 | + networks: { |
| 15 | + development: { |
| 16 | + host: "127.0.0.1", // Localhost (default: none) |
| 17 | + port: 7545, // Ganache port (default: none) |
| 18 | + network_id: "*", // Any network (default: none) |
| 19 | + }, |
| 20 | + rinkeby: { |
| 21 | + provider: () => new HDWalletProvider(MNEMONIC, INFURA_URL), |
| 22 | + network_id: 4, // Rinkeby's id |
| 23 | + gas: 5500000, // Gas limit |
| 24 | + confirmations: 2, // # of confirmations to wait between deployments |
| 25 | + timeoutBlocks: 200, // # of blocks before a deployment times out |
| 26 | + skipDryRun: true // Skip dry run before migrations? (default: false for public nets) |
| 27 | + }, |
| 28 | + mainnet: { |
| 29 | + provider: () => new HDWalletProvider(MNEMONIC, MAINNET_URL), |
| 30 | + network_id: 1, // Mainnet's id |
| 31 | + gas: 5500000, // Gas limit |
| 32 | + confirmations: 2, // # of confirmations to wait between deployments |
| 33 | + timeoutBlocks: 200, // # of blocks before a deployment times out |
| 34 | + skipDryRun: true // Skip dry run before migrations? (default: false for public nets) |
| 35 | + } |
| 36 | + }, |
| 37 | + |
| 38 | + // Configure compilers |
| 39 | + compilers: { |
| 40 | + solc: { |
| 41 | + version: "0.8.19", // Specify the Solidity version |
| 42 | + settings: { |
| 43 | + optimizer: { |
| 44 | + enabled: true, // Enable optimization |
| 45 | + runs: 200 // Optimize for how many times you intend to run the code |
| 46 | + }, |
| 47 | + evmVersion: "istanbul" // Specify the EVM version |
| 48 | + } |
| 49 | + } |
| 50 | + }, |
| 51 | + |
| 52 | + // Configure plugins |
| 53 | + plugins: [ |
| 54 | + 'truffle-plugin-verify', // Plugin for verifying contracts on Etherscan |
| 55 | + 'truffle-contract-size' // Plugin for checking contract sizes |
| 56 | + ], |
| 57 | + |
| 58 | + // Configure Mocha testing framework |
| 59 | + mocha: { |
| 60 | + timeout: 100000 // Set timeout for tests |
| 61 | + }, |
| 62 | + |
| 63 | + // Configure the build directory |
| 64 | + contracts_build_directory: './build/contracts', |
| 65 | + |
| 66 | + // Configure the migrations directory |
| 67 | + migrations_directory: './migrations', |
| 68 | + |
| 69 | + // Configure the test directory |
| 70 | + test_directory: './test', |
| 71 | + |
| 72 | + // Configure the artifacts directory |
| 73 | + artifacts_directory: './artifacts' |
| 74 | +}; |
0 commit comments