Skip to content

Misagh95/nbase

Repository files navigation

nBase — Zero-Cost ERC20 Token Factory

Deploy gas-optimized ERC20 tokens on Base Mainnet for under $0.001 using EIP-1167 minimal proxies.

~55k gas
per token
~$0.001
at 1 gwei
EIP-1167
minimal clones
No allowance
mapping removed

How it works

  1. Factory (contracts/sources/TokenFactory.sol) deploys ERC20 tokens via create2-style minimal proxies.
  2. Each token is a clone of a single implementation contract (TokenImpl.sol), keeping deployment costs negligible.
  3. The contract is aggressively optimized — hardcoded decimals = 18, no allowance mapping, Solidity optimizer at 100k runs.

Smart contracts

Contract Purpose
TokenImpl.sol Minimal ERC20 implementation (name, symbol, totalSupply, transfer, decimals)
TokenFactory.sol Factory that clones TokenImpl for each user request, collects a creation fee

The factory is deployed on Base Mainnet at 0x94577897a3DaD59bD62c2F47c218e8bB2A02477b.


Frontend

A Next.js 16 app with wagmi + viem for wallet connection and contract interaction.

Route Description
/ Landing page
/token-factory Connect wallet, choose network, and deploy a token in one click

Features

  • Connect via MetaMask (or any injected wallet)
  • Switch between Base Mainnet / Base Sepolia
  • Deploy a token with name, symbol, and total supply
  • View all tokens deployed from your account
  • Copy contract address / open on BaseScan

Getting started

git clone <repo-url>
cd nbase
npm install

Environment

cp .env.example .env.local

Fill in your factory address and optional database URL:

NEXT_PUBLIC_FACTORY_ADDRESS=0x94577897a3DaD59bD62c2F47c218e8bB2A02477b
DATABASE_URL=postgresql://user:password@host:5432/db

Development

npm run dev -- --webpack    # Windows (Turbopack not supported)
npm run dev                  # Linux / macOS

Build

npm run build

Deploying contracts

Remix (quick)

  1. Open contracts/sources/TokenImpl.sol in Remix
  2. Compile with Solidity 0.8.24, optimizer enabled (100k runs)
  3. Deploy TokenFactory.sol with your chosen creation fee (e.g. 0.000001 ETH = 1000000000000 wei)

Hardhat

cd contracts
npm install
npx hardhat run scripts/deploy.js --network base

Update the resulting factory address in .env.localNEXT_PUBLIC_FACTORY_ADDRESS.


Deploying the frontend

# Push to Vercel
vercel --prod --yes

# Rename project (optional)
vercel project rename <old-name> <new-name>

The app automatically reads NEXT_PUBLIC_FACTORY_ADDRESS at build time.


Project structure

nbase/
├── contracts/
│   ├── sources/
│   │   ├── TokenImpl.sol          # Minimal ERC20 implementation
│   │   └── TokenFactory.sol       # EIP-1167 clone factory
│   ├── hardhat.config.js
│   └── scripts/deploy.js
├── src/
│   ├── app/
│   │   ├── api/                   # Serverless API routes
│   │   ├── token-factory/         # Token factory page
│   │   └── layout.tsx             # Root layout with nav
│   ├── components/
│   │   ├── providers/             # Wagmi + Web3 providers
│   │   └── token-factory.tsx      # Main factory component
│   └── lib/
│       ├── deployment.ts          # ABIs, chain config, factory address
│       └── wagmi.ts               # Wagmi configuration
├── .env.example
└── README.md

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages