This Rust application generates a new address for the Ethereum network. It creates a private-public key pair and then derives an Ethereum address from this pair. If the generated address starts with a specific prefix (e.g., "0x123456"), the address and the keys are saved into a file named addresses.json
.
anyhow
secp256k1
tiny_keccak
web3
serde_json
tokio
std
First, clone the project:
git clone https://github.com/codeesura/Ethereum-address-generator-rust.git
cd Ethereum-address-generator-rust
Then, install the dependencies:
cargo build && cargo run
While in the project's main directory, run the application with:
-
Key Pair Generation and Address Calculation:
- A new
secp256k1
object is instantiated withSecp256k1::new()
. - A timestamp function is defined to create a Random Number Generator (RNG).
- A key pair (
secret_key
andpub_key
) is generated using this RNG. - The
public_key_address
function derives an Ethereum address from the givenPublicKey
object.
- A new
-
Filtering Part:
- The generated Ethereum address is checked to see if it starts with a specific prefix (e.g., "0x123456").
- If this condition is met, the address and the associated keys are converted into a JSON object.
-
Reading and Writing to File:
- The
addresses.json
file is read, and the existing data is fetched. - The newly created JSON object is appended to this data.
- The updated data is written back into the
addresses.json
file.
- The
If you would like to contribute to the project, please open an issue first. Pull Requests (PRs) are always welcome.
This project is licensed under the MIT License.