I'm doing a flash loan request and trying to emit some debug information using events out of the function, but I haven't seen those messages emitted on the arbitrum block explorer or been able to retrieve them. It's almost like they're not being sent. In most of my test cases, the flashloan has failed in the payback part--and my understanding is that the transaction gets rolled back, but does that include previous emits? And if so, is there a way to get this information on what was done prior to the rollback. I'm struggling for a way to debug this while on the arbitrum mainnet. console.log doesn't seem to work either.

// SPDX-License-Identifier: MIT
pragma solidity 0.8.24;

import {FlashLoanSimpleReceiverBase} from "@aave/core- 
import {IPoolAddressesProvider} from "@aave/core- 
import {IERC20} from "@aave/core- 

contract FLASend is FlashLoanSimpleReceiverBase {

address payable owner;

constructor(address _addressProviderFlashLoanProviderPool)
FlashLoanSimpleReceiverBase(IPoolAddressesProvider(_addressProviderFlashLoanProviderPool)) {
    owner = payable(msg.sender);       

function requestFlashLoan(address _loanTokenAddress, uint256 _loanTokenAmount) public {
    address receiverAddress = address(this);
    address asset = _loanTokenAddress;
    uint256 amount = _loanTokenAmount;
    bytes memory params = "";
    uint16 referralCode = 0;
    emit LendAddress(block.timestamp, address(this), "Flash Loan Requested--Loan Token Address", asset);
    emit LendNumeric(block.timestamp, address(this), "Flash Loan Requested--Loan Amount", amount);
    emit LendAddress(block.timestamp, address(this), "Flash Loan Requested--Loan Amount", receiverAddress);


    emit LendString(block.timestamp, address(this), "Flash Loan Received", "INFO");


    This function is called after your contract has received the flash loaned amount
function executeOperation(
    address asset,
    uint256 amount,
    uint256 premium,
    address initiator,
    bytes calldata params
) external override returns (bool) {
    uint256 token1Balance = 0; 
    uint256 i = 0;
    bool lastSwap = false;

    // At the end of your logic above, this contract owes
    // the flashloaned amount + premiums.
    // Therefore ensure your contract has enough to repay
    // these amounts.

    // I have logic here that is currently failing to payback the loan.    

    emit LendString(block.timestamp, address(this), "Flash will fail on payback", "INFO");

    // Approve the Pool contract allowance to *pull* the owed amount
    uint256 amountOwed = amount + premium;
    IERC20(asset).approve(address(POOL), amountOwed);

    return true;

function getBalance(address _tokenAddress) external view returns (uint256) {
    return IERC20(_tokenAddress).balanceOf(address(this));

function withdraw(address _tokenAddress) external onlyOwner {
    IERC20 token = IERC20(_tokenAddress);
    token.transfer(msg.sender, token.balanceOf(address(this)));

modifier onlyOwner() {
        msg.sender == owner,
        "Only the contract owner can call this function"

event LendAddress(uint256 timestamp, address sourceAddress, string message, address addressValue);
event LendNumeric(uint256 timestamp, address sourceAddress, string message, uint numericValue); 
event LendString(uint256 timestamp, address sourceAddress, string message, string stringValue);

receive() external payable {}

1 Answer 1


Yeah, events emitted are rolled back if the tx reverts, that's why they aren't shown.

You can use this explorer https://app.blocksec.com/explorer/ to debug a failed transaction, it shows the rolled back events in the "Invocation Flow" tab alongside other useful information.

  • Thank you so much. And your explanation totally makes sense--I thought that was happening because I literally couldn't see anything that happened, but I think your solution will help a lot! Cheers! Commented May 7 at 0:18

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.