EthWallet.Transaction (eth_wallet v0.0.13)

Tx about Ethereum.

Link to this section Summary

Link to this section Types

Specs

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()
}

Link to this section Functions

Link to this function

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

Link to this function

encode_unsigned(n)

Specs

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)

Specs

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

serialize(tx, include_vrs \\ true)

Specs

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

sign_tx(tx, private_key, chain_id \\ nil)

Specs

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)

Specs

signed_tx_to_raw_tx(t()) :: String.t()