Skip to main content

getCode

Callable


  • Get the code at a specific address.


    Type parameters

    Parameters

    Returns Promise<string>

    The data at the provided address.

    web3.eth.getCode("0x033456732123ffff2342342dd12342434324234234fd234fd23fd4f23d4234").then(console.log);
    > "0x600160008035811a818181146012578301005b601b6001356025565b8060005260206000f25b600060078202905091905056"

    web3.eth.getCode(
    "0x407d73d8a49eeb85d32cf465507dd71d507100c1",
    'safe',
    { number: FMT_NUMBER.HEX , bytes: FMT_BYTES.UINT8ARRAY }
    ).then(console.log);
    > Uint8Array(50) [
    96, 1, 96, 0, 128, 53, 129, 26, 129, 129, 129,
    20, 96, 18, 87, 131, 1, 0, 91, 96, 27, 96,
    1, 53, 96, 37, 86, 91, 128, 96, 0, 82, 96,
    32, 96, 0, 242, 91, 96, 0, 96, 7, 130, 2,
    144, 80, 145, 144, 80, 86
    ]