Skip to content

send_transaction fails to format call data #20

@thunef

Description

@thunef

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions