EthWallet.Transaction (eth_wallet v0.1.1)

Tx about Ethereum.

Summary

Types

@type t() :: %EthWallet.Transaction{
  data: binary(),
  gas_limit: integer(),
  gas_price: integer(),
  init: binary(),
  nonce: integer(),
  r: integer(),
  s: integer(),
  to: <<_::160>> | <<_::0>>,
  v: integer(),
  value: integer()
}

Functions

Link to this function

build_tx(to_str, value, data, nonce, gas_price, gas_limit)

Link to this function

encode_unsigned(n)

@spec encode_unsigned(number()) :: binary()

iex(80)> :binary.encode_unsigned(12345)

"09"

iex(81)> "09" <> <<0>>

<<48, 57, 0>>

iex(83)> 48 * 256 + 57

12345

Link to this function

hash_for_signing(tx, chain_id \\ nil)

@spec hash_for_signing(t(), integer() | nil) :: binary()
Link to this function

serialize(tx, include_vrs \\ true)

@spec serialize(t(), boolean()) :: ExRLP.t()
Link to this function

sign_tx(tx, private_key, chain_id \\ nil)

@spec sign_tx(t(), binary(), integer() | nil) :: t()

https://b10c.me/blog/006-evolution-of-the-bitcoin-signature-length/

https://bitcoin.stackexchange.com/questions/12554/why-the-signature-is-always-65-13232-bytes-long

Bitcoin: 0x30 [total-length] 0x02 [R-length] [R] 0x02 [S-length] [S]

Attetion: SigHash Flag should be append to the last in finally signature.

Ethereum: R <> S <> V (V = recid + chainID * 2 + 35)

Link to this function

signed_tx_to_raw_tx(signed_tx)

@spec signed_tx_to_raw_tx(t()) :: String.t()