NetworkConstants
in package
HTTP Status Code Constants
This class contains HTTP status codes used throughout the SDK for network request handling and error detection. These constants ensure consistent handling of HTTP responses across different API interactions.
References:
- RFC 7231 (HTTP/1.1): https://tools.ietf.org/html/rfc7231
- RFC 6585 (Additional HTTP Status Codes): https://tools.ietf.org/html/rfc6585
Note: This class cannot be instantiated. All constants are static and should be accessed directly via the class name.
Table of Contents
Constants
- DEFAULT_SOROBAN_TIMEOUT_SECONDS = 300
- Default timeout for Soroban contract method calls in seconds.
- DEFAULT_TIME_BOUNDS_OFFSET_SECONDS = 10
- Default time bounds offset in seconds.
- HTTP_BAD_REQUEST = 400
- HTTP 400 Bad Request status code.
- HTTP_CONFLICT = 409
- HTTP 409 Conflict status code.
- HTTP_FORBIDDEN = 403
- HTTP 403 Forbidden status code.
- HTTP_INTERNAL_SERVER_ERROR = 500
- HTTP 500 Internal Server Error status code.
- HTTP_NOT_FOUND = 404
- HTTP 404 Not Found status code.
- HTTP_OK = 200
- HTTP 200 OK status code.
- HTTP_SERVICE_UNAVAILABLE = 503
- HTTP 503 Service Unavailable status code.
Constants
DEFAULT_SOROBAN_TIMEOUT_SECONDS
Default timeout for Soroban contract method calls in seconds.
public
mixed
DEFAULT_SOROBAN_TIMEOUT_SECONDS
= 300
This defines the maximum time a transaction remains valid after submission. After this timeout, the transaction will no longer be accepted by the network.
Default: 300 seconds (5 minutes)
Unit: seconds
Note: This timeout represents the transaction validity window, not the actual execution time. Most contract invocations complete within a few seconds, but the longer window allows for network congestion and retry scenarios.
Reference: Soroban transaction lifecycle
Tags
DEFAULT_TIME_BOUNDS_OFFSET_SECONDS
Default time bounds offset in seconds.
public
mixed
DEFAULT_TIME_BOUNDS_OFFSET_SECONDS
= 10
Used for transaction validity windows to account for clock drift between client and server. Transactions are typically given a validity window that starts slightly in the past to account for minor time discrepancies.
Default: 10 seconds before current time
Unit: seconds
Example:
- Start time: current_time - 10 seconds
- End time: current_time + timeout
This prevents transactions from being rejected due to minor clock synchronization issues between client and network nodes.
Reference: Transaction time bounds best practices
Tags
HTTP_BAD_REQUEST
HTTP 400 Bad Request status code.
public
mixed
HTTP_BAD_REQUEST
= 400
Indicates that the server cannot process the request due to client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).
Common causes:
- Invalid transaction format
- Missing required parameters
- Malformed JSON
Tags
HTTP_CONFLICT
HTTP 409 Conflict status code.
public
mixed
HTTP_CONFLICT
= 409
Indicates that the request could not be completed due to a conflict with the current state of the target resource.
Common causes:
- Transaction already submitted
- Resource version conflict
- State transition not allowed
Tags
HTTP_FORBIDDEN
HTTP 403 Forbidden status code.
public
mixed
HTTP_FORBIDDEN
= 403
Indicates that the server understood the request but refuses to authorize it. Unlike 401, authentication will not help.
Common causes:
- Insufficient permissions
- Rate limiting
- IP blacklisting
Tags
HTTP_INTERNAL_SERVER_ERROR
HTTP 500 Internal Server Error status code.
public
mixed
HTTP_INTERNAL_SERVER_ERROR
= 500
Indicates that the server encountered an unexpected condition that prevented it from fulfilling the request. This is a generic error message when no more specific message is suitable.
Common causes:
- Server misconfiguration
- Unhandled exception
- Database errors
Tags
HTTP_NOT_FOUND
HTTP 404 Not Found status code.
public
mixed
HTTP_NOT_FOUND
= 404
Indicates that the server cannot find the requested resource.
Common causes:
- Account doesn't exist
- Transaction not found
- Invalid endpoint
Tags
HTTP_OK
HTTP 200 OK status code.
public
mixed
HTTP_OK
= 200
Indicates that the request succeeded. The meaning of success depends on the HTTP method:
- GET: Resource fetched successfully
- POST: Resource created or action completed
This is the standard success response code.
Tags
HTTP_SERVICE_UNAVAILABLE
HTTP 503 Service Unavailable status code.
public
mixed
HTTP_SERVICE_UNAVAILABLE
= 503
Indicates that the server is not ready to handle the request. This is typically a temporary condition, such as:
- Server maintenance
- Server overload
- Network issues
The response may include a Retry-After header indicating when the client should retry.