Overspend error on contract's inner tx

Hello fellow algorand lovers:

Im in my first weeks understanding the algorand blockchain and while testing a contract I came across this error.

The error is the following and occurs in an inner tx of the contract:

HTTP 400: {"message":"TransactionPool.Remember: transaction QEJX3677O22W5NHHLIM2ME7ROUWXFMLBXE7ZJLVZHM54X6JQE22Q: logic eval error: overspend (account JVKH57LFBSAZS5GMIJWRP6HCYO67YVKHEFUZACVW5HPEKT7YRP5HAWIIAU, data {AccountBaseData:{Status:Offline MicroAlgos:{Raw:1280411} RewardsBase:2668 RewardedMicroAlgos:{Raw:411} AuthAddr:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAY5HFKQ TotalAppSchema:{_struct:{} NumUint:0 NumByteSlice:0} TotalExtraAppPages:0 TotalAppParams:0 TotalAppLocalStates:0 TotalAssetParams:0 TotalAssets:0} VotingData:{VoteID:[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] SelectionID:[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] StateProofID:[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] VoteFirstValid:0 VoteLastValid:0 VoteKeyDilution:0}}, tried to spend {1552000}). Details: pc=256, opcodes=intc_1 // 0\nitxn_field Fee\nitxn_submit\n"}

The situation is like this:

Im interacting with the contract with a group tx (one appl tx and one pay tx). I’m doing transaction pooling to pay the fee of the inner tx of the contract. If the contract account balance is higher than the amount to pay in the inner tx is all good, but if the balance (the contract’s account balance) is lower I get this error, even if the sender’s amount is enough to pay the tx. So my question is: Does the contract account have to hold enough money to pay for the inner tx amount? Can’t I just enable some pooling like with the tx fee?

Another way of describing it:
Should this be valid?
The receiver needs to receive 2 ALGO

SENDER ----> CONTRACT ----> INNER TX ----> RECEIVER

  • sender tx amount 2 ALGO + pooling tx fee
  • contract balance 0.1 ALGO

Regards

PD: Maybe my assumption of the error is completely wrong but so far this is my conclusion.

Indeed, pooling is only for fees.
Inner transactions can only come from the application account* and cannot come from the sender.
You need the sender to send tokens to the application account beforehand if you need to use those.

*Note: technically it’s any account authorized by the application account, which is the application account itself and any account rekeyed to it.