https://www.inco.org/ logo
Hi, sorry for the delayed response! No, CPI won't ...
# 💻│dev-chat
d
Hi, sorry for the delayed response! No, CPI won't panic if insufficient balance, that's the key thing about confidential transfers. With Inco's encrypted operations, the transfer uses e_select internally:
Copy code
let has_sufficient = e_ge(balance, amount)?;
let actual_amount = e_select(has_sufficient, amount, zero)?;  // Transfer amount OR zero
balance = e_sub(balance, actual_amount)?;
If the customer doesn't have enough, actual_amount becomes zero, the transaction still succeeds, just with nothing transferred. The problem for your NFT shop, you can't know on-chain whether the payment actually went through! The transfer "succeeds" either way. Check balance first, then transfer:
let has_funds: Ebool = e_ge(cpi_ctx, customer_balance, price, 0)?;
// Store has_funds handle, require customer to prove they paid Use attested decrypt for verification: After transfer, customer decrypts their has_funds result Submit proof on-chain via is_validsignature Only then transfer NFT Hope u undertand what I am trying to say?!