Method: Eth::Client#transact
- Defined in:
- lib/eth/client.rb
#transact(contract, function) ⇒ Object #transact(contract, function, *args) ⇒ Object #transact(contract, function, *args, **kwargs) ⇒ Object
Executes a contract function with a transaction (transactional contract read/write).
Note, that many remote providers (e.g., Infura) do not provide
any accounts. Provide a sender_key: if you experience issues.
319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 |
# File 'lib/eth/client.rb', line 319 def transact(contract, function, *args, **kwargs) gas_limit = if kwargs[:gas_limit] kwargs[:gas_limit] else Tx.estimate_intrinsic_gas(contract.bin) end params = { value: kwargs[:tx_value] || 0, gas_limit: gas_limit, chain_id: chain_id, to: kwargs[:address] || contract.address, data: contract.function(function, args: args.size).encode_call(*args), } send_transaction(params, kwargs[:legacy], kwargs[:sender_key], kwargs[:nonce]) end |