getCode
Callable
Type parameters
- ReturnFormat: DataFormat
Parameters
web3Context: Web3Context<EthExecutionAPI, any>
(Web3Context) Web3 configuration object that contains things such as the provider, request manager, wallet, etc.
address: string
The address to get the code from.
blockNumber: BlockNumberOrTag = web3Context.defaultBlock
(BlockNumberOrTag defaults to Web3Eth.defaultBlock) Specifies what block to use as the current state for the code query.
returnFormat: ReturnFormat
(DataFormat defaults to DEFAULT_RETURN_FORMAT) Specifies how the return data should be formatted.
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
]
Get the code at a specific address.