hswick / exw3

High level Ethereum RPC Client for Elixir
Apache License 2.0
151 stars 45 forks source link

Issue with calling smart contract #152

Closed yashh closed 4 months ago

yashh commented 1 year ago
ExW3.Contract.start_link()
ExW3.Contract.register(:Contract, abi: ExW3.Abi.load_abi("path/to/abis/erc721.json"))
ExW3.Contract.at(:Contract, "0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d")
url = Spool.Chain.Helpers.get_endpoint_for_network(1)
Application.put_env(:ethereumex, :url, url)
ExW3.Contract.call(:Contract, :symbol)
[error] GenServer ContractManager terminating
** (MatchError) no match of right hand side value: <<0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0>>
    (ex_abi 0.5.16) lib/abi/type_decoder.ex:238: ABI.TypeDecoder.decode_bytes/4
    (ex_abi 0.5.16) lib/abi/type_decoder.ex:327: anonymous fn/3 in ABI.TypeDecoder.decode_type/3
    (elixir 1.14.1) lib/enum.ex:2468: Enum."-reduce/3-lists^foldl/2-0-"/3
    (ex_abi 0.5.16) lib/abi/type_decoder.ex:325: ABI.TypeDecoder.decode_type/3
    (ex_abi 0.5.16) lib/abi/type_decoder.ex:188: anonymous fn/3 in ABI.TypeDecoder.do_decode_raw/2
    (elixir 1.14.1) lib/enum.ex:2468: Enum."-reduce/3-lists^foldl/2-0-"/3
    (ex_abi 0.5.16) lib/abi/type_decoder.ex:185: ABI.TypeDecoder.do_decode_raw/2
    (ex_abi 0.5.16) lib/abi/type_decoder.ex:179: ABI.TypeDecoder.decode_raw/2
    (exw3 0.6.1) lib/exw3/abi.ex:52: ExW3.Abi.decode_output/3
    (exw3 0.6.1) lib/exw3/contract.ex:214: ExW3.Contract.eth_call_helper/4
    (exw3 0.6.1) lib/exw3/contract.ex:480: ExW3.Contract.handle_call/3
    (stdlib 4.1.1) gen_server.erl:1149: :gen_server.try_handle_call/4
    (stdlib 4.1.1) gen_server.erl:1178: :gen_server.handle_msg/6
    (stdlib 4.1.1) proc_lib.erl:240: :proc_lib.init_p_do_apply/3
Last message (from #PID<0.840.0>): {:call, {:Contract, :symbol, []}}

https://github.com/hswick/exw3/pull/153

Here is a quick fix