class Faker::Blockchain::Tezos

Constants

PREFIXES

@private

Public Class Methods

account() click to toggle source

Produces a random Tezos account address

@return [String]

@example

Faker::Blockchain::Tezos.account
  #=> "tz1eUsgK6aj752Fbxwk5sAoEFvSDnPjZ4qvk"

@faker.version 1.9.2

# File lib/faker/blockchain/tezos.rb, line 31
def account
  encode_tz(:tz1, 20)
end
block() click to toggle source

Produces a random Tezos block

@return [String]

@example

Faker::Blockchain::Tezos.block
  #=> "BMbhs2rkY1dvAkAyRytvPsjFQ2RiPrBhYkxvWpY65dzkdSuw58a"

@faker.version 1.9.4

# File lib/faker/blockchain/tezos.rb, line 73
def block
  encode_tz(:B, 32)
end
contract() click to toggle source

Produces a random Tezos contract

@return [String]

@example

Faker::Blockchain::Tezos.contract
  #=> "KT1MroqeP15nnitB4CnNfkqHYa2NErhPPLWF"

@faker.version 1.9.2

# File lib/faker/blockchain/tezos.rb, line 45
def contract
  encode_tz(:KT1, 20)
end
operation() click to toggle source

Produces a random Tezos operation

@return [String]

@example

Faker::Blockchain::Tezos.operation
  #=> "onygWYXJX3xNstFLv9PcCrhQdCkENC795xwSinmTEc1jsDN4VDa"

@faker.version 1.9.2

# File lib/faker/blockchain/tezos.rb, line 59
def operation
  encode_tz(:o, 32)
end
public_key() click to toggle source

Produces a random Tezos public key

@return [String]

@example

Faker::Blockchain::Tezos.public_key
  #=> "edpkuib9x8QXRc5nWwHUg7U1dXsVmaUrUNU5sX9pVEEvwbMVdfMCeq"

@faker.version 2.15.2

# File lib/faker/blockchain/tezos.rb, line 101
def public_key
  encode_tz(:edpk, 32)
end
secret_key() click to toggle source

Produces a random Tezos public key

@return [String]

@example

Faker::Blockchain::Tezos.secret_key
  #=> "edsk3HZCAGEGpzQPnQUwQeFY4ESanFhQCgLpKriQw8GHyhKCrjHawv"

@faker.version 2.15.2

# File lib/faker/blockchain/tezos.rb, line 115
def secret_key
  encode_tz(:edsk, 32)
end
signature() click to toggle source

Produces a random Tezos signature

@return [String]

@example

Faker::Blockchain::Tezos.signature
  #=> "edsigu165B7VFf3Dpw2QABVzEtCxJY2gsNBNcE3Ti7rRxtDUjqTFRpg67EdAQmY6YWPE5tKJDMnSTJDFu65gic8uLjbW2YwGvAZ"

@faker.version 1.9.2

# File lib/faker/blockchain/tezos.rb, line 87
def signature
  encode_tz(:edsig, 64)
end

Protected Class Methods

encode_tz(prefix, payload_size) click to toggle source

@param prefix [Symbol] @param payload_size [Integer] The size of the payload

@return [String]

# File lib/faker/blockchain/tezos.rb, line 126
def encode_tz(prefix, payload_size)
  prefix = PREFIXES.fetch(prefix)
  packed = prefix.map(&:chr).join + Faker::Config.random.bytes(payload_size)
  checksum = OpenSSL::Digest::SHA256.digest(OpenSSL::Digest::SHA256.digest(packed))[0..3]
  Faker::Base58.encode(packed + checksum)
end