Get contract state
Returns the current state of a deployed contract including its fields and token balances.immFields are set at deployment and never change. mutFields are the contract’s mutable state that changes with each transaction.
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Read contract state, query events, and interact with Ralph smart contracts.
curl "https://rpc.ralphstudio.xyz/{slug}/contracts/{address}/state" \
-H "Authorization: Bearer API_KEY"
{
"address": "27Gsc5...",
"bytecode": "0201402c...",
"codeHash": "a1b2c3...",
"initialStateHash": "d4e5f6...",
"immFields": [
{
"type": "Address",
"value": "1DrDyTr9..."
}
],
"mutFields": [
{
"type": "U256",
"value": "1000000000000000000"
}
],
"asset": {
"attoAlphAmount": "1000000000000000000",
"tokens": []
}
}
immFields are set at deployment and never change. mutFields are the contract’s mutable state that changes with each transaction.
curl "https://rpc.ralphstudio.xyz/{slug}/contracts/{address}/bytecode" \
-H "Authorization: Bearer API_KEY"
{
"bytecode": "0201402c..."
}
curl -X POST "https://rpc.ralphstudio.xyz/{slug}/contracts/call-contract" \
-H "Authorization: Bearer API_KEY" \
-H "Content-Type: application/json" \
-d '{
"group": 0,
"address": "27Gsc5...",
"methodIndex": 0,
"args": [
{
"type": "Address",
"value": "1DrDyTr9..."
}
]
}'
{
"returns": [
{
"type": "U256",
"value": "1000000000000000000"
}
],
"gasUsed": 5000,
"contracts": [...],
"txInputs": [],
"txOutputs": []
}
curl -X POST "https://rpc.ralphstudio.xyz/{slug}/contracts/test-contract" \
-H "Authorization: Bearer API_KEY" \
-H "Content-Type: application/json" \
-d '{
"group": 0,
"address": "27Gsc5...",
"bytecode": "0201402c...",
"initialFields": [...],
"testMethodIndex": 0,
"testArgs": [...]
}'
curl -X POST "https://rpc.ralphstudio.xyz/{slug}/contracts/compile-contract" \
-H "Authorization: Bearer API_KEY" \
-H "Content-Type: application/json" \
-d '{
"code": "Contract MyToken(name: ByteVec) {\n pub fn getName() -> ByteVec {\n return name\n }\n}"
}'
{
"bytecode": "0201402c...",
"codeHash": "a1b2c3...",
"fields": {
"names": ["name"],
"types": ["ByteVec"],
"isMutable": [false]
},
"functions": [...],
"events": [...]
}
curl "https://rpc.ralphstudio.xyz/{slug}/events/contract/{address}?start=0&limit=20" \
-H "Authorization: Bearer API_KEY"
{
"events": [
{
"blockHash": "00000000ab3c...",
"txId": "503a2c...",
"contractAddress": "27Gsc5...",
"eventIndex": 0,
"fields": [
{
"type": "Address",
"value": "1DrDyTr9..."
},
{
"type": "U256",
"value": "1000000000000000000"
}
]
}
],
"nextStart": 20
}
curl "https://rpc.ralphstudio.xyz/{slug}/events/tx-id/{tx-hash}" \
-H "Authorization: Bearer API_KEY"
curl "https://rpc.ralphstudio.xyz/{slug}/contracts/{address}/sub-contracts" \
-H "Authorization: Bearer API_KEY"
{
"subContracts": ["28Hsc7...", "29Isc8..."]
}
| Parameter | Type | Description |
|---|---|---|
| address | string | Base58-encoded contract address |
| group | integer | Shard group the contract belongs to (0–3) |
| methodIndex | integer | Index of the function to call |
| args | array | Function arguments as typed values |
| start | integer | Event offset for pagination |
| limit | integer | Number of events to return (max: 100) |
