Skip to content

TehilaFavourite/hello-blockchain-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

hello-blockchain-cli

This tool is a simple command-line Ethereum address validator written in Rust that checks whether a given address has a valid 0x prefix, correct length, and valid hexadecimal characters.

Installation

Clone the repository, make sure Rust is installed, then run the program using Cargo with a single argument: cargo run -- <ethereum_address> Example:

cargo run -- 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045

Examples

A valid input prints a success message to standard output and returns exit code 0: Valid address: 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045 An invalid input prints an error message to standard error and returns exit code 1: Invalid address: 0x123invalidaddress...

What I Learned

This project reinforced that string slices (&str) are borrowed references, meaning we can pass around and validate data without taking ownership of the String, avoiding unnecessary cloning and making the program more efficient. A proper CLI tool must validate input before accessing it, handle missing arguments gracefully, and separate normal output (stdout) from error messages (stderr) while using exit codes to communicate success or failure to the operating system.

About

Takes an Ethereum address, validates the format, prints formatted output.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors