Home/Blockchain/Wallet Connect Demo/Transaction Signing
โ†
Previous Module
Role-based DAO Permissions

๐Ÿ“ Transaction Signing: Mobile Approval

Discover how transactions are sent to mobile wallets for approval

Integrate Web3 wallets into your dApp

๐Ÿ“ Transaction Signing & Gas Estimation

Transaction signing is where things cost money. Unlike message signing (free), transactions modify blockchain state and require gas fees. When users click "Swap" on Uniswap or "Mint" on OpenSea, their wallet shows: transaction details, gas estimate, total cost. Users review, approve, and sign. The signed transaction is then broadcast to the network. Let's simulate the full flow.

๐ŸŽฎ Interactive: Transaction Approval Flow

Select a transaction type, review the details (like users see in MetaMask), adjust gas, and sign. Watch the transaction go from pending to confirmed.

Choose Transaction Type

โ›ฝ Understanding Gas

Gas Limit

Maximum gas you're willing to use. Simple transfer: 21,000. Token swap: 180,000. If actual usage is less, you get refund. Set too low = transaction fails, you still pay.

Gas Price (Gwei)

How much you pay per unit of gas. Higher price = faster confirmation (miners prioritize high-paying txs). 1 Gwei = 0.000000001 ETH. Typical: 20-50 Gwei.

Total Cost Formula

Gas Cost = Gas Used ร— Gas Price
Example: 21,000 ร— 25 Gwei = 0.000525 ETH (~$1 at $2000/ETH). Plus transaction value.

EIP-1559 (Modern)

Base fee (burned) + priority fee (to miner). Base fee adjusts per block. Users set max fee willing to pay. Wallet estimates for you. More predictable than legacy gas pricing.

๐Ÿ” Transaction Security

Always Verify Contract Address

Scammers create fake Uniswap clones at different addresses. Check "To" field matches official contract. Use verified addresses from Etherscan or official docs.

Review Token Approvals

"Approve" transactions let contracts spend your tokens. Malicious contracts can drain approved tokens. Only approve trusted contracts. Use revoke.cash to audit/revoke old approvals.

Check Transaction Simulation

Tools like Tenderly or MetaMask simulate transactions before signing. Shows expected outcome: "You receive 2000 USDC, send 1 ETH". If simulation shows unexpected transfers, REJECT.

๐Ÿ’ก Key Insight

Transaction signing is the highest-risk moment in Web3 UX. Users must review: recipient address, value, data (function call), and gas costโ€”all in ~10 seconds. Mistakes are irreversible. This is why good dApps show clear transaction previews: "Swap 1 ETH โ†’ 2000 USDC" instead of raw hex data. Modern wallets (MetaMask, Rabby) add transaction simulation and security warnings. But ultimately, users must verify everything. As a developer, your job is to make transactions as transparent as possible: decode data, show expected outcomes, warn about approvals. Trust but verifyโ€”because on blockchain, there's no undo button.

โ† Signing Messages