Skip to content

Dev Wallet for Testing smart contract instead of using Meta mask Test-net option

Notifications You must be signed in to change notification settings

YASH514131/OnlyDev_Wallet

Repository files navigation

🧩 DevNet-Only Developer Wallet Extension

A secure, open-source browser wallet for testing smart contracts across multiple blockchains β€” never mainnet.

DevNet Wallet License Version

πŸš€ Overview

DevNet Wallet is a lightweight, privacy-preserving Chrome/Brave extension that lets blockchain developers test and debug dApps on devnets and other test networks without risking real assets.

✨ Features

  • βœ… Developer-only wallet – never stores or touches mainnet keys
  • βœ… Supports both ECDSA (secp256k1) and Ed25519 (Solana) key types
  • βœ… Ephemeral by default – private keys live in memory unless user encrypts
  • βœ… Multi-chain testing – single UI for EVM and Solana testnets
  • βœ… Extensible architecture – easy to add new testnets

Supported Networks

Network Type Chain/Cluster ID RPC URL Explorer Faucet
Ethereum Sepolia EVM 11155111 https://eth-sepolia.public.blastapi.io sepolia.etherscan.io sepoliafaucet.com
Polygon Amoy EVM 80002 https://rpc-amoy.polygon.technology amoy.polygonscan.com faucet.polygon.technology
BSC Testnet EVM 97 https://data-seed-prebsc-1-s1.binance.org:8545 testnet.bscscan.com Binance Faucet
Avalanche Fuji EVM 43113 https://api.avax-test.network/ext/bc/C/rpc testnet.snowtrace.io faucet.avax.network
Local Hardhat/Anvil EVM 31337 http://127.0.0.1:8545 Local Dev Built-in
Solana Devnet Ed25519 devnet https://api.devnet.solana.com explorer.solana.com faucet.solana.com

🧱 Architecture

Tech Stack

  • Frontend: React + TypeScript + Tailwind CSS
  • Blockchain Libraries:
    • ethers.js β†’ EVM chains (secp256k1)
    • @solana/web3.js β†’ Solana Devnet (Ed25519)
  • Extension APIs: Manifest V3 (chrome.runtime, chrome.storage, chrome.action)
  • Crypto:
    • EVM keys β†’ BIP-39 / BIP-44 (HD wallets)
    • Solana keys β†’ Ed25519 Keypair (tweetnacl)
  • Storage: In-memory (default) or AES-encrypted sessionStorage

Project Structure

devnet-wallet/
β”œβ”€β”€ manifest.json           # Extension manifest (V3)
β”œβ”€β”€ package.json            # Dependencies
β”œβ”€β”€ vite.config.ts          # Build configuration
β”œβ”€β”€ tailwind.config.js      # Tailwind CSS config
β”œβ”€β”€ tsconfig.json           # TypeScript config
β”œβ”€β”€ index.html              # Popup HTML
β”œβ”€β”€ public/
β”‚   β”œβ”€β”€ icons/              # Extension icons
β”‚   └── inject.js           # Injected wallet API
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ background/
β”‚   β”‚   └── index.ts        # Service worker
β”‚   β”œβ”€β”€ content/
β”‚   β”‚   └── inject.ts       # Content script
β”‚   β”œβ”€β”€ popup/
β”‚   β”‚   β”œβ”€β”€ index.tsx       # Popup entry
β”‚   β”‚   β”œβ”€β”€ Popup.tsx       # Main popup component
β”‚   β”‚   └── components/     # UI components
β”‚   β”‚       β”œβ”€β”€ Header.tsx
β”‚   β”‚       β”œβ”€β”€ CreateWalletView.tsx
β”‚   β”‚       β”œβ”€β”€ WalletView.tsx
β”‚   β”‚       └── SettingsView.tsx
β”‚   β”œβ”€β”€ utils/
β”‚   β”‚   β”œβ”€β”€ evm.ts          # EVM wallet helpers
β”‚   β”‚   β”œβ”€β”€ solana.ts       # Solana key & tx helpers
β”‚   β”‚   β”œβ”€β”€ network.ts      # Network configurations
β”‚   β”‚   β”œβ”€β”€ faucet.ts       # Faucet integrations
β”‚   β”‚   β”œβ”€β”€ crypto.ts       # Encryption utilities
β”‚   β”‚   └── storage.ts      # Storage management
β”‚   └── styles/
β”‚       └── index.css       # Global styles
└── README.md

🧠 Core Features

πŸ” Key Management

  • Auto-generate new wallet on first load (ECDSA + Ed25519)
  • Optional import (private key / seed phrase / Solana keypair)
  • Optional encrypted export with "TESTNET ONLY" warning
  • Auto-wipe keys on tab close
  • Multi-format support:
    • 0x hex (private key – EVM)
    • Mnemonic (12/24 words)
    • Solana base58 secret key

🌍 Network Management

  • Preloaded testnets (see table above)
  • Manual switch dropdown
  • Custom RPC addition with explicit "TESTNET ONLY" checkbox
  • Auto-reject chainId 1 (mainnet) or Solana mainnet-beta

πŸ’Έ Faucet Access

  • Per-network "Get Test Tokens" button
  • Built-in local faucet for Hardhat/Anvil
  • Direct links to external faucets

🧾 Transactions & Signing

  • Transaction preview modal (from/to/value/gas/data)
  • EVM: ethers.Wallet.signTransaction & sendTransaction
  • Solana: Transaction via @solana/web3.js
  • Logs all signed tx hashes for developer debugging

πŸ’¬ UI Overview

Popup Panel

  • Network selector
  • Wallet address (copy icon)
  • Balance display
  • Buttons: Send / Receive / Faucet / Settings

Settings Panel

  • "Persist key (encrypted)" toggle
  • Manage networks
  • Clear wallet
  • Export key (with warning)
  • Debug logs toggle

Visual Safety

  • Red banner: "TESTNET ONLY – NO REAL FUNDS"
  • Always display chain name and RPC URL in header

🧰 Developer Integration

Injected APIs

The extension injects window.devnetWallet (EVM) and window.solanaDevnetWallet (Solana) into web pages. Legacy aliases (window.testnetWallet, window.solanaTestnetWallet) remain available for compatibility.

EVM API (similar to window.ethereum)

// Request accounts
const accounts = await window.devnetWallet.request({ 
  method: 'eth_requestAccounts' 
});

// Get current chain
const chainId = await window.devnetWallet.request({ 
  method: 'eth_chainId' 
});

// Send transaction
const txHash = await window.devnetWallet.request({
  method: 'eth_sendTransaction',
  params: [{
    from: accounts[0],
    to: '0x...',
    value: '0x...',
    gas: '0x...',
  }]
});

// Listen for network changes
window.devnetWallet.on('chainChanged', (chainId) => {
  console.log('Network changed to:', chainId);
});

Solana API (similar to Phantom)

// Connect wallet
const { publicKey } = await window.solanaDevnetWallet.connect();

// Send transaction
const connection = new solanaWeb3.Connection('https://api.devnet.solana.com');
const transaction = new solanaWeb3.Transaction().add(
  solanaWeb3.SystemProgram.transfer({
    fromPubkey: publicKey,
    toPubkey: recipientPublicKey,
    lamports: amount,
  })
);

const { signature } = await window.solanaDevnetWallet.signAndSendTransaction(transaction);

πŸ›‘οΈ Security Model

  • βœ… Handshake-authenticated messaging bridge between dApp, content script, and service worker
  • βœ… Strict RPC input validation before forwarding any call to external providers
  • βœ… Block chainId 1 and mainnet-beta
  • βœ… Keys never leave local context
  • βœ… All RPC calls HTTPS or localhost
  • βœ… No analytics or telemetry
  • βœ… Strong warnings for seed import/export
  • βœ… UI must show active network and testnet badge at all times

πŸ”§ Build & Run

Prerequisites

  • Node.js 18+ and npm/yarn
  • Chrome or Brave browser

Installation

# Clone the repository
git clone https://github.com/yourname/devnet-wallet
cd devnet-wallet

# Install dependencies
npm install

# Build the extension
npm run build

Load in Browser

  1. Open Chrome/Brave
  2. Navigate to chrome://extensions/
  3. Enable Developer mode
  4. Click Load unpacked
  5. Select the build/ directory

Development Mode

# Run in watch mode
npm run dev

πŸ’‘ Example User Flow

  1. Developer installs extension
  2. On launch, wallet auto-generates EVM & Solana keys (in memory)
  3. Developer selects "Sepolia" or "Solana Devnet"
  4. Clicks Get Test Tokens to fund wallet
  5. Deploys contracts or runs CI tests
  6. Closes browser β†’ keys wiped

🎨 Design Guidelines

  • Tailwind CSS + Inter font
  • Developer-centric dark theme
  • Rounded corners (2xl), soft shadows, large padding
  • Animated banner "TESTNET ONLY"

🧩 Future Extensions

  • Add Base Goerli, Linea, zkSync Testnet
  • Multi-account management
  • Built-in Solana airdrops button
  • Local node manager (start/stop Anvil)
  • Web dashboard for testnet analytics

πŸ“œ License

MIT – Open source for educational / developer testing purposes.


⚠️ Disclaimer

Never use with mainnet funds. This wallet is for testnets only.

This extension is designed exclusively for development and testing purposes. It includes safeguards to prevent mainnet usage, but developers should always exercise caution.


🀝 Contributing

Contributions are welcome! Please open an issue or submit a pull request.

Development Setup

npm install
npm run dev      # Development mode
npm run build    # Production build

πŸ§ͺ Testing with Smart Contracts

The contracts/ directory contains sample smart contracts to test the wallet's functionality:

Quick Start with Contracts

cd contracts
npm install
npm run compile

# Start local Hardhat node
npm run node

# Deploy contracts (in another terminal)
npm run deploy:local

Available Contracts

  1. SimpleStorage - Test basic transactions and state changes
  2. TestToken - ERC20 token for testing transfers
  3. Guestbook - Test string parameters and events

See contracts/README.md for detailed instructions.


οΏ½ Developer Tools

Generate Solana Keypair (JSON Format)

From the extension UI:

  1. Open the wallet popup β†’ Settings.
  2. Under Export Keys, click Show Private Keys.
  3. Press Download Solana Keypair (.json).

The browser downloads solana-wallet-keypair.json containing the Uint8Array representation that Solana CLI, Solana Playground, and other tools expect.

Prefer the command line? You can still run:

node scripts/generate-keypair.js YOUR_BASE64_SECRET_KEY

πŸ“– See docs/SOLANA_DEPLOY_GUIDE.md for full deployment guide.


οΏ½πŸ“š Documentation

Key Code Snippets

EVM Ephemeral Wallet

import { ethers } from "ethers";

export async function createEvmWallet(rpcUrl: string) {
  const provider = new ethers.providers.JsonRpcProvider(rpcUrl);
  const net = await provider.getNetwork();
  
  if (net.chainId === 1) throw new Error("Mainnet not allowed");
  
  return ethers.Wallet.createRandom().connect(provider);
}

Solana Ephemeral Wallet

import { Keypair, Connection } from "@solana/web3.js";

export function createSolanaWallet(cluster = "https://api.devnet.solana.com") {
  const connection = new Connection(cluster, "confirmed");
  const wallet = Keypair.generate();
  return { wallet, connection };
}

Prevent Mainnet

const BLOCKED = [1, 137, 56]; // Ethereum, Polygon, BSC mainnets

if (BLOCKED.includes(chainId) || cluster === "mainnet-beta") {
  throw new Error("Mainnet not supported");
}

πŸ™ Acknowledgments

Built with ❀️ for the blockchain developer community.


Made for testing. Built for developers. Never for mainnet.

About

Dev Wallet for Testing smart contract instead of using Meta mask Test-net option

Resources

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published