Skip to content
On this page

getBytecode โ€‹

Retrieves the bytecode at an address.

Usage โ€‹

ts
import { publicClient } from './client'

const bytecode = await publicClient.getBytecode({
  address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
})
ts
import { createPublicClient, http } from 'viem'
import { mainnet } from 'viem/chains'

export const publicClient = createPublicClient({
  chain: mainnet,
  transport: http()
})

Return Value โ€‹

Hex

The contract's bytecode.

Parameters โ€‹

address โ€‹

The contract address.

ts
const bytecode = await publicClient.getBytecode({
  address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2', 
})

Released under the MIT License.