Calls Between Subjects¶
An oracle or contract can call another one. The caller signs with its own identity, so no shared secret is needed.
1. The caller creates an agreement¶
curl -s -X POST http://127.0.0.1:7700/contracts/<caller>/agreement -H "Authorization: Bearer $ADMIN_TOKEN" -H "Content-Type: application/json" \
-d '{"a": "<oracle>", "methods": ["read_oracle"], "expires": 1893456000000, "limits": {"max_calls": 1000}}'
expires is a time in milliseconds.
2. The called subject accepts it¶
Post the result to /oracles/<oracle>/engage of the service that hosts the oracle.
3. Call¶
curl -s -X POST http://127.0.0.1:7700/contracts/<caller>/call -H "Authorization: Bearer $ADMIN_TOKEN" -H "Content-Type: application/json" \
-d '{"url": "http://oracle:8080/oracles/<oracle>/invoke", "to": "<oracle>", "engagement": "<id>", "method": "read_oracle", "params": {}}'
The response is verified and returned. read_history accepts {"after": <sequence>} and returns up to 20 entries. read_state returns the state and variables of a contract.
Depth¶
Calls carry their depth. It is limited to 4, so calls cannot form endless loops.