diff --git a/.env.example b/.env.example index 544d02d..ded86c3 100644 --- a/.env.example +++ b/.env.example @@ -4,11 +4,11 @@ # DEPLOYMENT CONFIGURATION # ================================ -# Deployer's private key (used for contract deployment) +# Private key (used for deployment and oracle operations) # IMPORTANT: This should be a funded account with enough ETH for gas # NEVER commit your real private key! # The key below is from Anvil's default accounts - DO NOT USE IN PRODUCTION -DEPLOYER_PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 +PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 # ================================ # ORACLE CONFIGURATION @@ -21,12 +21,6 @@ DEPLOYER_PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf # Mainnet: https://mainnet.infura.io/v3/YOUR-INFURA-KEY RPC_URL=http://localhost:8545 -# Oracle operator's private key (required for oracle) -# This account submits arbitration decisions on-chain -# IMPORTANT: Ensure this account has sufficient ETH for gas! -# The key below is from Anvil's default accounts - DO NOT USE IN PRODUCTION -PRIVATE_KEY=0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d - # EAS (Ethereum Attestation Service) Contract Address (optional) # If you used the deploy script, get this from deployments/.json # EAS_CONTRACT_ADDRESS=0x... diff --git a/README.md b/README.md index 36f7214..23c1790 100644 --- a/README.md +++ b/README.md @@ -179,7 +179,6 @@ nla escrow:collect \ ```bash # 1. Get Sepolia ETH from faucet # 2. Set your keys -export DEPLOYER_PRIVATE_KEY=0x... export PRIVATE_KEY=0x... export OPENAI_API_KEY=sk-... @@ -194,7 +193,6 @@ nla start-oracle sepolia ```bash # āš ļø PRODUCTION - Be careful! -export DEPLOYER_PRIVATE_KEY=0x... export PRIVATE_KEY=0x... export OPENAI_API_KEY=sk-... diff --git a/cli/server/deploy.ts b/cli/server/deploy.ts index 4bca840..5cc57bb 100644 --- a/cli/server/deploy.ts +++ b/cli/server/deploy.ts @@ -13,6 +13,7 @@ import { mainnet, sepolia, baseSepolia, foundry } from "viem/chains"; import { writeFileSync, existsSync, mkdirSync } from "fs"; import { resolve } from "path"; import { fixtures, contracts } from "alkahest-ts"; +import { getPrivateKey } from "../utils.js"; // Helper function to display usage function displayHelp() { @@ -30,7 +31,7 @@ Options: --help, -h Display this help message Environment Variables (alternative to CLI options): - DEPLOYER_PRIVATE_KEY Deployer's private key + PRIVATE_KEY Deployer's private key RPC_URL Custom RPC URL Networks: @@ -47,7 +48,7 @@ Examples: bun deploy.ts --network sepolia --private-key 0x... --rpc-url https://sepolia.infura.io/v3/YOUR-KEY # Using environment variables - export DEPLOYER_PRIVATE_KEY=0x... + export PRIVATE_KEY=0x... bun deploy.ts --network localhost `); } @@ -98,7 +99,7 @@ async function main() { // Get configuration const network = args.network; - const privateKey = args["private-key"] || process.env.DEPLOYER_PRIVATE_KEY; + const privateKey = args["private-key"] || getPrivateKey(); let rpcUrl = args["rpc-url"] || process.env.RPC_URL; // Validate required parameters @@ -109,8 +110,12 @@ async function main() { } if (!privateKey) { - console.error("āŒ Error: Private key is required. Use --private-key or set DEPLOYER_PRIVATE_KEY"); - console.error("Run with --help for usage information."); + console.error("āŒ Error: Private key is required."); + console.error("\nšŸ’” You can either:"); + console.error(" 1. Set it globally: nla wallet:set --private-key "); + console.error(" 2. Use for this command only: --private-key "); + console.error(" 3. Set PRIVATE_KEY environment variable"); + console.error("\nRun with --help for usage information."); process.exit(1); }