Transactions – Who Pays Gas When Multiple Smart Contracts Are Triggered?

chainlinkgas-pricetransactions

The scenario is when an EOA interacted with Function 1 from smart contract A. But in a single transaction, function 1 also makes calls to contract B, which makes calls to contract C.

Question 1: Would this EOA cover the gas invoked in the chain of functions(state-changing) upfront when signing in Metamask? In this case, contract A, B and C don't pay for gas.

Because this seems to contradict what I read on Chainlink's VRF direct funding cost calculation. (https://docs.chain.link/vrf/v2/direct-funding/)
This calculates the total gas cost when a consuming smart contract gets a random number but the gas is converted and charged in LINK Token additionally from the gas cost already paid in ETH upfront by an EOA who invokes the function. See chainlink's gas cost formula:
(Gas price * (Verification gas + Callback gas limit + Wrapper gas Overhead)) = total gas cost

Question 2: why is there additional gas charged to the consuming smart contract aside from the upfront gas paid by an EOA(signer)? Or this additional gas cost in LINK is only post-charged for Callback functions? If so, is there a way to avoid the chain of Callback functions to avoid extra gas costs? Thank you!

Best Answer

Question 1: The user initiating the transaction will pay for all of the gas accounted during the transaction, regardless of how many contracts interact.

Question 2: Using Vrf or any other Chainlink product requires interaction with the Chainlnk chain. This chain nodes offer the mentioned services, and paying with Link is the way to pay for these extra services.

Hope it helps

Related Topic