API overview
The API is packaged as a Docker image and included in your agent when it’s uploaded to Phala Cloud. The API is accessible internally by default on port 3140, but it’s not accessible from outside the TEE. When the API image boots up, it will automatically:- Derive the agent’s NEAR account (a random implicit account)
- Fund it with 0.3 NEAR from the NEAR_ACCOUNT_ID specified in the environment variables
- Register the agent in the agent contract
Setup
- TypeScript
- Python
- Other Languages
Agent account ID
Fetches the NEAR account ID of the agent.- TypeScript
- Python
- Other Languages
Agent info
Fetches the code hash and checksum for the agent.- The
code hashis the code hash of the app image running inside the agent. - The
checksumis produced by the TEE’s attestation and represents that the agent is registered.
- TypeScript
- Python
- Other Languages
Agent balance
Fetches the NEAR balance of the agent’s account in yoctoNEAR (1 NEAR = 10^24 yoctoNEAR).- TypeScript
- Python
- Other Languages
Request signature
Requests a signature from the Shade Agent for a multichain account (by calling request_signature on the agent contract).Parameters
| Parameter | Type | Description |
|---|---|---|
path | string | A string that decides which account the signature is for. Different paths derive different accounts. |
payload | string | The hash of the transaction to be signed, given as a hex string. |
keyType | string | The signature scheme: Ecdsa (secp256k1) or Eddsa (ed25519). |
Returns
The signature for the transaction.- TypeScript
- Python
- Other Languages
Response Format
Response Format
For For If you’re using the chainsig.js library, you don’t need to worry about the format of these responses since the library handles it.
Ecdsa, the function returns the components of the signature as hex strings. Note that to get r, remove the first two hex characters from big_r.Eddsa, the function returns the whole signature as a 64-byte array.Agent call
Makes a function call to the agent contract from the agent. This is used for custom contracts when you want to call a function other than request_signature. It returns the result of the function call.- TypeScript
- Python
- Other Languages
Agent view
Makes a function call to a view method (a method that does not require gas) on the agent contract. It returns the result of the function call.- TypeScript
- Python
- Other Languages
Next steps
Framework Overview
Learn about the core components of the Shade Agent Framework
Security Considerations
Review best practices for secure agent deployment