I have a contract called Test , which uses a library called LCG. They are respectively defined in the .sol files with the same name as the contract:
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.4;
import "./LCG.sol";
contract Test {
using LCG for LCG.iterator;
LCG.iterator public x;
constructor () {
x.iterate();
}
}
and
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.4;
library LCG {
struct iterator {
uint x;
}
function iterate (iterator storage i) external {
i.x = i.x + 1;
}
}
I deployed the contract to 0x1773c9913710bd3B9Ba3AFE4b08574C63631EE3e on Rinkeby. When I ask etherscan to verify the contract I get the following error message:
Compiler debug log:
Error! Unable to generate Contract ByteCode and ABI
Found the following ContractName(s) in source code: LCG.sol:LCG, Test.sol:Test
But we were unable to locate a matching bytecode (err_code_2)
and then
ByteCode (what we are looking for):
608060405234801561001057600080fd5b50600073e91f7cf9f5d9943f43171ab141c8f692ffa5bdbb63760ebcb390916040518263ffffffff1660e01b815260040161004b9190610087565b60006040518083038186803b15801561006357600080fd5b505af4158015610077573d6000803e3d6000fd5b505050506100a2565b8082525050565b600060208201905061009c6000830184610080565b92915050565b60b9806100b06000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c80630c55699c14602d575b600080fd5b60336047565b604051603e91906060565b60405180910390f35b60008060000154905081565b605a816079565b82525050565b6000602082019050607360008301846053565b92915050565b600081905091905056fe{ipfs}64736f6c63430008040033
versus
We tried looking for a match from the list of compiled contract bytecode outputs (as listed below), but was unable to find an exact match.
1) LCG.sol:LCG
6101a3610053600b82828239805160001a607314610046577f4e487b7100000000000000000000000000000000000000000000000000000000600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600436106100355760003560e01c8063760ebcb31461003a575b600080fd5b81801561004657600080fd5b50610061600480360381019061005c9190610094565b610063565b005b6001816000015461007491906100bd565b816000018190555050565b60008135905061008e81610156565b92915050565b6000602082840312156100a657600080fd5b60006100b48482850161007f565b91505092915050565b60006100c88261011d565b91506100d38361011d565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0382111561010857610107610127565b5b828201905092915050565b6000819050919050565b6000819050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b61015f81610113565b811461016a57600080fd5b5056fe{ipfs}64736f6c63430008040033
2) Test.sol:Test
608060405234801561001057600080fd5b50600073__$ba5a92dcf866592fe0e4658ad284226a6d$__63760ebcb390916040518263ffffffff1660e01b815260040161004b9190610087565b60006040518083038186803b15801561006357600080fd5b505af4158015610077573d6000803e3d6000fd5b505050506100a2565b8082525050565b600060208201905061009c6000830184610080565b92915050565b60b9806100b06000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c80630c55699c14602d575b600080fd5b60336047565b604051603e91906060565b60405180910390f35b60008060000154905081565b605a816079565b82525050565b6000602082019050607360008301846053565b92915050565b600081905091905056fe{ipfs}64736f6c63430008040033
Somehow the compiled bytecode of Test.sol has those dollar signs inside (e.g. __$ba5a92dcf866592fe0e4658ad284226a6d$__6).
I also failed to verify when I put everything into one single file. What's going wrong?