cfx_getCode
Returns the code at given address at given time (epoch number).
- CURL
curl --request POST \
--url https://main.confluxrpc.com \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '
{
"id": 1,
"jsonrpc": "2.0",
"params": ["CFXTEST:TYPE.USER:AATGGCS6J4VMKE5M10WY04SKDZ7D27RDX2CZXKDMY3",null],
"method": "cfx_getCode"
}'
Params
addr required
Schema
type : string
Pattern :
^(NET\d+|CFX|CFXTEST)(:TYPE\..*|):[ABCDEFGHJKMNPRSTUVWXYZ0123456789]{42}$
block_hash_or_epoch_number optional
Schema
type : any
Always valid
Result
Schema
type : string
Pattern :
^0x[0-9a-f]*$
Examples
- cfx_getCode
- cfx_getCode
- cfx_getCode
- cfx_getCode
- cfx_getCode
- cfx_getCode
- cfx_getCode
- cfx_getCode
- cfx_getCode
Request
curl -X POST --data \
'{
"jsonrpc": "2.0",
"id": 1,
"method": "cfx_getCode",
"params": [
"CFXTEST:TYPE.USER:AATGGCS6J4VMKE5M10WY04SKDZ7D27RDX2CZXKDMY3"
]
}' \
-H "Content-Type: application/json" \
localhost:12539
Response
"0x"
Request
curl -X POST --data \
'{
"jsonrpc": "2.0",
"id": 1,
"method": "cfx_getCode",
"params": [
"CFXTEST:TYPE.USER:AATGGCS6J4VMKE5M10WY04SKDZ7D27RDX2CZXKDMY3",
"latest_mined"
]
}' \
-H "Content-Type: application/json" \
localhost:12539
Response
{
"code": -32602,
"message": "Invalid parameters: num",
"data": "\"Latest mined epoch is not executed\""
}
Request
curl -X POST --data \
'{
"jsonrpc": "2.0",
"id": 1,
"method": "cfx_getCode",
"params": [
"CFXTEST:TYPE.USER:AATGGCS6J4VMKE5M10WY04SKDZ7D27RDX2CZXKDMY3",
"earliest"
]
}' \
-H "Content-Type: application/json" \
localhost:12539