Secret Network smart contracts used for Secret AI subscriptions, workers, and rewards management.
Secret Network smart contracts are integrated with Secret AI in order to track and manage Secret AI Subscriptions, Workers, and Rewards Management. This is actively in development; you can view the secret-ai-contracts
repository here for Secret Network smart contract integrations using Secret AI SDK.
WorkerManager contract registers, manages and assigns Confidential GPU Workers
The Worker Manager Contract is designed for managing workers in a distributed environment. Admins can register, update, or remove workers, while workers themselves can update their information such as payment wallets, IP addresses, or worker types. Additionally, the contract allows querying worker details and reports.
The contract stores:
Admin Address: The account that has permission to manage workers and modify critical state data.
Workers: A mapping from an IP address to the worker's details, including payment wallet, attestation report, and worker type.
Note: Most ExecuteMsg
messages can only be called by the admin of the contract, except for specific updates that are restricted to the worker's payment wallet.
RegisterWorker
Action: Registers a new worker in the contract's state.
Parameters:
ip_address
(String): The IP address of the worker.
payment_wallet
(String): The wallet address to receive payments.
attestation_report
(String): The attestation report for the worker.
worker_type
(String): The type of worker being registered.
SetWorkerWallet
Action: Updates the payment wallet address of a worker.
Parameters:
ip_address
(String): The IP address of the worker.
payment_wallet
(String): The new wallet address.
Permission: Only the owner of the wallet can update this.
SetWorkerAddress
Action: Updates the IP address of a worker.
Parameters:
new_ip_address
(String): The new IP address.
old_ip_address
(String): The current IP address.
Permission: Only the owner of the wallet can update this.
SetWorkerType
Action: Updates the type of a worker.
Parameters:
ip_address
(String): The IP address of the worker.
worker_type
(String): The new worker type.
Permission: Only the owner of the wallet can update this.
RemoveWorker
Action: Removes a worker from the contract's state.
Parameters:
ip_address
(String): The IP address of the worker to remove.
Permission: Only the owner of the wallet can remove the worker.
ReportLiveliness
Action: Allows workers to report their liveliness status.
Status: Not Implemented.
ReportWork
Action: Allows workers to report work performed.
Status: Not Implemented.
GetWorkers
Action: Retrieves all registered workers.
Parameters:
signature
(String): A valid query signature from the subscriber's public key.
subscriber_public_key
(String): The public key of the subscriber.
Response:
workers
(Vec<Worker>): A list of all registered workers.
GetModels
Action: Retrieves the list of available models.
Parameters: None.
Response:
models
(Vec<String>): A list of model identifiers.
GetURLs
Action: Retrieves the URLs for accessing specific models.
Parameters:
model
(Option<String>): The identifier of the model (optional).
Response:
urls
(Vec<String>): A list of URLs.
GetLivelinessChallenge
Action: Retrieves a liveliness challenge to verify worker activity.
Parameters: None.
Response:
challenge
(String): A challenge string for workers to respond to.
Status: Not Implemented.
The RewardsManager
contract is used to track and disperse rewards to Worker. Workers report the amount of work (e.g. number of input and output tokens) and the user payments are distributed between the workers' operators according to their share of work performed.
RewardsManager
is actively in development and is expected to be integrated in 2025.
The Secret AI Subscription Manager Contract is designed for subscription-based use cases, where an admin manages subscribers using their public keys. The contract keeps track of registered subscribers and API keys, ensuring that only authorized admins can manage them.
The contract stores:
Admin Address: The account that has permission to register or remove subscribers, manage API keys, and change admin rights.
Subscribers: A mapping from a public key to the subscriber's status (active or inactive).
API Keys: A mapping of hashed API keys used for external access control. The API keys are stored as SHA-256 hashes to enhance security.
Note: All ExecuteMsg
messages can only be called by the admin of the contract.
RegisterSubscriber
Action: Registers a new subscriber in the contract's state.
Parameters:
public_key
(String): The public key of the subscriber.
RemoveSubscriber
Action: Removes a subscriber from the contract's state.
Parameters:
public_key
(String): The public key of the subscriber.
SetAdmin
Action: Updates the admin of the contract.
Parameters:
public_key
(String): The public key of the new admin.
AddApiKey
Action: Adds a new API key (its SHA-256
hash) to the contract's state.
Parameters:
api_key
(String): The plaintext API key.
RevokeApiKey
Action: Revokes an existing API key by removing its hash.
Parameters:
api_key
(String): The plaintext API key.
SubscriberStatus
Action: Verifies whether a subscriber is active by checking if their public key is stored in the contract.
Parameters:
public_key
(String): The public key of the subscriber.
Response:
active
(bool): Returns true
if the subscriber is active, otherwise false
.
ApiKeysWithPermit
Action: Returns the list of all stored API keys.
Parameters:
permit
(Permit): A valid admin-signed permit.
Response:
api_keys
(Vec<ApiKey>): A list of hashed API keys.