RPC
JSON-RPC execution — src/client.rs · execute_function
execute_function(context_id, method, args, executor_public_key?)
Calls a method on a WASM application running inside a context via JSON-RPC. The node auto-resolves the caller's owned identity for the context — executor_public_key is accepted for backward compatibility but ignored.
str
The context ID string that the application is running in.
str
The WASM function name to call, e.g. "get_value" or "set_entries".
str (JSON)
Arguments to the function as a JSON string. Must be valid JSON — raises RuntimeError if it cannot be parsed.
Return value
Returns a Python dict representing the full JSON-RPC response envelope, including id, jsonrpc, and result / error fields.
Examples
Query — read-only call
context_id="ctx-abc123",
method="get_value",
args='{"key": "my_key"}'
)
result = response["result"]
Mutation — state-changing call
context_id="ctx-abc123",
method="set_entries",
args='[{"key": "x", "value": "hello"}]'
)
No arguments
context_id="ctx-abc123",
method="get_all_entries",
args="{}"
)
How it works
Build request
The Python args string is parsed as JSON and wrapped in a jsonrpc::ExecutionRequest targeting the given context and method.
Send to node
Sent as a JSON-RPC 2.0 request to the node's RPC endpoint. The node resolves the caller's identity from the JWT token.
Return response
The full JSON-RPC response is deserialized and returned as a Python dict. Check response["result"] for the function output.
executor_public_key is ignored
This parameter is present for backward compatibility with older clients. The node always auto-resolves the executor identity from the authenticated session. You can pass an empty string or omit it entirely.
Error handling
resp = client.execute_function(ctx_id, "my_method", "{}")
if "error" in resp:
print(f"App error: {resp['error']}")
except calimero.ClientError as e:
# Transport or auth failure
print(f"Client error: {e}")
except RuntimeError as e:
# Invalid JSON in args
print(f"Bad args: {e}")