Skip to content

Commit fcea1ac

Browse files
committed
feat: enhance security and add environment configuration templates
- Improved secret management with environment variables - Added .env.base files to .gitignore for better security - Created .env.example with placeholder values for safe distribution - Updated example code to enforce environment variable usage - Added comprehensive security reminders in configuration templates - Added test utilities for Base mainnet testing This ensures compliance with security best practices for handling sensitive credentials in development and production environments.
1 parent 5b26a95 commit fcea1ac

File tree

8 files changed

+546
-1
lines changed

8 files changed

+546
-1
lines changed

.env.example

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Example environment configuration
2+
# Copy this file to .env and fill in your actual values
3+
# NEVER commit .env files with real credentials
4+
5+
# Private key for transaction signing
6+
# Use a test wallet with minimal funds for development
7+
PRIVATE_KEY=your_private_key_here_without_0x_prefix
8+
9+
# RPC URLs for different networks
10+
RPC_URL_ETHEREUM=https://eth-mainnet.g.alchemy.com/v2/YOUR_ALCHEMY_KEY
11+
RPC_URL_POLYGON=https://polygon-rpc.com
12+
RPC_URL_BASE=https://mainnet.base.org
13+
RPC_URL_ARBITRUM=https://arb1.arbitrum.io/rpc
14+
15+
# WalletConnect Project ID (get from cloud.reown.com)
16+
WALLETCONNECT_PROJECT_ID=your_project_id_here
17+
18+
# Network configuration
19+
CHAIN_ID=1
20+
NETWORK_NAME=ethereum
21+
22+
# Transaction settings
23+
DEFAULT_GAS_LIMIT=21000
24+
CONFIRMATION_BLOCKS=1
25+
MAX_RETRIES=3
26+
27+
# Test configuration (for development only)
28+
TEST_RECIPIENT_ADDRESS=0x0000000000000000000000000000000000000000
29+
TEST_AMOUNT_ETH=0.001
30+
31+
# API Keys (if needed)
32+
ALCHEMY_API_KEY=your_alchemy_key_here
33+
INFURA_API_KEY=your_infura_key_here
34+
ETHERSCAN_API_KEY=your_etherscan_key_here
35+
36+
# SECURITY REMINDERS:
37+
# 1. Never share your private keys
38+
# 2. Use separate wallets for testing and production
39+
# 3. Keep production keys in secure key management systems
40+
# 4. Add .env to .gitignore (already done)
41+
# 5. Use environment-specific .env files (.env.development, .env.production)

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ dist/
88
.env
99
.env.local
1010
.env.*.local
11+
.env.base
12+
test-base/.env.base
1113

1214
# Logs
1315
npm-debug.log*

examples/real-transactions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const { SequentialTransactionHandler } = require('@cryptoflops/walletconnect-seq
1414
const CONFIG = {
1515
// Your private key (NEVER commit this to git!)
1616
// For testing, use a test wallet with small amounts
17-
PRIVATE_KEY: process.env.PRIVATE_KEY || 'YOUR_PRIVATE_KEY_HERE',
17+
PRIVATE_KEY: process.env.PRIVATE_KEY, // Always use environment variables, never hardcode
1818

1919
// RPC URLs (you can get free ones from Infura, Alchemy, etc.)
2020
RPC_URLS: {

project-info.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/bash
2+
3+
echo "
4+
╔══════════════════════════════════════════════════════════════════╗
5+
║ WalletConnect Sequential Transaction Handler - Project Info ║
6+
╚══════════════════════════════════════════════════════════════════╝
7+
8+
📦 NPM Package Information:
9+
Name: @cryptoflops/walletconnect-sequential-tx
10+
Version: 1.0.0
11+
URL: https://www.npmjs.com/package/@cryptoflops/walletconnect-sequential-tx
12+
13+
🐙 GitHub Repository:
14+
URL: https://github.com/cryptoflops/walletconnect-sequential-tx
15+
16+
📊 Badges for README/Documentation:
17+
18+
NPM Version:
19+
[![npm version](https://img.shields.io/npm/v/@cryptoflops/walletconnect-sequential-tx.svg)](https://www.npmjs.com/package/@cryptoflops/walletconnect-sequential-tx)
20+
21+
NPM Downloads:
22+
[![npm downloads](https://img.shields.io/npm/dm/@cryptoflops/walletconnect-sequential-tx.svg)](https://www.npmjs.com/package/@cryptoflops/walletconnect-sequential-tx)
23+
24+
Build Status:
25+
[![CI](https://github.com/cryptoflops/walletconnect-sequential-tx/actions/workflows/ci.yml/badge.svg)](https://github.com/cryptoflops/walletconnect-sequential-tx/actions/workflows/ci.yml)
26+
27+
License:
28+
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
29+
30+
Bundle Size:
31+
[![npm bundle size](https://img.shields.io/bundlephobia/min/@cryptoflops/walletconnect-sequential-tx)](https://bundlephobia.com/package/@cryptoflops/walletconnect-sequential-tx)
32+
33+
📝 Installation Command:
34+
npm install @cryptoflops/walletconnect-sequential-tx
35+
36+
🚀 Import Statement:
37+
import { SequentialTransactionHandler } from '@cryptoflops/walletconnect-sequential-tx';
38+
39+
✨ View Live on:
40+
• NPM Registry: https://www.npmjs.com/package/@cryptoflops/walletconnect-sequential-tx
41+
• GitHub: https://github.com/cryptoflops/walletconnect-sequential-tx
42+
• Bundlephobia: https://bundlephobia.com/package/@cryptoflops/walletconnect-sequential-tx
43+
"

test-base/package-lock.json

Lines changed: 125 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test-base/package.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "test-base",
3+
"version": "1.0.0",
4+
"main": "setup.js",
5+
"scripts": {
6+
"test": "echo \"Error: no test specified\" && exit 1"
7+
},
8+
"keywords": [],
9+
"author": "",
10+
"license": "ISC",
11+
"description": "",
12+
"dependencies": {
13+
"dotenv": "^17.2.3",
14+
"ethers": "^6.15.0"
15+
}
16+
}

test-base/setup.js

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
#!/usr/bin/env node
2+
3+
/**
4+
* Base Mainnet Testing Setup
5+
* This script helps you test the Sequential Transaction Handler on Base mainnet
6+
*/
7+
8+
const fs = require('fs');
9+
const path = require('path');
10+
11+
console.log('🚀 Setting up Base mainnet testing environment...\n');
12+
13+
// Check if .env.base exists
14+
const envPath = path.join(__dirname, '.env.base');
15+
if (!fs.existsSync(envPath)) {
16+
console.log('📝 Creating .env.base file...');
17+
const envTemplate = `# Base Mainnet Configuration
18+
# ⚠️ WARNING: This is for MAINNET - real money! Use small amounts for testing
19+
20+
# Base Mainnet RPC URLs (choose one)
21+
RPC_URL=https://mainnet.base.org
22+
# RPC_URL=https://base.llamarpc.com
23+
# RPC_URL=https://base.blockpi.network/v1/rpc/public
24+
25+
# Your wallet private key (USE A TEST WALLET WITH SMALL AMOUNTS!)
26+
# Create a new wallet specifically for testing
27+
# NEVER commit this file with a real private key!
28+
PRIVATE_KEY=YOUR_PRIVATE_KEY_HERE
29+
30+
# Base Network Configuration
31+
CHAIN_ID=8453
32+
NETWORK_NAME=base
33+
34+
# Base Block Explorer
35+
EXPLORER_URL=https://basescan.org
36+
37+
# Transaction Settings
38+
DEFAULT_GAS_LIMIT=100000
39+
CONFIRMATION_BLOCKS=1
40+
MAX_RETRIES=3
41+
42+
# Test Recipients (you can change these)
43+
TEST_RECIPIENT_1=0x
44+
TEST_RECIPIENT_2=0x
45+
46+
# Test Amounts (in ETH - keep these small!)
47+
TEST_AMOUNT_ETH=0.000001
48+
49+
# Popular Base Tokens (for testing token transfers)
50+
# USDC on Base
51+
USDC_ADDRESS=0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913
52+
# Wrapped ETH on Base
53+
WETH_ADDRESS=0x4200000000000000000000000000000000000006
54+
55+
# DEX Contracts on Base
56+
# Uniswap V3 Router
57+
UNISWAP_V3_ROUTER=0x2626664c2603336E57B271c5C0b26F421741e481
58+
# BaseSwap Router
59+
BASESWAP_ROUTER=0x327Df1E6de05895d2ab08513aaDD9313Fe505d86
60+
61+
# Bridge Base ETH to Base:
62+
# https://bridge.base.org/
63+
`;
64+
65+
fs.writeFileSync(envPath, envTemplate);
66+
console.log('✅ Created .env.base template\n');
67+
console.log('⚠️ IMPORTANT: Edit .env.base with your configuration before testing!\n');
68+
} else {
69+
console.log('✅ .env.base already exists\n');
70+
}
71+
72+
console.log('📌 Base Mainnet Information:');
73+
console.log(' Chain ID: 8453');
74+
console.log(' Native Token: ETH');
75+
console.log(' Block Explorer: https://basescan.org');
76+
console.log(' Bridge: https://bridge.base.org/\n');
77+
78+
console.log('🎯 Setup complete! Next steps:');
79+
console.log('1. Edit .env.base with your private key (use a test wallet!)');
80+
console.log('2. Bridge some ETH to Base: https://bridge.base.org/');
81+
console.log('3. Run: node test-simple.js (for simple ETH transfers)');
82+
console.log('4. Run: node test-sequential.js (for sequential transactions)');
83+
console.log('5. Run: node test-tokens.js (for token operations)\n');
84+
85+
console.log('⚠️ SAFETY REMINDERS:');
86+
console.log(' - This is MAINNET - transactions cost real money');
87+
console.log(' - Use a dedicated test wallet with small amounts');
88+
console.log(' - Start with very small test amounts (0.000001 ETH)');
89+
console.log(' - Always double-check addresses before sending\n');

0 commit comments

Comments
 (0)