This API provides endpoints for managing state, interacting with IPFS, and communicating with a rollup server. It supports operations such as setting, deleting, and fetching state, as well as interacting with metadata and externalizing state.
Endpoints
DELETE /delete_state/{key}
Deletes the state associated with a specific key.
Path Parameter:
key: The key of the state to delete.
Response Codes:
200 OK: State successfully deleted.
500 Internal Server Error: Failed to delete the state.
POST /set_state/{key}
Sets a state with the given key and associated data.
Path Parameter:
key: The key of the state to set.
Request Body:
The data (binary) to store in the state.
Response Codes:
200 OK: State successfully set.
500 Internal Server Error: Failed to set the state.
GET /get_state/{key}
Retrieves the state associated with a specific key.
Path Parameter:
key: The key of the state to retrieve.
Response Codes:
200 OK: State successfully retrieved.
500 Internal Server Error: Failed to retrieve the state.
GET /open_state
Requests and opens the current state based on a GIO request.
Response Codes:
200 OK: State successfully opened.
400 Bad Request: Failed to open the state.
GET /commit_state
Commits the current state by sending a GIO request to a rollup server.
Response Codes:
200 OK: State successfully committed.
400 Bad Request: Failed to commit the state.
GET /metadata/{text}
Fetches metadata associated with the provided text.
Path Parameter:
text: The text whose metadata is to be fetched.
Response Codes:
200 OK: Metadata successfully retrieved.
400 Bad Request: Failed to fetch metadata.
PUT /ipfs/put/{cid}
Uploads data to IPFS and externalizes the state.
Path Parameter:
cid: The CID of the data being uploaded.
Request Body:
The data to be uploaded.
Response Codes:
200 OK: Data successfully uploaded to IPFS.
400 Bad Request: Failed to upload data to IPFS.
HEAD /ipfs/has/{cid}
Checks if a specific CID exists on IPFS.
Path Parameter:
cid: The CID to check for existence.
Response Codes:
200 OK: CID exists.
404 Not Found: CID does not exist.
GET /ipfs/get/{cid}
Fetches data from IPFS by CID.
Path Parameter:
cid: The CID of the data to retrieve.
Response Codes:
200 OK: Data successfully retrieved from IPFS.
400 Bad Request: Failed to retrieve data from IPFS.
GET /get_data/{namespace}/{data_id}
Fetches data based on a namespace and data ID.
Path Parameters:
namespace: The namespace (e.g., keccak256).
data_id: The ID of the data to retrieve.
Response Codes:
200 OK: Data successfully retrieved.
400 Bad Request: Failed to retrieve data.
GET /get_app
Fetches the current app state using a GIO request.
Response Codes:
200 OK: App state successfully retrieved.
400 Bad Request: Failed to retrieve app state.
Configuration
The HTTP server can be configured via a Config struct that defines the HTTP address and port. The server is created using the create_server function and run asynchronously with the run function.
HTTP API Documentation
This API provides endpoints for managing state, interacting with IPFS, and communicating with a rollup server. It supports operations such as setting, deleting, and fetching state, as well as interacting with metadata and externalizing state.
Endpoints
DELETE /delete_state/{key}
Deletes the state associated with a specific key.
key
: The key of the state to delete.200 OK
: State successfully deleted.500 Internal Server Error
: Failed to delete the state.POST /set_state/{key}
Sets a state with the given key and associated data.
key
: The key of the state to set.200 OK
: State successfully set.500 Internal Server Error
: Failed to set the state.GET /get_state/{key}
Retrieves the state associated with a specific key.
key
: The key of the state to retrieve.200 OK
: State successfully retrieved.500 Internal Server Error
: Failed to retrieve the state.GET /open_state
Requests and opens the current state based on a GIO request.
200 OK
: State successfully opened.400 Bad Request
: Failed to open the state.GET /commit_state
Commits the current state by sending a GIO request to a rollup server.
200 OK
: State successfully committed.400 Bad Request
: Failed to commit the state.GET /metadata/{text}
Fetches metadata associated with the provided text.
text
: The text whose metadata is to be fetched.200 OK
: Metadata successfully retrieved.400 Bad Request
: Failed to fetch metadata.PUT /ipfs/put/{cid}
Uploads data to IPFS and externalizes the state.
cid
: The CID of the data being uploaded.200 OK
: Data successfully uploaded to IPFS.400 Bad Request
: Failed to upload data to IPFS.HEAD /ipfs/has/{cid}
Checks if a specific CID exists on IPFS.
cid
: The CID to check for existence.200 OK
: CID exists.404 Not Found
: CID does not exist.GET /ipfs/get/{cid}
Fetches data from IPFS by CID.
cid
: The CID of the data to retrieve.200 OK
: Data successfully retrieved from IPFS.400 Bad Request
: Failed to retrieve data from IPFS.GET /get_data/{namespace}/{data_id}
Fetches data based on a namespace and data ID.
namespace
: The namespace (e.g.,keccak256
).data_id
: The ID of the data to retrieve.200 OK
: Data successfully retrieved.400 Bad Request
: Failed to retrieve data.GET /get_app
Fetches the current app state using a GIO request.
200 OK
: App state successfully retrieved.400 Bad Request
: Failed to retrieve app state.Configuration
The HTTP server can be configured via a
Config
struct that defines the HTTP address and port. The server is created using thecreate_server
function and run asynchronously with therun
function.