getCode
Get the code of the specified contract. If contract not exist will return undefined.
Usage
import { publicClient } from "./client";
const bytecode = await publicClient.getCode({
address: "cfx:...",
});import { http, createPublicClient } from 'cive'
import { mainnet } from 'cive/chains'
export const publicClient = createPublicClient({
chain: mainnet,
transport: http(),
})Returns
Return Hex if the address has code; otherwise, return undefined.
Parameters
address
- Type:
Address
The address to check for collateral storage
const contractAddress = await publicClient.getCode({
address: "cfx:...",
});epochTag (optional)
- Type:
latest_state|latest_confirmed|latest_checkpoint|earliest - Defaut:
latest_state
const contractAddress = await publicClient.getCode({
address: "cfx:...",
epochTag: "latest_state",
});epochNumber (optional)
- Type:
bigint
const contractAddress = await publicClient.getCode({
address: "cfx:...",
epochNumber: 1n,
});