View L1 assets bridged to Optimism via the Optimism Standard Bridge
This query shows how to find finalized deposit events logs for L1 assets that
were bridged to Optimism using the official Optimism Standard
Bridge. The Optimism Standard Bridge
supports bridging native Ether and certain ERC-20 tokens from Ethereum to Optimism.
In the Google Cloud console, go to the BigQuery page.
The following query is loaded into the Editor field:
-- UDF for easier string manipulation.CREATETEMPFUNCTIONParseSubStr(hexStrSTRING,startIndexINT64,endIndexINT64)RETURNSSTRINGLANGUAGEjsASr""" if (hexStr.length < 1) { return hexStr; } return hexStr.substring(startIndex, endIndex);""";-- UDF to translate hex numbers into decimal representation.CREATETEMPFUNCTIONHexToDec(hexStrSTRING)RETURNSBIGNUMERICLANGUAGEjsASr""" return parseInt(hexStr, 16)""";-- UDF to strip leading zeroes from 66 character addresses.-- Optimism addresses as returned from the OP node are 66 characters long.-- Format: "0x" prefix + 64 character (32-byte) address.-- Strip the leading zeroes so that it's easier to look up addresses in block explorer.CREATETEMPFUNCTIONStripLeadingZeroes(hexSTRING,numZeroesINT64)RETURNSSTRINGLANGUAGEjsASr""" function _stripLeadingZeroes(addr, numZeroes) { if (addr.length != 66) { return addr; } return '0x'.concat(addr.substring(numZeroes)); } return _stripLeadingZeroes(hex, numZeroes);""";-- Find finalized deposits into Optimism (L2) where assets were transferred-- from the L1 (Ethereum) to the L2 (Optimism) via the Optimism Standard Bridge-- at block X.SELECTblock_number,transaction_hash,CONCAT("https://optimistic.etherscan.io/tx/",transaction_hash)AStxn_optimistic_etherscan,StripLeadingZeroes(topics[OFFSET(1)],26)ASL1Token,StripLeadingZeroes(topics[OFFSET(2)],26)ASL2Token,StripLeadingZeroes(topics[OFFSET(3)],26)ASfrom_address,StripLeadingZeroes(ParseSubStr(l.data,0,66),26)ASto_address,HexToDec(ParseSubStr(l.data,66,130))ASamount_deposited,FROM`bigquery-public-data.goog_blockchain_optimism_mainnet_us.logs`aslWHEREARRAY_LENGTH(l.topics) > 0-- Check for non-empty topics first to short-circuit boolean evaluation.AND-- DepositFinalized:-- https://github.com/ethereum-optimism/optimism/blob/e24d77204ede3635d57253f5b6306be261e109b5/packages/contracts-ts/abis.json#L10319l.topics[OFFSET(0)]="0xb0444523268717a02698be47d0803aa7468c00acbed2f8bd93a0459cde61dd89"ANDblock_number=109223310;
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-03 UTC."],[[["\u003cp\u003eThis page provides query examples for analyzing Optimism blockchain data using BigQuery.\u003c/p\u003e\n"],["\u003cp\u003ePre-GA offerings, like the ones potentially referred to on this page, are "as is" and may have limited support as described in the General Service Terms.\u003c/p\u003e\n"],["\u003cp\u003eYou can use the provided query to find the earliest and most recently indexed block on the Optimism network.\u003c/p\u003e\n"],["\u003cp\u003eAnother example shows how to find finalized deposit events for L1 assets bridged to Optimism using the Optimism Standard Bridge.\u003c/p\u003e\n"],["\u003cp\u003eThe examples include custom JavaScript functions to help users with data manipulation and conversion within BigQuery.\u003c/p\u003e\n"]]],[],null,["# Optimism example queries\n\n| **Preview**\n|\n|\n| This product or feature is subject to the \"Pre-GA Offerings Terms\" in the General Service Terms section\n| of the [Service Specific Terms](/terms/service-terms#1).\n|\n| Pre-GA products and features are available \"as is\" and might have limited support.\n|\n| For more information, see the\n| [launch stage descriptions](/products#product-launch-stages).\n\nThis page provides Blockchain Analytics query examples for Optimism.\n\nSee the [BigQuery documentation](/bigquery/docs/introduction) for\ninstructions on using BigQuery.\n\nView the earliest and most recently indexed block\n-------------------------------------------------\n\nIn the Google Cloud console, go to the **BigQuery** page.\n\n[Go to BigQuery](https://console.cloud.google.com/bigquery?sq=650023896125:bb161caf40844b0cb9a23129783496b0)\n\nThe following query is loaded into the **Editor** field: \n\n SELECT\n MIN(block_number) AS `First block`,\n MAX(block_number) AS `Newest block`,\n COUNT(1) AS `Total number of blocks`\n FROM\n bigquery-public-data.goog_blockchain_optimism_mainnet_us.blocks;\n\n**Example result**:\n\nView L1 assets bridged to Optimism via the Optimism Standard Bridge\n-------------------------------------------------------------------\n\nThis query shows how to find finalized deposit events logs for L1 assets that\nwere bridged to Optimism using the official [Optimism Standard\nBridge](https://community.optimism.io/docs/developers/bridge/standard-bridge/#). The Optimism Standard Bridge\nsupports bridging native Ether and [certain ERC-20 tokens](https://static.optimism.io/optimism.tokenlist.json) from Ethereum to Optimism.\n\nIn the Google Cloud console, go to the **BigQuery** page.\n\n[Go to BigQuery](https://console.cloud.google.com/bigquery?sq=650023896125:92d97fa52d3a4752b414332e2cb3bdeb)\n\nThe following query is loaded into the **Editor** field: \n\n -- UDF for easier string manipulation.\n CREATE TEMP FUNCTION ParseSubStr(hexStr STRING, startIndex INT64, endIndex INT64)\n RETURNS STRING\n LANGUAGE js\n AS r\"\"\"\n if (hexStr.length \u003c 1) {\n return hexStr;\n }\n return hexStr.substring(startIndex, endIndex);\n \"\"\";\n\n -- UDF to translate hex numbers into decimal representation.\n CREATE TEMP FUNCTION HexToDec(hexStr STRING)\n RETURNS BIGNUMERIC\n LANGUAGE js\n AS r\"\"\"\n return parseInt(hexStr, 16)\n \"\"\";\n\n -- UDF to strip leading zeroes from 66 character addresses.\n -- Optimism addresses as returned from the OP node are 66 characters long.\n -- Format: \"0x\" prefix + 64 character (32-byte) address.\n -- Strip the leading zeroes so that it's easier to look up addresses in block explorer.\n CREATE TEMP FUNCTION StripLeadingZeroes(hex STRING, numZeroes INT64)\n RETURNS STRING\n LANGUAGE js\n AS r\"\"\"\n function _stripLeadingZeroes(addr, numZeroes) {\n if (addr.length != 66) {\n return addr;\n }\n return '0x'.concat(addr.substring(numZeroes));\n }\n return _stripLeadingZeroes(hex, numZeroes);\n \"\"\";\n\n -- Find finalized deposits into Optimism (L2) where assets were transferred\n -- from the L1 (Ethereum) to the L2 (Optimism) via the Optimism Standard Bridge\n -- at block X.\n SELECT\n block_number,\n transaction_hash,\n CONCAT(\"https://optimistic.etherscan.io/tx/\", transaction_hash) AS txn_optimistic_etherscan,\n StripLeadingZeroes(topics[OFFSET(1)], 26) AS L1Token,\n StripLeadingZeroes(topics[OFFSET(2)], 26) AS L2Token,\n StripLeadingZeroes(topics[OFFSET(3)], 26) AS from_address,\n StripLeadingZeroes(ParseSubStr(l.data, 0, 66), 26) AS to_address,\n HexToDec(ParseSubStr(l.data, 66, 130)) AS amount_deposited,\n FROM\n `bigquery-public-data.goog_blockchain_optimism_mainnet_us.logs` as l\n WHERE\n ARRAY_LENGTH(l.topics) \u003e 0 -- Check for non-empty topics first to short-circuit boolean evaluation.\n AND\n -- DepositFinalized:\n -- https://github.com/ethereum-optimism/optimism/blob/e24d77204ede3635d57253f5b6306be261e109b5/packages/contracts-ts/abis.json#L10319\n l.topics[OFFSET(0)] = \"0xb0444523268717a02698be47d0803aa7468c00acbed2f8bd93a0459cde61dd89\"\n AND\n block_number = 109223310;\n\n**Example result**:"]]