Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

send_transaction fails to format call data #20

Open
thunef opened this issue Jun 10, 2020 · 1 comment
Open

send_transaction fails to format call data #20

thunef opened this issue Jun 10, 2020 · 1 comment

Comments

@thunef
Copy link

thunef commented Jun 10, 2020

This function sends invalid data to the client:

** (MatchError) no match of right hand side value: {:error, %{"code" => -32602, "message" => "invalid argument 0: json: cannot unmarshal hex string without 0x prefix into Go value of type hexutil.Bytes"}}
    (eth 0.5.0) lib/eth/transaction.ex:88: ETH.Transaction.send_transaction!/2

This is the relevant code. The transaction is signed, then hex encoded.

def send_transaction(params, private_key) do
    set_default_from(params, private_key)
    |> build
    |> sign_transaction(private_key)
    |> Base.encode16()
    |> send
end

By prepending 0x to the transaction, geth is happy.

 def send_transaction(params, private_key) do
    set_default_from(params, private_key)
    |> build
    |> sign_transaction(private_key)
    |> Base.encode16()
    |> (fn transaction -> "0x" <> transaction end).()
    |> send
  end

Right now we are using an infura endpoint. The errors comes from geth in this case.

Are we doing something wrong, or infura, or is this a bug in this library?

We would be happy to supply a PR for the latter.

Thanks in advance!

@izelnakri
Copy link
Owner

izelnakri commented Oct 18, 2020

Hi @thunef , thanks for bringing this up! I'm also not sure since every ethereum client seems to provide their own implementation, not sure if this is indicated in the yellow paper or EIP. Today I also read a PR regarding a similar mismatch: #18

When I built this library, it was the only option to send ethereum transactions from elixir, and most clients didnt provide a mature test environment to run code against their CLI.

I'm willing to have a complex github action/CI workflow that target mature ethereum clients as long as they provide testing environment. Lately parity provides one I suppose. Then we can fix these mismatches between ethereum clients. Please let me know if you would like to contribute, I can add you as a maintainer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants