I compile my solidity file using the following command:

solc Encoder.sol --bin --abi --optimize -o <output_dir>/

Then I try to deploy it in Geth:

Encoder = eth.contract([<abi file content>])
deployEncoder = {from:eth.coinbase, data:"0x<bin file content>", gas:2000000}>}

getPartialInstanceEncoder = Encoder.new([], deployEncoder)

The last line throws an exception. Looking closer into the bin file content, I figured out that the bin file contains several invalid characters, either '$' or '_'. What is the reason for this?

I uploaded my bin file here (since it is too large for the text here), you can search for the characters in your browser: https://file.io/OIFtZM


Just a guess because the link seems to be dead, but maybe you're using libraries?

From https://solidity.readthedocs.io/en/v0.5.11/using-the-compiler.html:

If your contracts use libraries, you will notice that the bytecode contains substrings of the form __$53aea86b7d70b31448b230b20ae141a537$__. These are placeholders for the actual library addresses. The placeholder is a 34 character prefix of the hex encoding of the keccak256 hash of the fully qualified library name. The bytecode file will also contain lines of the form // <placeholder> -> <fq library name> at the end to help identify which libraries the placeholders represent. Note that the fully qualified library name is the path of its source file and the library name separated by :. You can use solc as a linker meaning that it will insert the library addresses for you at those points:

Either add --libraries "file.sol:Math:0x1234567890123456789012345678901234567890 file.sol:Heap:0xabCD567890123456789012345678901234567890" to your command to provide an address for each library or store the string in a file (one library per line) and run solc using --libraries fileName.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.