Get Code
Retrieve contract bytecode at an address with getCode
Loading...
Retrieve contract bytecode at an address with getCode
GetCode returns the bytecode at a given address (e.g. contract deployment code). Uses eth_getCode. No ABI required.
import ( "github.com/ethereum/go-ethereum/common" "github.com/ChefBingbong/viem-go/actions/public")code, err := public.GetCode(ctx, publicClient, public.GetCodeParameters{ Address: common.HexToAddress("0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2"),})if err != nil { log.Fatal(err)}if code == nil { // No contract at this address (EOA or empty)}fmt.Printf("Bytecode length: %d bytes", len(code))common.Address*uint64BlockTag (e.g. "latest", "pending", "safe")"latest"([]byte, error). nil slice means no code (empty account or EOA).