truffle
truffle copied to clipboard
No source fetcher for Blockscout
Issue
There's currently no source fetcher for Blockscout.
That said, writing one faces some problems. Now Blockscout actually has two different APIs one could use for fetching source code. One is similar to Etherscan's; the other is GraphQL based. However, the GraphQL-based interface seems to be lacking some necessary information (such as the value of the runs parameter), so I don't think we can use that one; it would have to be the Etherscan-like interface (which is not quite identical to Etherscan's, having some minor differences, such as the key name for the runs parameter).
However, determining the exact workings of this interface would also be troublesome (the documentation certainly doesn't do much to explain it). As with Etherscan, there are four cases, although they're not the same four cases that Etherscan has. (The cases are Solidity single-source; Vyper single-source; Solidity JSON; and Solidity metadata-and-sources (like Sourcify); that last one is different from Etherscan, which instead has Solidity multiple-source.)
So, it would be necessary to determine how each of those cases work. I've already looked at the Solidity single-source case. But how to determine the others?
With Etherscan, I could determine things by browsing verified contracts, looking for the different cases. But Blockscout doesn't seem to have a good way to browse verified contracts. Also with Etherscan, I could throw up test contracts on Goerli and verify them to see the result; the problem here is that Blockscout doesn't support the usual testnets. The only testnets they support are the xDAI testnet and Sokol. So uh I'd have to figure out how to use one of those, probably Sokol? They have a faucet at least which is convenient. But maybe I can look at that sometime when I have time...
Environment
- Truffle version (
truffle version): 5.5.2
OK, even this is low-priority, I did some more looking into this using Sokol, and what I found is that Blockscout has some problems. The JSON method just... doesn't seem to work? I couldn't verify any contracts that way. And if you use the Sourcify-like method, then the return value is missing some necessary information. :-/ I mean, the good news is that in that case they actually verify the contract on Sourcify, so one could rely on that...? :-/ (Presumably not in the same fetcher, though.)
Moreover, Blockscout seems to be in the habit of occasionally returning errors for no particular reason that I could find. It seemed like if it knew about that address, but that address wasn't verified, it would return an error! It would only return the "not verified" message when it was an address it didn't know about at all...? This will pose a problem if one wants to be able to retry on errors, as it will lead to a lot of fruitless retrying!
Btw, here are the issues I've filed with Blocksout:
- https://github.com/blockscout/blockscout/issues/5746
- https://github.com/blockscout/blockscout/issues/5747
- https://github.com/blockscout/blockscout/issues/5748
- https://github.com/blockscout/blockscout/issues/5749
So, Blockscout now supports Yul! However, I ran into a problem trying to test that case: https://github.com/blockscout/blockscout-rs/issues/449