|
| 1 | +# ERC20 Multisend Template |
| 2 | + |
| 3 | +A browser-only React + Vite template for sending one ERC20 token to many |
| 4 | +recipients with Uniswap Permit2. |
| 5 | + |
| 6 | +The app lets a sender choose any ERC20 token on the configured network, approve |
| 7 | +Permit2 once for that token, paste or upload recipient rows, and send the batch |
| 8 | +with one Permit2 signature plus one transaction. |
| 9 | + |
| 10 | +## Features |
| 11 | + |
| 12 | +- Any ERC20 token address can be entered in the UI. |
| 13 | +- Recipient rows use a strict `address,amount` format with no header row. |
| 14 | +- Duplicate recipients are detected before sending. |
| 15 | +- Balance, allowance, gas, and block-limit checks run before broadcast. |
| 16 | +- No backend, no server-held keys, and no token-specific config. |
| 17 | +- Ready for Vercel or Cloudflare Workers static-assets deployment. |
| 18 | + |
| 19 | +## Important Security Note |
| 20 | + |
| 21 | +This template is not audited. It is useful starter code, but you should review |
| 22 | +and test it before using valuable tokens. The setup step grants Permit2 a high |
| 23 | +allowance for the selected token. Users can revoke that allowance later with a |
| 24 | +wallet or allowance management tool. |
| 25 | + |
| 26 | +## How It Works |
| 27 | + |
| 28 | +1. Connect an injected wallet such as MetaMask. |
| 29 | +2. Enter an ERC20 token contract address on the selected network. |
| 30 | +3. The app reads token metadata, balance, and the wallet's Permit2 allowance. |
| 31 | +4. Approve Permit2 once with standard ERC20 `approve`. |
| 32 | +5. Paste or upload recipient rows. |
| 33 | +6. Sign the Permit2 batch transfer and submit one transaction. |
| 34 | + |
| 35 | +Private keys stay in the wallet. The app runs fully in the browser. |
| 36 | + |
| 37 | +## Recipient Format |
| 38 | + |
| 39 | +Use one recipient per line with two comma-separated values: recipient address, |
| 40 | +then token amount. |
| 41 | + |
| 42 | +```csv |
| 43 | +0x0000000000000000000000000000000000000000,100 |
| 44 | +0x1111111111111111111111111111111111111111,250.5 |
| 45 | +``` |
| 46 | + |
| 47 | +Do not include a header row. Every non-empty row is parsed as a recipient row. |
| 48 | + |
| 49 | +## Permit2 Flow |
| 50 | + |
| 51 | +The template uses the canonical Uniswap Permit2 contract: |
| 52 | + |
| 53 | +```text |
| 54 | +0x000000000022D473030F116dDEE9F6B43aC78BA3 |
| 55 | +``` |
| 56 | + |
| 57 | +Generic ERC20 tokens cannot be assumed to support EIP-2612 `permit`, so setup |
| 58 | +uses a normal ERC20 `approve(Permit2, max)` transaction. The actual multisend |
| 59 | +uses Permit2 `permitTransferFrom`: the sender signs typed data for the batch, |
| 60 | +then submits one transaction that transfers every row. |
| 61 | + |
| 62 | +## Local Development |
| 63 | + |
| 64 | +```bash |
| 65 | +npm ci |
| 66 | +cp .env.example .env |
| 67 | +npm run dev |
| 68 | +``` |
| 69 | + |
| 70 | +The default app runs on Ethereum Mainnet. Change `VITE_CHAIN` in `.env` to use |
| 71 | +another configured network. |
| 72 | + |
| 73 | +## Configuration |
| 74 | + |
| 75 | +`src/config.js` defines supported networks. The template currently includes: |
| 76 | + |
| 77 | +- `mainnet` |
| 78 | +- `sepolia` |
| 79 | + |
| 80 | +To add another EVM network, add a chain entry with: |
| 81 | + |
| 82 | +- `key` |
| 83 | +- `chainId` |
| 84 | +- `hexChainId` |
| 85 | +- `name` |
| 86 | +- `native` |
| 87 | +- `explorer` |
| 88 | + |
| 89 | +## Checks |
| 90 | + |
| 91 | +```bash |
| 92 | +npm test |
| 93 | +npm run build |
| 94 | +npm run audit:prod |
| 95 | +``` |
| 96 | + |
| 97 | +`npm run audit:prod` audits production dependencies only. Development tooling |
| 98 | +may report transitive audit warnings depending on the npm registry state. |
| 99 | + |
| 100 | +## Deployment |
| 101 | + |
| 102 | +Vercel works with the included `vercel.json`. |
| 103 | + |
| 104 | +For Cloudflare Workers static assets: |
| 105 | + |
| 106 | +```bash |
| 107 | +npm run build |
| 108 | +npm run deploy |
| 109 | +``` |
| 110 | + |
| 111 | +Set `VITE_CHAIN` in your hosting provider's environment variables if you do not |
| 112 | +want the default `mainnet` setting. |
| 113 | + |
| 114 | +## Repository Hygiene |
| 115 | + |
| 116 | +Do not commit: |
| 117 | + |
| 118 | +- `.env` files |
| 119 | +- private keys or API secrets |
| 120 | +- `node_modules` |
| 121 | +- `dist` |
| 122 | +- `.wrangler` |
| 123 | + |
| 124 | +## License |
| 125 | + |
| 126 | +MIT |
0 commit comments