Imagine this scenario, I have a contract that has a function where I call with runtime.Call().

But this function returns an address of a newly created contract, but not the bytecode as runtime.Create does.

How would I access that bytecode?


  • 1
    eth_getcode is invokable over RPC or IPC. Aug 6, 2018 at 16:14
  • Yeah, but I am woking directly to the evm creating a genesis file. So I need to get all that data included in a genesis. So I dont have access from outside of the blockchain, because it is not even instantiate. But this gives me a good idea, I can review how that eth_getcode is implemented in the lowlevel. Thanks! Aug 6, 2018 at 16:16
  • You can use geth to init a chain with your genesis, and then geth dump 0 to dump the genesis block state trie, which will contain the code and balances for every account Aug 6, 2018 at 16:27
  • what bytecode ??? the bytecode of the contract? it is part of the transaction, a field called extra data, also called input when evm.Call() is executed.
    – Nulik
    Aug 6, 2018 at 18:00

1 Answer 1


Yes it is! Use the client CodeAt method of the ethclient package to read the bytecode of a deployed smart contract. Here's a full example:

package main

import (


func main() {
    client, err := ethclient.Dial("https://rinkeby.infura.io")
    if err != nil {

    contractAddress := common.HexToAddress("0x147B8eb97fD247D06C4006D269c90C1908Fb5D54")
    bytecode, err := client.CodeAt(context.Background(), contractAddress, nil) // nil is latest block
    if err != nil {

    fmt.Println(hex.EncodeToString(bytecode)) // 60806...10029

It'll be the same result as seen on etherscan

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.