diff --git a/apps/explorer/lib/explorer/smart_contract/reader.ex b/apps/explorer/lib/explorer/smart_contract/reader.ex index 16adc3b92a..3f20119eee 100644 --- a/apps/explorer/lib/explorer/smart_contract/reader.ex +++ b/apps/explorer/lib/explorer/smart_contract/reader.ex @@ -254,8 +254,16 @@ defmodule Explorer.SmartContract.Reader do response = Integer.parse(item) case response do - {integer, remainder_of_binary} when remainder_of_binary == "" -> integer - _ -> item + {integer, ""} -> + hex_encoding = + integer + |> :binary.encode_unsigned() + |> Base.encode16(case: :lower) + + "0x" <> hex_encoding + + _ -> + item end end diff --git a/apps/explorer/test/explorer/smart_contract/reader_test.exs b/apps/explorer/test/explorer/smart_contract/reader_test.exs index 8d9d27c288..188570607a 100644 --- a/apps/explorer/test/explorer/smart_contract/reader_test.exs +++ b/apps/explorer/test/explorer/smart_contract/reader_test.exs @@ -214,10 +214,12 @@ defmodule Explorer.SmartContract.ReaderTest do describe "normalize_args/1" do test "converts argument when is a number" do - assert [0] = Reader.normalize_args(["0"]) + assert ["0x00"] = Reader.normalize_args(["0"]) assert ["0x798465571ae21a184a272f044f991ad1d5f87a3f"] = Reader.normalize_args(["0x798465571ae21a184a272f044f991ad1d5f87a3f"]) + + assert ["0x7b"] = Reader.normalize_args(["123"]) end test "converts argument when is a boolean" do