Web3SignerWebSocketProxy is a project that provides a WebSocket proxy for sending Ethereum transactions using a web-based interface.
-
Any Wallet: Implementations can construct transactions via scripts, but initiate transactions via any metamask/rabby-compatible wallet (Safe, Argus, hardware wallets, etc.).
-
No private key import: Sending transactions without importing the private key in web3.py avoids the possibility of some accidental private key leakage.
-
Foundy Support: This proxy can be used in foundy
--rpc-urlto be able to deploy contracts by signing them with a browser wallet (the native forge command arguments only support Trezor, ledger, and now more Remote wallets).
- Python 3.7+
- Node.js
- MetaMask or any other wallet extension that implements the Ethereum JSON-RPC Specification installed in your browser
-
Clone the repository:
git clone https://github.com/MobillsInMobild/Web3SignerWebSocketProxy cd Web3SignerWebSocketProxy -
Install Python wsProxy Module:
cd src pip install wsProxy/
-
Open
proxy.htmlin your browser by Live Server (Five Server) to access the web interface.To handle possible CORS issues, you may need to install the Cross Domain CORS Extension on your browser. -
Start
web3_demo.py:cd demo python web3_demo.py -
Sign transactions on your browser and check your signed transactions on the blockchain browser.
-
Open
proxy.htmlin your browser in the same way. -
Run wsServer:
python -m wsProxy.wsServer [network]
-
Use the
forge createcommand to deploy the contract. The contract used here is from the "Creating an NFT with Solmate" demo in the Foundry documentation. Note that the--rpc-urlconfiguration is infoundry.toml, specifically the WebSocket URL for wsProxy. Both--unlockand--fromare required command arguments.forge create NFT --rpc-url=proxy --unlocked --from [wallet_address] --constructor-args-path constructor-args.txt
-
Or use the
forge scriptcommand to deploy the contract.forge script script/NFT.s.sol --rpc-url=proxy --broadcast --sender=[wallet_address] --unlocked
-
Sign transactions on your browser and check your signed transactions on the blockchain browser.
- Open the web interface in your browser.
- Connect your MetaMask wallet.
- The WebSocket server will handle incoming transaction requests and forward them to the connected clients for signing.
src/: Contains the main source code.wsProxy/: WebSocket proxy module.proxy.html: Web interface for demonstrating transaction signing using the WebSocket proxy.
demo/: Contains demonstration code.web3_demo.py: Example showing how to use the WebSocket proxy for web3py signing.forge_demo/: Example showing how to use the WebSocket proxy for forge signing.foundry.toml: Foundry configuration file, including WebSocket URL and other settings.
README.md: Project documentation.
Issue: There is a potential bug in the system where, if a transaction signature takes too long, Forge may throw an error:
ERROR alloy_transport_ws: failed to deserialize message err=missing field
paramsat line 1 column 15
When this error occurs, Forge attempts to resend the transaction that is waiting to be signed.
Impact: Due to the nonce used in the transaction process, these duplicate transactions do not affect the actual transactions on the blockchain. At present, there seems to be no adverse effects.
- websockets - WebSocket library for Python
- ethers.js - Library for interacting with the Ethereum blockchain