3

I am writing a contract that will interact with another contract: contract A will call a function defined by contract B. Is it possible to set the gas price that contract A is willing to pay when initiating the transaction that will call the function defined by contract B?

1 Answer 1

1

The call from Contract A to Contract B is sometimes referred to as an "internal transaction", but it's not really a transaction. It's more accurate to call it a call.

The call is part of the original transaction, so the miner has to decide whether to take the whole transaction or not. It follows that there is only one gas price for a transaction. You can set the maximum amount of gas used by a call, but not the price of one unit of gas.

If you really need to initiate a call from Contract A, but it needs to run code in Contract B with a different gas price, you need to get someone to actually send a transaction. A contract can trigger a transaction indirectly using the Ethereum Alarm clock or a similar mechanism: Contract A would send some money to the alarm clock contract, then some unknown person on the internet would call Contract B for you and collect the funds from the alarm clock.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.