curl --request POST \
--url https://hyperliquid-mainnet.core.chainstack.com/4f8d8f4040bdacd1577bff8058438274/evm \
--header 'Content-Type: application/json' \
--data '{
"jsonrpc": "2.0",
"method": "eth_getCode",
"params": [
"0x5555555555555555555555555555555555555555",
"latest"
],
"id": 1
}'
{
"jsonrpc": "2.0",
"id": 1,
"result": "0x608060405234801561001057600080fd5b50600436106100365760003560e01c8063a9059cbb1461003b578063dd62ed3e14610057575b600080fd5b610055600480360381019061005091906101a7565b610087565b005b610071600480360381019061006c91906101e7565b6100a5565b60405161007e9190610236565b60405180910390f35b8173ffffffffffffffffffffffffffffffffffffffff16ff5b60008173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156100e0576000905061012c565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610120576001905061012c565b60009050610131565b809150505b92915050565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061016782610138565b9050919050565b6101778161015c565b811461018257600080fd5b50565b6000813590506101948161016e565b92915050565b6000819050919050565b6101ad8161019a565b81146101b857600080fd5b50565b6000813590506101ca816101a4565b92915050565b600080604083850312156101e7576101e6610133565b5b60006101f585828601610185565b9250506020610206858286016101bb565b9150509250929050565b600080604083850312156102275761022661013357600080fd5b5b600061023585828601610185565b925050602061024685828601610185565b9150509250929050565b6102598161019a565b82525050565b60006020820190506102746000830184610250565b9291505056fea2646970667358221220..."
}
Returns the bytecode of a smart contract at a given address and block.
curl --request POST \
--url https://hyperliquid-mainnet.core.chainstack.com/4f8d8f4040bdacd1577bff8058438274/evm \
--header 'Content-Type: application/json' \
--data '{
"jsonrpc": "2.0",
"method": "eth_getCode",
"params": [
"0x5555555555555555555555555555555555555555",
"latest"
],
"id": 1
}'
{
"jsonrpc": "2.0",
"id": 1,
"result": "0x608060405234801561001057600080fd5b50600436106100365760003560e01c8063a9059cbb1461003b578063dd62ed3e14610057575b600080fd5b610055600480360381019061005091906101a7565b610087565b005b610071600480360381019061006c91906101e7565b6100a5565b60405161007e9190610236565b60405180910390f35b8173ffffffffffffffffffffffffffffffffffffffff16ff5b60008173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156100e0576000905061012c565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610120576001905061012c565b60009050610131565b809150505b92915050565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061016782610138565b9050919050565b6101778161015c565b811461018257600080fd5b50565b6000813590506101948161016e565b92915050565b6000819050919050565b6101ad8161019a565b81146101b857600080fd5b50565b6000813590506101ca816101a4565b92915050565b600080604083850312156101e7576101e6610133565b5b60006101f585828601610185565b9250506020610206858286016101bb565b9150509250929050565b600080604083850312156102275761022661013357600080fd5b5b600061023585828601610185565b925050602061024685828601610185565b9150509250929050565b6102598161019a565b82525050565b60006020820190506102746000830184610250565b9291505056fea2646970667358221220..."
}
eth_getCode
JSON-RPC method returns the bytecode of a smart contract at a given address and block. This method is essential for contract verification, analysis, and determining whether an address contains a smart contract or is an externally owned account (EOA).
address
(string, required) — The 20-byte address to retrieve code fromblock
(string, required) — Block identifier: "latest"
(only the latest block is supported on Hyperliquid)"0x"
if no code exists at the address.
result
— The contract bytecode as a hexadecimal string with 0x
prefix0x
prefix"0x"
indicates no code (externally owned account)// Check if address is a contract
const isContract = (code) => code !== "0x" && code.length > 2;
// Check if address is an EOA
const isEOA = (code) => code === "0x";
// Get contract bytecode on Hyperliquid
const getContractCode = async (address) => {
const response = await fetch('https://hyperliquid-mainnet.core.chainstack.com/YOUR_ENDPOINT/evm', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
jsonrpc: '2.0',
method: 'eth_getCode',
params: [address, 'latest'], // Only 'latest' is supported
id: 1
})
});
const data = await response.json();
return data.result;
};
// Check if address is a contract or EOA
const analyzeAddress = async (address) => {
const code = await getContractCode(address);
const isContract = code !== "0x" && code.length > 2;
const isEOA = code === "0x";
return {
address,
code,
isContract,
isEOA,
codeSize: isContract ? (code.length - 2) / 2 : 0, // Convert hex to bytes
hasCode: isContract
};
};
// Analyze multiple addresses
const analyzeMultipleAddresses = async (addresses) => {
const results = [];
for (const address of addresses) {
try {
const analysis = await analyzeAddress(address);
results.push(analysis);
} catch (error) {
console.error(`Error analyzing address ${address}:`, error);
results.push({
address,
error: error.message,
isContract: null,
isEOA: null
});
}
}
return results;
};
// Check for common proxy patterns
const checkProxyPattern = (bytecode) => {
if (bytecode === "0x") return { isProxy: false, type: null };
// EIP-1167 minimal proxy pattern
if (bytecode.includes("363d3d373d3d3d363d73")) {
return { isProxy: true, type: "EIP-1167 Minimal Proxy" };
}
// Other common proxy patterns
if (bytecode.includes("3660008037600080366000845af43d6000803e")) {
return { isProxy: true, type: "Delegatecall Proxy" };
}
return { isProxy: false, type: null };
};
// Usage examples
const contractAddress = "0x5555555555555555555555555555555555555555";
const eoaAddress = "0xFC1286EeddF81d6955eDAd5C8D99B8Aa32F3D2AA";
analyzeAddress(contractAddress)
.then(analysis => {
console.log('Contract Analysis:', analysis);
if (analysis.isContract) {
const proxyInfo = checkProxyPattern(analysis.code);
console.log('Proxy Analysis:', proxyInfo);
}
})
.catch(error => console.error('Error:', error));
// Analyze multiple addresses
analyzeMultipleAddresses([contractAddress, eoaAddress])
.then(results => console.log('Multiple Address Analysis:', results))
.catch(error => console.error('Error:', error));
"latest"
block parameter is supported"0x"
indicates an externally owned account (EOA)curl -X POST \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"eth_getCode","params":["0x5555555555555555555555555555555555555555","latest"],"id":1}' \
https://hyperliquid-mainnet.core.chainstack.com/4f8d8f4040bdacd1577bff8058438274/evm
eth_getCode
method is essential for applications that need to:
eth_getCode
only supports the latest block. The returned bytecode is the runtime code deployed on the blockchain, not the constructor code. For EOAs (externally owned accounts), this method returns "0x"
.Successful response with the contract bytecode
The response is of type object
.