Skip to content

Commit

Permalink
Use blockscout API primarily for fetching creator-tx-hash instead of …
Browse files Browse the repository at this point in the history
…Etherscan
  • Loading branch information
kuzdogan committed Sep 3, 2024
1 parent ac84c7b commit 558cc50
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ export const getCreatorTx = async (
sourcifyChain: SourcifyChain,
contractAddress: string,
): Promise<string | null> => {
// Try blockscout first
if (sourcifyChain.fetchContractCreationTxUsing?.blockscoutApi) {
const fetcher = getBlockscoutApiContractCreatorFetcher(
sourcifyChain.fetchContractCreationTxUsing?.blockscoutApi.url,
Expand All @@ -245,6 +246,8 @@ export const getCreatorTx = async (
return result;
}
}

// Try etherscan if blockscout fails
if (
sourcifyChain.fetchContractCreationTxUsing?.etherscanApi &&
sourcifyChain?.etherscanApi?.apiURL
Expand Down
63 changes: 42 additions & 21 deletions services/server/src/sourcify-chains-default.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
"apiKeyEnvName": "ETHERSCAN_API_KEY"
},
"fetchContractCreationTxUsing": {
"blockscoutApi": {
"url": "https://eth.blockscout.com/"
},
"etherscanApi": true
},
"rpc": [
Expand Down Expand Up @@ -39,6 +42,9 @@
"apiKeyEnvName": "ETHERSCAN_API_KEY"
},
"fetchContractCreationTxUsing": {
"blockscoutApi": {
"url": "https://eth-holesky.blockscout.com/"
},
"etherscanApi": true
},
"rpc": [
Expand Down Expand Up @@ -83,6 +89,9 @@
}
],
"fetchContractCreationTxUsing": {
"blockscoutApi": {
"url": "https://eth-sepolia.blockscout.com/"
},
"etherscanApi": true
}
},
Expand Down Expand Up @@ -203,6 +212,9 @@
"apiKeyEnvName": "POLYGONSCAN_API_KEY"
},
"fetchContractCreationTxUsing": {
"blockscoutApi": {
"url": "https://polygon.blockscout.com/"
},
"etherscanApi": true
},
"rpc": [
Expand Down Expand Up @@ -266,6 +278,9 @@
"apiKeyEnvName": "ARBISCAN_API_KEY"
},
"fetchContractCreationTxUsing": {
"blockscoutApi": {
"url": "https://arbitrum.blockscout.com/"
},
"etherscanApi": true
},
"rpc": [
Expand All @@ -288,6 +303,9 @@
"apiKeyEnvName": "ARBISCAN_API_KEY"
},
"fetchContractCreationTxUsing": {
"blockscoutApi": {
"url": "https://arbitrum-sepolia.blockscout.com/"
},
"etherscanApi": true
}
},
Expand Down Expand Up @@ -396,6 +414,9 @@
"apiKeyEnvName": "OPTIMISMSCAN_API_KEY"
},
"fetchContractCreationTxUsing": {
"blockscoutApi": {
"url": "https://optimism.blockscout.com/"
},
"etherscanApi": true
},
"rpc": [
Expand All @@ -418,6 +439,9 @@
"apiKeyEnvName": "OPTIMISMSCAN_API_KEY"
},
"fetchContractCreationTxUsing": {
"blockscoutApi": {
"url": "https://optimism-sepolia.blockscout.com/"
},
"etherscanApi": true
},
"rpc": [
Expand Down Expand Up @@ -940,13 +964,7 @@
},
"84531": {
"sourcifyName": "Base Goerli Testnet",
"supported": false,
"etherscanApi": {
"apiURL": "https://api-goerli.basescan.org/"
},
"fetchContractCreationTxUsing": {
"etherscanApi": true
}
"supported": false
},
"8453": {
"sourcifyName": "Base Mainnet",
Expand All @@ -956,6 +974,9 @@
"apiKeyEnvName": "BASESCAN_API_KEY"
},
"fetchContractCreationTxUsing": {
"blockscoutApi": {
"url": "https://base.blockscout.com/"
},
"etherscanApi": true
}
},
Expand Down Expand Up @@ -1411,6 +1432,9 @@
"apiKeyEnvName": "ZKEVM_POLYGONSCAN_API_KEY"
},
"fetchContractCreationTxUsing": {
"blockscoutApi": {
"url": "https://zkevm.blockscout.com/"
},
"etherscanApi": true
}
},
Expand All @@ -1422,10 +1446,7 @@
"apiKeyEnvName": "SCROLLSCAN_API_KEY"
},
"fetchContractCreationTxUsing": {
"etherscanApi": true,
"blockscoutScrape": {
"url": "https://blockscout.scroll.io/"
}
"etherscanApi": true
}
},
"534351": {
Expand All @@ -1436,10 +1457,7 @@
"apiKeyEnvName": "SCROLLSCAN_API_KEY"
},
"fetchContractCreationTxUsing": {
"etherscanApi": true,
"blockscoutScrape": {
"url": "https://sepolia-blockscout.scroll.io"
}
"etherscanApi": true
}
},
"34443": {
Expand Down Expand Up @@ -1474,10 +1492,10 @@
"sourcifyName": "ZKFair Mainnet",
"supported": true,
"fetchContractCreationTxUsing": {
"etherscanApi": true,
"blockscoutApi": {
"url": "https://scan.zkfair.io/"
}
},
"etherscanApi": true
}
},
"1890": {
Expand Down Expand Up @@ -1506,10 +1524,10 @@
"apiKeyEnvName": "KROMASCAN_API_KEY"
},
"fetchContractCreationTxUsing": {
"etherscanApi": true,
"blockscoutApi": {
"url": "https://blockscout.kroma.network/"
}
},
"etherscanApi": true
}
},
"2358": {
Expand All @@ -1520,10 +1538,10 @@
"apiKeyEnvName": "KROMASCAN_API_KEY"
},
"fetchContractCreationTxUsing": {
"etherscanApi": true,
"blockscoutApi": {
"url": "https://blockscout.sepolia.kroma.network/"
}
},
"etherscanApi": true
}
},
"4000": {
Expand Down Expand Up @@ -1714,6 +1732,9 @@
"sourcifyName": "Base Sepolia Tesnet",
"supported": true,
"fetchContractCreationTxUsing": {
"blockscoutApi": {
"url": "https://base-sepolia.blockscout.com/"
},
"etherscanApi": true
},
"etherscanApi": {
Expand Down

0 comments on commit 558cc50

Please sign in to comment.