Skip to content

Checksummed Addresses

Afr Schoe edited this page Feb 8, 2022 · 2 revisions

To handle, verify, and checksum addresses, just instantiate an ::Address object and the gem will handle the rest.

address = Eth::Address.new "0x0c53ffa57ec554451315c2568d22477db8e71356"
# => #<Eth::Address:0x0000558e550ac588 @address="0x0c53ffa57ec554451315c2568d22477db8e71356">

Is it valid?

address.valid?
# => true

Get the checksummed address string (EIP-55).

address.to_s
# => "0x0c53FFA57Ec554451315c2568d22477dB8e71356"

That's it and should be preferred over just using address strings.

Clone this wiki locally