Skip to content

Shade Agent Docs #2547

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open

Shade Agent Docs #2547

wants to merge 23 commits into from

Conversation

PiVortex
Copy link
Contributor

@PiVortex PiVortex commented May 19, 2025

This PR adds docs for Shade Agents.

Pages:

  • Introduction
  • What can you build
  • Deploying an agent
  • Key components
  • Plugins (WIP, included some resources for now, full docs will be added later)
  • AI and NEAR page

Other changes:

  • Added media
  • Edited sidebars
  • Added chain signatures and shade agents support component

@PiVortex PiVortex marked this pull request as ready for review May 20, 2025 15:27
@PiVortex PiVortex requested a review from bucanero as a code owner May 20, 2025 15:27
@PiVortex PiVortex requested a review from mattlockyer May 20, 2025 15:27
@PiVortex PiVortex changed the title WIP: Shade agent Shade Agent Docs May 20, 2025
@PiVortex PiVortex requested a review from miaojiang May 20, 2025 15:37
Copy link
Contributor

@mattlockyer mattlockyer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking great overall, just a couple of questions and consistency points.

@trechriron trechriron temporarily deployed to shade-agent - near-docs PR #2547 May 22, 2025 10:46 — with Render Destroyed
"type": "html",
"value": "<span class='menu__link'><b><small> Shade Agents </small></b></span>"
},
"shade-agents/introduction",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@PiVortex I think Shade Agents should be under Chain Abstraction > Chain Abstraction Services. @gagdiez @bucanero wdyt?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think what we're doing with Shade Agents is too big to be put under Chain Abstraction. And I wouldn't really call it a chain abstraction product it just uses chain signatures. Happy to explore where else we can put this.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok cool, lets schedule a call to chat about this :)

Co-authored-by: Damián Parrino <[email protected]>
@trechriron trechriron temporarily deployed to shade-agent - near-docs PR #2547 May 27, 2025 17:55 — with Render Destroyed
@trechriron trechriron temporarily deployed to shade-agent - near-docs PR #2547 May 29, 2025 15:02 — with Render Destroyed

---

## Yield and Resume
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not sound like part of "AI and NEAR", but part of a different page related to AI and Smart Contracts

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dont really understand this, smart contracts are on NEAR. Do you not think it should go in this page? I think its worth mentioning here.

1. They are trustless and verifiable by creating and using a private key within a trusted execution environment (TEE), but if the TEE goes down, the accounts and funds are lost.
2. The accounts are persistent, but the agents are centralized.

Shade Agents provide verifiability, non-custody, and persistent accounts by operating in TEEs and implementing decentralized key management. Any agent running with the same code inside a TEE can access the same accounts.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Shade Agents provide verifiability, non-custody, and persistent accounts by operating in TEEs and implementing decentralized key management. Any agent running with the same code inside a TEE can access the same accounts.
Shade Agents provide verifiability by operating in TEEs, but leverage the NEAR tech stack to gain non-custody, and persistent control of accounts across multiple blockchains.
Particularly, Shade Agents register their code-hash (unique to the agent) on a NEAR smart contract, which allows them to control multiple accounts through chain signatures. This way, if the agent is deployed in a different environment, it can easily recover their accounts (as their code-hash is verifiably the same)


Shade Agents provide verifiability, non-custody, and persistent accounts by operating in TEEs and implementing decentralized key management. Any agent running with the same code inside a TEE can access the same accounts.

These agents can autonomously sign transactions across any chain, interact with AI models and external data sources, manage assets, and perform privacy-preserving, verifiable computations, offering the flexibility and performance of Web2 with the verifiability of Web3.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
These agents can autonomously sign transactions across any chain, interact with AI models and external data sources, manage assets, and perform privacy-preserving, verifiable computations, offering the flexibility and performance of Web2 with the verifiability of Web3.
Thanks to combining TEE with the NEAR tech stack, Shade Agents can autonomously sign transactions across any chain, interact with AI models and external data sources, manage assets, and perform privacy-preserving, verifiable computations, offering the flexibility and performance of Web2 with the verifiability of Web3.


When a worker agent is booted up in a TEE, the `TEE's hardware-based entropy` generates a random private key and account. This private key is exclusively used to call the agent contract, not for storing funds.

The worker agent calls the `register_worker` function on the agent contract, providing two pieces of information generated inside the TEE:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The worker agent calls the `register_worker` function on the agent contract, providing two pieces of information generated inside the TEE:
The worker agent calls the `register_worker` function on the `agent smart contract`, providing two pieces of information generated inside the TEE:

- A `remote attestation quote` (which proves it is running inside a genuine TEE).
- The Docker image's SHA256 `code hash` (to prove that the expected code is running).

If the attestation quote is valid and the code hash matches the expected code hash of the worker agent (defined during agent contract deployment), the worker agent's accounts are added to a list of valid worker agents.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
If the attestation quote is valid and the code hash matches the expected code hash of the worker agent (defined during agent contract deployment), the worker agent's accounts are added to a list of valid worker agents.
If the attestation quote is valid and the code hash matches the expected code hash of the worker agent (defined during agent contract deployment), the worker agent's accounts are added to a list of valid worker agents inside the `agent smart contract`.


If the attestation quote is valid and the code hash matches the expected code hash of the worker agent (defined during agent contract deployment), the worker agent's accounts are added to a list of valid worker agents.

Once registered, the worker agent can call the `sign_tx` function on the agent contract, enabling it to sign transactions on behalf of the Shade Agent. The Shade Agent utilizes [chain signatures](../../chain-abstraction/chain-signatures.md) for decentralized key management, allowing it to hold assets and sign transactions on nearly any chain.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Once registered, the worker agent can call the `sign_tx` function on the agent contract, enabling it to sign transactions on behalf of the Shade Agent. The Shade Agent utilizes [chain signatures](../../chain-abstraction/chain-signatures.md) for decentralized key management, allowing it to hold assets and sign transactions on nearly any chain.
Once registered, the `worker agent` can call the `sign_tx` function on the agent contract, enabling it to sign transactions. This way, the agent can leverage [chain signatures](../../chain-abstraction/chain-signatures.md) for decentralized key management, allowing it to hold assets and sign transactions on nearly any chain.


Once registered, the worker agent can call the `sign_tx` function on the agent contract, enabling it to sign transactions on behalf of the Shade Agent. The Shade Agent utilizes [chain signatures](../../chain-abstraction/chain-signatures.md) for decentralized key management, allowing it to hold assets and sign transactions on nearly any chain.

`Anyone` can deploy the same Docker image of the worker agent to a TEE and have it register as a valid worker agent and access the sign_tx function to use the same accounts. This means the accounts are never lost and the service is `always live`. Worker agents are designed to be stateless to facilitate this functionality.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`Anyone` can deploy the same Docker image of the worker agent to a TEE and have it register as a valid worker agent and access the sign_tx function to use the same accounts. This means the accounts are never lost and the service is `always live`. Worker agents are designed to be stateless to facilitate this functionality.
`Anyone` can deploy the same Docker image of the worker agent to a different TEE. Since the Docker image will have the same hash, it can be then registered as a new valid `worker` for the agent, and thus gain access to signing transactions using the agent's accounts. This means the accounts are persisted across TEE instances of the agent. To facilitate this functionality, `worker` agents are designed to be stateless


<details>

<summary>What is a TEE?</summary>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe this goes when we first say TEE, or closer to the first time we say TEE on this sub-section


#### Approve Code Hash

After contract deployment, a `code hash` is set to ensure that only worker agents running the correct worker code can register.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
After contract deployment, a `code hash` is set to ensure that only worker agents running the correct worker code can register.
After the contract is deployed, a `code hash` is set to ensure that only worker agents running the correct code (i.e. the code identified by the `code hash`) can be register in the contract.


After contract deployment, a `code hash` is set to ensure that only worker agents running the correct worker code can register.

Developers or protocols may need to modify the code running inside worker agents. When the contract is first deployed, it's initialized with an `owner` account Id. Only the owner can call the approve code hash function to update the worker agent code.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Developers or protocols may need to modify the code running inside worker agents. When the contract is first deployed, it's initialized with an `owner` account Id. Only the owner can call the approve code hash function to update the worker agent code.
Developers or protocols may need to modify the agent's code. Because of this, when the contract is initialized a `owner` is set, which is the only account allowed to approve updates to the stored `code hash`.


#### Register Worker

The register worker function verifies that the worker agent is running in a TEE and executing the expected code. Upon successful verification, the worker agent's account Id becomes registered and gains access to `gated functions` (sign_tx).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The register worker function verifies that the worker agent is running in a TEE and executing the expected code. Upon successful verification, the worker agent's account Id becomes registered and gains access to `gated functions` (sign_tx).
The register worker function verifies that the worker agent is running in a TEE and executing the expected code (as defined by the registered `code_hash`).
Upon successful verification, the worker agent's account ID becomes registered and gains access to signing transactions.


#### Sign Tx

The `sign_tx` function serves as the gateway to access the Shade Agent's multichain accounts and sign transactions. It employs `method access control` so that only valid worker agent account Ids are able to use this function. Developers should not sign transactions from the worker agents themselves (except for functions on the agent contract) as these accounts will be lost if the worker agent goes down. The magic of Shade Agents is that the multichain accounts are tied to the agent contract, which are persistent and accessible by any instance of a valid worker agent.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The `sign_tx` function serves as the gateway to access the Shade Agent's multichain accounts and sign transactions. It employs `method access control` so that only valid worker agent account Ids are able to use this function. Developers should not sign transactions from the worker agents themselves (except for functions on the agent contract) as these accounts will be lost if the worker agent goes down. The magic of Shade Agents is that the multichain accounts are tied to the agent contract, which are persistent and accessible by any instance of a valid worker agent.
The `sign_tx` function serves as the gateway to access the Shade Agent's multichain accounts and sign transactions. It employs `method access control` so that only the registered `workers` are able to use this function.
:::tip
Developers should not sign transactions from the worker agents themselves (except for functions on the agent contract) as these accounts will be lost if the worker agent goes down.
The magic of Shade Agents is that the multichain accounts are tied to the agent contract, which are persistent and accessible by any instance of a valid worker agent.
:::

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: NEW❗
Development

Successfully merging this pull request may close these issues.

7 participants