Contents Menu Expand Light mode Dark mode Auto light/dark mode
Web3 Ethereum Defi documentation
Web3 Ethereum Defi documentation
  • API documentation
    • Core API
      • chain
        • POA_MIDDLEWARE_NEEDED_CHAIN_IDS
        • fetch_block_timestamp
        • has_graphql_support
        • install_api_call_counter_middleware
        • install_chain_middleware
        • install_retry_middleware
      • token
        • create_token
        • fetch_erc20_details
        • TokenDetails
        • TokenDetailError
      • balances
        • convert_balances_to_decimal
        • fetch_erc20_balances_by_token_list
        • fetch_erc20_balances_by_transfer_event
        • DecimalisedHolding
        • BalanceFetchFailed
      • abi
        • decode_function_args
        • encode_function_args
        • encode_function_call
        • encode_with_signature
        • get_abi_by_filename
        • get_contract
        • get_deployed_contract
        • get_linked_contract
        • get_transaction_data_field
        • humanise_decoded_arg_data
        • link_libraries_hardhat
      • deploy
        • deploy_contract
        • get_or_create_contract_registry
        • get_registered_contract
        • register_contract
        • ContractDeploymentFailed
      • event
        • fetch_all_events
      • gas
        • apply_gas
        • estimate_gas_fees
        • node_default_gas_price_strategy
        • GasPriceMethod
        • GasPriceSuggestion
      • confirmation
        • broadcast_and_wait_transactions_to_complete
        • broadcast_transactions
        • wait_transactions_to_complete
        • BroadcastFailure
        • ConfirmationTimedOut
      • revert_reason
        • fetch_transaction_revert_reason
        • TransactionReverted
      • hotwallet
        • HotWallet
        • SignedTransactionWithNonce
      • anvil
        • CLI_FLAGS
        • dump_state
        • fork_network_anvil
        • launch_anvil
        • load_state
        • make_anvil_custom_rpc_request
        • mine
        • revert
        • sleep
        • snapshot
        • unlock_account
        • AnvilLaunch
        • InvalidArgumentWarning
        • RPCRequestError
      • ganache
        • EVM_DEFAULT
        • fork_network
        • GanacheLaunch
        • InvalidArgumentWarning
        • NoGanacheInstalled
      • middleware
        • DEFAULT_RETRYABLE_EXCEPTIONS
        • DEFAULT_RETRYABLE_HTTP_STATUS_CODES
        • DEFAULT_RETRYABLE_RPC_ERROR_CODES
        • construct_sign_and_send_raw_middleware_anvil
        • exception_retry_middleware
        • http_retry_request_with_sleep_middleware
        • is_retryable_http_exception
        • raise_on_revert_middleware
      • tx
        • decode_signed_transaction
        • AssetDelta
        • DecodeFailure
      • trace
        • assert_call_success_with_explanation
        • assert_transaction_success_with_explanation
        • print_symbolic_trace
        • trace_evm_call
        • trace_evm_transaction
        • SymbolicTreeRepresentation
        • TraceMethod
        • TraceNotEnabled
        • TransactionAssertionError
      • eip_712
        • eip712_encode
        • eip712_encode_hash
        • eip712_signature
        • encode_data
        • encode_type
        • fast_keccak
        • find_type_dependencies
        • hash_struct
        • hash_type
      • utils
        • ZERO_ADDRESS_STR
        • is_localhost_port_listening
        • sanitise_string
        • shutdown_hard
        • to_unix_timestamp
    • USDC API
      • usdc.deployment
        • deploy_fiat_token
      • usdc.transfer_with_authorization
        • construct_receive_with_authorization_message
        • make_receive_with_authorization_transfer
    • Uniswap v2 DEX API
      • uniswap_v2.deployment
        • INIT_CODE_HASH_MISSING
        • deploy_factory_sushi
        • deploy_trading_pair
        • deploy_uniswap_v2_like
        • fetch_deployment
        • mock_partial_deployment_for_analysis
        • UniswapV2Deployment
      • uniswap_v2.pair
        • fetch_pair_details
        • PairDetails
      • uniswap_v2.fees
        • estimate_buy_price
        • estimate_buy_price_decimals
        • estimate_buy_quantity
        • estimate_buy_received_amount_raw
        • estimate_sell_price
        • estimate_sell_price_decimals
        • estimate_sell_received_amount_raw
        • UniswapV2FeeCalculator
        • BadReserves
      • uniswap_v2.analysis
        • analyse_trade_by_hash
        • analyse_trade_by_receipt
      • uniswap_v2.utils
        • ZERO_ADDRESS
        • pair_for
        • sort_tokens
      • uniswap_v2.swap
        • swap_with_slippage_protection
      • uniswap_v2.liquidity
        • get_liquidity
        • LiquidityResult
        • UnmatchedToken
      • uniswap_v2.oracle
        • convert_sync_log_result_to_price_entry
        • update_live_price_feed
        • update_price_oracle_with_sync_events_single_thread
        • UniswapV2PriceOracleContext
      • uniswap_v2.token_tax
        • estimate_token_taxes
        • TokenTaxInfo
        • ApprovalFailure
        • OutOfGasDuringSell
        • OutOfGasDuringTransfer
        • SellFailed
        • SwapError
        • TransferFailure
        • TransferFromError
    • Uniswap v3 DEX API
      • uniswap_v3.deployment
        • add_liquidity
        • decrease_liquidity
        • deploy_pool
        • deploy_uniswap_v3
        • deploy_uniswap_v3_factory
        • fetch_deployment
        • increase_liquidity
        • mock_partial_deployment_for_analysis
        • UniswapV3Deployment
      • uniswap_v3.constants
      • uniswap_v3.utils
        • decode_path
        • encode_path
        • encode_sqrt_ratio_x96
        • get_default_tick_range
        • get_max_tick
        • get_min_tick
        • get_nearest_usable_tick
        • get_token0_amount_in_range
        • get_token1_amount_in_range
        • run_graphql_query
        • tick_to_price
        • tick_to_sqrt_price
      • uniswap_v3.liquidity
        • create_tick_csv
        • create_tick_delta_csv
        • estimate_liquidity_depth_at_block
        • get_pool_state_at_block
        • handle_burn_event
        • handle_mint_event
        • TickDelta
      • uniswap_v3.analysis
        • analyse_trade_by_receipt
        • get_input_args
      • uniswap_v3.events
        • decode_burn
        • decode_mint
        • decode_pool_created
        • decode_swap
        • fetch_events_to_csv
        • get_event_mapping
        • TokenCache
      • uniswap_v3.price
        • estimate_buy_received_amount
        • estimate_sell_received_amount
        • UniswapV3PriceHelper
      • uniswap_v3.pool
        • fetch_pool_details
        • get_raw_fee_from_pool_address
        • PoolDetails
      • uniswap_v3.swap
        • swap_with_slippage_protection
      • uniswap_v2.oracle
        • convert_sync_log_result_to_price_entry
        • update_live_price_feed
        • update_price_oracle_with_sync_events_single_thread
        • UniswapV2PriceOracleContext
    • Aave v3 API
      • aave_v3.balances
        • aave_v3_get_deposit_balance
        • aave_v3_get_stable_borrow_balance
        • aave_v3_get_variable_borrow_balance
      • aave_v3.constants
        • aave_v3_get_account_address
        • aave_v3_get_json_rpc_url
        • aave_v3_get_network_by_chain_id
        • aave_v3_get_token_name_by_deposit_address
        • AaveNetwork
        • AaveToken
        • AaveV3InterestRateMode
      • aave_v3.deployer
        • AAVE_DEPLOYER_REPO
        • HARDHAT_CONTRACTS
        • get_aave_hardhard_export
        • AaveDeployer
      • aave_v3.deployment
        • AaveV3Deployment
        • AaveV3ReserveConfiguration
        • AaveV3UserData
      • aave_v3.events
        • aave_v3_fetch_events_to_csv
        • decode_reserve_data_updated
        • get_event_mapping
        • TokenCache
      • aave_v3.loan
        • borrow
        • repay
        • supply
        • withdraw
      • aave_v3.rates
        • aave_v3_calculate_accrued_deposit_interest
        • aave_v3_calculate_accrued_interests
        • aave_v3_calculate_accrued_stable_borrow_interest
        • aave_v3_calculate_accrued_variable_borrow_interest
        • aave_v3_calculate_apr_apy_rates
        • aave_v3_calculate_mean
        • aave_v3_calculate_ohlc
        • aave_v3_filter_by_date_range
        • aave_v3_filter_by_token
        • AaveAccruedInterest
        • AaveAccruedInterests
    • Enzyme protocol API
      • enzyme.deployment
        • POLYGON_DEPLOYMENT
        • EnzymeContracts
        • EnzymeDeployment
        • RateAsset
        • EnzymeDeploymentError
      • enzyme.vault
        • Vault
      • enzyme.integration_manager
        • IntegrationManagerActionId
      • enzyme.events
        • fetch_vault_balance_events
        • Deposit
        • EnzymeBalanceEvent
        • Redemption
      • enzyme.price_feed
        • fetch_price_feeds
        • fetch_updated_price_feed
        • EnzymePriceFeed
        • UnsupportedBaseAsset
      • enzyme.generic_adapter
        • encode_call_on_integration_args
        • encode_generic_adapter_execute_calls_args
        • execute_calls_for_generic_adapter
      • enzyme.uniswap_v2
        • prepare_swap
    • Chainlink API
      • chainlink.round_data
        • fetch_chainlink_round_data
        • ChainLinkLatestRoundData
    • Solidity event reader
      • event_reader.multithread
        • MultithreadEventReader
      • event_reader.reader
        • extract_events
        • extract_events_concurrent
        • extract_timestamps_json_rpc
        • prepare_filter
        • read_events
        • read_events_concurrent
        • ProgressUpdate
        • Web3EventReader
        • BadTimestampValueReturned
        • TimestampNotFound
      • event_reader.logresult
        • LogContext
        • LogResult
      • event_reader.filter
        • Filter
      • event_reader.progress_update
        • PrintProgressUpdate
        • TQDMProgressUpdate
      • event_reader.conversion
        • convert_int256_bytes_to_int
        • convert_jsonrpc_value_to_int
        • convert_uint256_bytes_to_address
        • convert_uint256_hex_string_to_address
        • convert_uint256_string_to_address
        • convert_uint256_string_to_int
        • decode_data
      • event_reader.fast_json_rpc
        • patch_provider
        • patch_web3
        • IPCFlaky
      • event_reader.block_header
        • BlockHeader
      • event_reader.block_time
        • measure_block_time
      • event_reader.block_data_store
        • BlockDataStore
      • event_reader.reorganisation_monitor
        • create_reorganisation_monitor
        • ChainReorganisationResolution
        • GraphQLReorganisationMonitor
        • JSONRPCReorganisationMonitor
        • MockChainAndReorganisationMonitor
        • ReorganisationMonitor
        • BlockNotAvailable
        • ChainReorganisationDetected
        • ReorganisationResolutionFailure
        • TooLongRange
      • event_reader.parquet_block_data_store
        • ParquetDatasetBlockDataStore
        • NoGapsWritten
      • event_reader.csv_block_data_store
        • CSVDatasetBlockDataStore
        • NoGapsWritten
      • event_reader.web3factory
        • SimpleWeb3Factory
        • TunedWeb3Factory
        • Web3Factory
      • event_reader.web3worker
        • create_thread_pool_executor
        • get_worker_web3
      • event_reader.state
        • ScanState
      • event_reader.json_state
        • JSONFileScanState
    • Price oracle
      • price_oracle.oracle
        • time_weighted_average_price
        • BasePriceOracle
        • FixedPriceOracle
        • PriceEntry
        • PriceFunction
        • PriceOracle
        • PriceSource
        • TrustedStablecoinOracle
        • DataPeriodTooShort
        • DataTooOld
        • NotEnoughData
        • PriceCalculationError
    • Data research
      • research.candle
        • convert_to_ohlcv_candles
  • Tutorials
    • ERC-20 token transfer with web3.py
    • Solidity event high-speed multithread reading
    • EVM JSON-RPC node integrity verifier
    • Uniswap v2 live price with web3.py
    • Uniswap V3 liquidity analysis
    • Uniswap V3 price analysis
    • Uniswap v2 historial swaps and pairs event reading
    • Uniswap v2 reading swaps real-time (minimal)
    • Uniswap v2 reading real-time swaps and new pairs
    • Aave V3 Interest Analysis
  • Developer guide
  • Troubleshooting
  • Related projects
  v: latest
Versions
latest
Downloads
On Read the Docs
Project Home
Builds
Back to top
Edit this page

print_symbolic_trace

Documentation for eth_defi.trace.print_symbolic_trace function.

print_symbolic_trace(contract_registry, calltree)[source]

Print a symbolic trace of an Ethereum transaction.

  • Contracts by name

  • Functions by name

Notes about tracing:

  • Currently only works with Anvil backend and if steps_trace=True

  • Transaction must have its gas parameter set, otherwise transaction is never broadcasted because it fails in estimate gas phase

Example output:

E           AssertionError: Transaction failed: AttributeDict({'hash': HexBytes('0xaa70b2f76ad9f32f7c722390535d5a806b4d815f3d8d460e5d18cdba3b1c8c2d'), 'nonce': 2, 'blockHash': HexBytes('0x1d2a1d36185bebb373639e1eb4ddbe9f7f3347fa6dd7bcbbe5e5905fe6a1f4ed'), 'blockNumber': 3, 'transactionIndex': 0, 'from': '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266', 'to': '0x5FbDB2315678afecb367f032d93F642f64180aa3', 'value': 0, 'gasPrice': 768647811, 'gas': 500000, 'input': '0x25ad8c83000000000000000000000000e7f1725e7734ce288f8367e1bb143e90bb3f0512', 'v': 1, 'r': HexBytes('0x43336f08be93aec7ecf456c724d3c29c6cebc589ab3fe6199ee783a627bbcda8'), 's': HexBytes('0x74002a6cdd84b81932e36ac0725591460b09eaaa6b0dd615c0c5d43171467c8a'), 'type': 2, 'accessList': [], 'maxPriorityFeePerGas': 0, 'maxFeePerGas': 1768647811, 'chainId': 31337})
E           Revert reason: execution reverted: Big bada boom
E           Solidity stack trace:
E           CALL: RevertTest.revert2(second=0xe7f1725e7734ce288f8367e1bb143e90bb3f0512) [3284 gas]
E           └── CALL: RevertTest2.boom() [230 gas]

See also

  • eth_defi.anvil.launch_anvil().

Usage example:

reverter = deploy_contract(web3, "RevertTest.json", deployer)

tx_hash = reverter.functions.revert1().transact({"from": deployer, "gas": 500_000})
receipt = web3.eth.wait_for_transaction_receipt(tx_hash)
assert receipt["status"] == 0  # Tx failed

# Get the debug trace from the node and transform it to a list of call items
trace_data = trace_evm_transaction(web3, tx_hash)

# Transform the list of call items to a human-readable output,
# use ABI data from deployed contracts to enrich the output
trace_output = print_symbolic_trace(get_or_create_contract_registry(web3), trace_data)

assert trace_output == 'CALL: [reverted] RevertTest.<revert1> [500000 gas]'
Parameters
  • contract_registry (Dict[str, web3.contract.contract.Contract]) –

    The registered contracts for which we have symbolic information available.

    See eth_defi.deploy.deploy_contract() for registering. All contracts deployed using this function should be registered by default.

  • calltree (evm_trace.base.CallTreeNode) –

    Call tree output.

    From trace_evm_transaction().

Returns

Unicode print output

Next
trace_evm_call
Previous
assert_transaction_success_with_explanation
A part of Trading Strategy algorithmic trading suite. Follow us on Twitter.