5

I have the bytecode of a contract, can I deploy it to a private network without the need of source code?

Does bytecode contain the deployers signature or somehow the network id? Here is the bytecode.

0x606060405260043610610062576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806319e30bc7146100775780635bd74afe146101055780639df211541461017f578063b1d131bf146101ad575b6000366001919061007492919061042d565b50005b341561008257600080fd5b61008a610202565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100ca5780820151818401526020810190506100af565b50505050905090810190601f1680156100f75780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61017d600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001908201803590602001908080601f016020809104026020016040519081016040528093929190818152602001838380828437820191505050505050919080359060200190919050506102a0565b005b6101ab600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190505061038d565b005b34156101b857600080fd5b6101c0610408565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b60018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156102985780601f1061026d57610100808354040283529160200191610298565b820191906000526020600020905b81548152906001019060200180831161027b57829003601f168201915b505050505081565b3373ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415156102fb57600080fd5b8273ffffffffffffffffffffffffffffffffffffffff16818360405180828051906020019080838360005b83811015610341578082015181840152602081019050610326565b50505050905090810190601f16801561036e5780820380516001836020036101000a031916815260200191505b5091505060006040518083038185876187965a03f19250505050505050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc3073ffffffffffffffffffffffffffffffffffffffff16319081150290604051600060405180830381858888f19350505050151561040557600080fd5b50565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061046e57803560ff191683800117855561049c565b8280016001018555821561049c579182015b8281111561049b578235825591602001919060010190610480565b5b5090506104a991906104ad565b5090565b6104cf91905b808211156104cb5760008160009055506001016104b3565b5090565b905600a165627a7a723058202592c848fd2bdbf19b6558815a8c0a67519b4ad552eb001c92109a188ef215950029
7

You don't need the source code, but in your contract creation transaction, you need to specify the initialization code: bytecode that returns the bytecode that you want deployed.

For example, if you wanted to deploy a contract with code 0x60606040, you can't just set the data field of your transaction to 0x60606040: your data field needs to be bytecode that when executed by the EVM, returns 0x60606040.

See also: Bytecode on block chain different from the one used when deploying and the Yellow Paper, Section 4.3:

Additionally, a contract creation transaction contains:
init: An unlimited size byte array specifying the
EVM-code for the account initialisation procedure,
formally Ti.
init is an EVM-code fragment; it returns the body,
a second fragment of code that executes each time the
account receives a message call (either through a transaction
or due to the internal execution of code). init is
executed only once at account creation and gets discarded
immediately thereafter.

As @Davide answered, the source code is usually helpful to get the ABI: Do I need a compiled contract just to get the ABI definition?


Does bytecode contain the deployers signature or somehow the network id?

No.

1

You dont need the source code of a smart contract to deploy it, but you do need its bytecode.

The bytecode does not contain the deployer signature nor network id. The bytecode is only a translation of your source code into intructions that the Ethereum Virtual Machine can understand.

1

You can do without source code however you will need the contract ABI interface which describes in a formal way the function signatures of the contract. Then using a wallet that can interact with smart contracts (MyEtherWallet for instance) you can deploy the contract on the network. During deployment it will ask you to insert the actual parameters for the contract constructor if any.

  • Yes it's good point to make that you need the ABI to interact, but I know one function signature so I will try to debug that function with different transactions. – EralpB Nov 8 '17 at 11:18

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.