Method: Eth::Client#deploy
- Defined in:
- lib/eth/client.rb
#deploy(contract) ⇒ String #deploy(contract, *args) ⇒ String #deploy(contract, *args, **kwargs) ⇒ String
Deploys a contract. Uses eth_accounts or external signer
if no sender key is provided.
Note, that many remote providers (e.g., Infura) do not provide
any accounts. Provide a sender_key: if you experience issues.
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 |
# File 'lib/eth/client.rb', line 233 def deploy(contract, *args, **kwargs) raise ArgumentError, "Cannot deploy contract without source or binary!" if contract.bin.nil? raise ArgumentError, "Missing contract constructor params!" if contract.constructor_inputs.length != args.length data = contract.bin unless args.empty? data += encode_constructor_params(contract, args) end gas_limit = if kwargs[:gas_limit] kwargs[:gas_limit] else Tx.estimate_intrinsic_gas(data) + Tx::CREATE_GAS end params = { value: 0, gas_limit: gas_limit, chain_id: chain_id, data: data, } send_transaction(params, kwargs[:legacy], kwargs[:sender_key], kwargs[:nonce]) end |