I have a contract that results to the following bytecode: 0x6080604052348015600f57600080fd5b506004361060285760003560e01c806321185b7914602d575b600080fd5b60336047565b604051603e91906078565b60405180910390f35b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60728160b1565b82525050565b6000602082019050608b6000830184606b565b92915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600060ba8260c1565b9050919050565b600060ca826091565b905091905056fea2646970667358221220c7327aadd8e40ef6a907b537c81793e0671c2583a5dec5b21446f965d3d4b3c864736f6c63430008000033

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;

contract SharingIsCaring {
    string public flag;

    constructor(string memory _key) {
        flag = _key;

How can I read the public variable flag from the bytecode?

  • The variable flag is a string, so it is more complicate to work with. You could use remix to compile an obtain an assembly output that is easier to read. Why do you want to read the flag bytecode?
    – Ismael
    Commented Apr 20, 2023 at 4:40

1 Answer 1


Constructor arguments to are usually ABI encoded and appended to the end of the deployment bytecode. Since this is a string, the argument would probably look something like

[your_bytecode][0x20 padded to 32 bytes][length of string padded to 32 bytes][your actual string]

So for example if you wanted to set the _key value to "hello world" you would append:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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