feat: add multi-network single signer example#244
Open
dicethedev wants to merge 1 commit intoalloy-rs:mainfrom
Open
feat: add multi-network single signer example#244dicethedev wants to merge 1 commit intoalloy-rs:mainfrom
dicethedev wants to merge 1 commit intoalloy-rs:mainfrom
Conversation
- Demonstrates using one signer across multiple EVM networks - Shows Ethereum, Optimism, and Arbitrum Sepolia testnets - Includes balance checking on each network - References issue alloy-rs#54
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Closes #54
This PR adds a comprehensive example demonstrating how to use a single signer across multiple EVM-compatible networks. The example was specifically requested to show:
PrivateKeySignerthat can be reused across different networksThis addresses a common use case for developers building multi-chain applications who need to understand how to efficiently manage signers across different EVM networks without creating separate signers for each chain.
Solution
Overview
Added
multi_network_signer.rstoexamples/transactions/examples/which demonstrates:PrivateKeySignerfrom an environment variable and clones it for use with multiple providersAnyNetworkgasUsedForL1andl1BlockNumberl1Fee,l1GasUsed, andl1GasPriceKey Features
Code Structure
How to Test
Expected behavior: The example will connect to each network, check balance, send a transaction if funded, and display network-specific receipt fields.
Testing
Tested successfully on all three networks:
Ethereum Sepolia:
Optimism Sepolia:
Arbitrum Sepolia:
All transactions confirmed within 30-60 seconds. The same signer worked seamlessly across all networks, demonstrating the power of EVM compatibility.
Related Examples
This example builds upon the existing
any_network.rsexample (as suggested by maintainers) and expands it to show practical multi-network usage with transaction sending, which was the primary request in issue #54.PR Checklist
Additional Notes
Future Enhancements (can be separate PRs if desired):
remove_liquidityrequest)Dependencies Added:
serdewithderivefeature for deserializing network-specific receipt fieldsenv_loggerfor optional debug loggingtokiotimefeature for rate limitingI'm happy to make any adjustments based on feedback!