4
0
Fork 0

use ExthCrypto.Hash.Keccak.kec instead of web3_sha3

pull/5/head
Deon 7 years ago
parent 910e2ad66e
commit 67db4310c9
No known key found for this signature in database
GPG Key ID: 5292459838C9BC58
  1. 8
      lib/exw3.ex

@ -28,9 +28,11 @@ defmodule ExW3 do
def to_checksum_address(address) do
address = String.replace(address, ~r/^0x/, "")
{:ok, hash} = Ethereumex.HttpClient.web3_sha3(String.downcase(address))
non_prefix_hash = String.replace(hash, ~r/^0x/, "")
keccak_hash_list = non_prefix_hash
hash = ExthCrypto.Hash.Keccak.kec(String.downcase(address))
|> Base.encode16(case: :lower)
|> String.replace(~r/^0x/, "")
keccak_hash_list = hash
|> String.split("", trim: true)
|> Enum.map(fn (x) -> elem(Integer.parse(x, 16),0) end)

Loading…
Cancel
Save