My question is: is it possible to pay the execution cost of a SC with the ether stored in the SC itself?
However, this isn't a straightforward thing to do, and will require that the smart contract be written in such a way that miners can be paid directly rather than via the gas costs.
Someone with more experience of constructing such transactions would be better placed to answer, but what it boils down to is the following:
- The transaction is submitted with a gas price of 0
- The contract being executed can reward the miner by paying the
block.coinbase address, which is the address of the miner that is set when the block is mined. Payment is therefore made from the contract to the miner.
There are APIs available from the FlashBots project that enable such transactions to be submitted to miners that run the relevant client implementation.
For a broader background in MEV (Miner-Extractable Value), see this previous answer:
For an equivalent mechanism in rewarding miners with tokens, see OpenZeppelin's Rewarding Miners.