class Eth::Client
def transfer(destination, amount, **kwargs)
-
(String)
- the local transaction hash.
Parameters:
-
**nonce
(Integer
) -- optional specific nonce for transaction. -
**legacy
(Boolean
) -- enables legacy transactions (pre-EIP-1559). -
**sender_key
(Eth::Key
) -- the sender private key. -
amount
(Integer
) -- the transfer amount in Wei. -
destination
(Eth::Address
) -- the destination address. -
amount
(Integer
) -- the transfer amount in Wei. -
destination
(Eth::Address
) -- the destination address.
Overloads:
-
transfer(destination, amount, **kwargs)
-
transfer(destination, amount)
def transfer(destination, amount, **kwargs) params = { value: amount, to: destination, gas_limit: gas_limit, chain_id: chain_id, } if kwargs[:legacy] params.merge!({ gas_price: max_fee_per_gas, }) else params.merge!({ priority_fee: max_priority_fee_per_gas, max_gas_fee: max_fee_per_gas, }) end unless kwargs[:sender_key].nil? # use the provided key as sender and signer params.merge!({ from: kwargs[:sender_key].address, nonce: kwargs[:nonce] || get_nonce(kwargs[:sender_key].address), }) tx = Eth::Tx.new(params) tx.sign kwargs[:sender_key] return eth_send_raw_transaction(tx.hex)["result"] else # use the default account as sender and external signer params.merge!({ from: default_account, nonce: kwargs[:nonce] || get_nonce(default_account), }) return eth_send_transaction(params)["result"] end end