Class: Faker::Blockchain::Ethereum

Inherits:
Faker::Base show all
Defined in:
lib/faker/blockchain/ethereum.rb

Constant Summary

Constants inherited from Faker::Base

Faker::Base::LLetters, Faker::Base::Letters, Faker::Base::NOT_GIVEN, Faker::Base::Numbers, Faker::Base::ULetters

Class Method Summary collapse

Methods inherited from Faker::Base

bothify, disable_enforce_available_locales, fetch, fetch_all, flexible, generate, letterify, method_missing, numerify, parse, rand, rand_in_range, regexify, resolve, respond_to_missing?, sample, shuffle, translate, unique, with_locale

Class Method Details

.addressString

Produces a random Ethereum wallet address

Examples:

Faker::Blockchain::Ethereum.address
  #=> "0xd392b0c0500700d02d27ab30805ec80ddd3320ff"

Returns:

  • (String)

Available since:

  • 1.9.1



17
18
19
20
21
22
# File 'lib/faker/blockchain/ethereum.rb', line 17

def address
  hex_alphabet = '0123456789abcdef'
  var = +'0x'
  40.times { var << sample(shuffle(hex_alphabet.chars)) }
  var
end