Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/ai/shade-agents/custom-contracts/agent-guard-rails.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
id: agent-guard-rails
title: Agents Guard Rails
sidebar_label: Agent Guard Rails
description: "TODO"
---
6 changes: 6 additions & 0 deletions docs/ai/shade-agents/custom-contracts/near-agents.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
id: near-agents
title: NEAR Agents
sidebar_label: NEAR Agents
description: "TODO"
---
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
---
id: custom-agent-contract
title: Custom Agent Contract
sidebar_label: Custom Agent Contract
description: This document explains how to create and deploy a custom Shade Agent contract on NEAR, including compiling, deploying, and interacting with the contract.
id: overview
title: Overview
sidebar_label: Overview
description: "This document explains how to create and deploy a custom Shade Agent contract on NEAR, including compiling, deploying, and interacting with the contract."
---

import { SigsSupport } from '@site/src/components/sigsSupport';
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

Expand All @@ -17,11 +16,11 @@ In some cases, you may want to deploy a custom agent contract. This allows for m

To create a custom agent contract, we recommend you fork the [sandbox contract](https://github.com/NearDeFi/shade-agent-js/tree/main/contracts/sandbox). This is the agent contract that's deployed under the hood when using the `shade-agent-cli`. For testing locally, you will need to maintain a separate similar contract that does not implement the agent registration flow; for this, you can follow the structure of the [proxy contract](https://github.com/NearDeFi/shade-agent-js/tree/main/contracts/proxy).

Inside this contract, you will create your own functions. For building contracts on NEAR, see our [smart contract docs](../../smart-contracts/quickstart.md). You can only develop agent contracts in Rust.
Inside this contract, you will create your own functions. For building contracts on NEAR, see our [smart contract docs](../../../smart-contracts/quickstart.md). You can only develop agent contracts in Rust.

With the quickstart template, an agent can sign any transaction. You may want to limit your agent to only be able to sign transactions for a limited set of functions or actions. For this, we recommend building your transactions inside your agent contract with the [omni-transaction-rs](https://github.com/near/omni-transaction-rs) library. In such case, you should make the `request_signature` function private.

For developing Shade Agents that just interact with NEAR, you can remove the `request_signature` function. The agent will make function calls to the contract directly. Make sure that you restrict relevant functions to only be allowed to be called by the agent. If you want to interact with existing contracts on NEAR that do not implement agent registration, you can leverage [cross contract calls](../../smart-contracts/anatomy/crosscontract.md).
For developing Shade Agents that just interact with NEAR, you can remove the `request_signature` function. The agent will make function calls to the contract directly. Make sure that you restrict relevant functions to only be allowed to be called by the agent. If you want to interact with existing contracts on NEAR that do not implement agent registration, you can leverage [cross contract calls](../../../smart-contracts/anatomy/crosscontract.md).

How you compile the contract depends on your operating system.

Expand Down Expand Up @@ -54,7 +53,7 @@ How you compile the contract depends on your operating system.

## Deploying the Custom Contract

To deploy your agent with the custom contract, add the `--wasm` flag when using the `shade-agent-cli`, specifying the path to your wasm file. Depending on the size of the wasm, you may require more NEAR to deploy the contract. This can be done using the `--funding` flag, followed by the amount of NEAR (100KB = 1 NEAR).
To deploy your agent with the custom contract, add the `--wasm` flag when using the Shade Agent CLI, specifying the path to your wasm file. Depending on the size of the wasm, you may require more NEAR to deploy the contract. This can be done using the `--funding` flag, followed by the amount of NEAR (100KB = 1 NEAR).

Here is an example:

Expand All @@ -66,16 +65,4 @@ shade-agent-cli --wasm contract/target/near/contract.wasm --funding 5

## Interacting with Custom Contract

To call a function on your custom agent contract, use the `agentCall` function provided by `shade-agent-js`. Supply the `methodName` and the `args` to the function call.

```js
const res = await agentCall({
methodName: 'example_function',
args: {
arg1,
arg2,
},
});
```

<SigsSupport />
To call a function on your custom agent contract, use the `agentCall` function provided by the Shade Agent API. Please refer to the [relevant docs](../framework/api.md#agent-call) for calling the contract in your desired language.
6 changes: 6 additions & 0 deletions docs/ai/shade-agents/custom-contracts/yield-for-agent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
id: yield-for-agent
title: Yield for Agent
sidebar_label: Yield for Agent
description: "TODO"
---
43 changes: 24 additions & 19 deletions docs/ai/shade-agents/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,58 +10,63 @@ With their extensive list of features, Shade Agents unlock a wide range of new u
## Shade Agent Features

Shade Agents are:
- **AI Powered** - Verifiably access LLMs.

- **Multichain** - Can hold any crypto asset and sign transactions on any chain.

- **Non-custodial** - No one entity controls the private keys of the agent (MPC signing).

- **Verifiable** - Agent code is known and executes as expected; no one can tamper with the agent.

- **Multichain** - Can hold any crypto asset and sign transactions on any chain.

- **AI Powered** - Can verifiably access LLMs.

- **Confidential** - Inputs and state of the agent can be private.

- **Flexible** - Interact with off-chain data and APIs beyond blockchain VM limits.

- **Low cost** - Run intensive computation cheaply without gas limits (~20% TEE overhead compared to standard servers).

---

## Agentic Protocols

Shade Agents enable a new paradigm of decentralized applications where a major component of the logic for a protocol is run in a verifiable off-chain environment. This allows for more flexibility in terms of computation, cost, privacy, and the data you have access to. Agentic Protocols are designed to be autonomous, proactive, and intelligent.
Shade Agents enable a new paradigm of decentralized applications where a component of the logic for a protocol is run in a verifiable off-chain environment. This allows for more flexibility in terms of computation, cost, privacy, and the data you have access to. Agentic Protocols are designed to be autonomous, proactive, and intelligent.

- A Yield Optimizer that earns optimal yield on assets across various DeFi protocols on different chains and autonomously rebalances according to a verifiable algorithm.
- A private DAO agent on Ethereum Mainnet that takes votes confidentially and publishes the end result in a single transaction.
- A Yield Optimizer that earns optimal yield on assets across various DeFi protocols on different chains and autonomously rebalances according to a verifiable algorithm to get users the best rate, always.
- A staking protocol that can implement complex reward mechanics.
- A private DAO agent on Ethereum Mainnet that takes votes confidentially and publishes the end result in a single transaction.
- A smart contract that can verifiably book users plane tickets by calling the contract with funds and passing secrets (passport information and email address) to the agent directly.

---

## Flexible Oracles

Since Shade Agents can access off-chain data and APIs, they make great cheap, flexible, quick-to-spin-up oracles.

- A custom data oracle where app developers list a number of different sources, a consensus mechanism (4 of 5 sources state the same data), and the frequency with which data is pushed (or on demand), which allows smart contracts to access any data verifiably.
- A prediction market resolver agent that uses an LLM to interpret multiple webpages and APIs to resolve markets quickly and accurately.
- Verifiable randomness oracle.

---

## Smart Contracts using LLMs

Shade Agents allow you to access LLMs from a smart contract that lives on any chain. The LLM and agent are both running in a TEE, so we know that the response from the agent is actually from an LLM and its response is a function of the provided inputs.

There are two main flows:

- The smart contract emits an event during a function call, the agent indexes this, uses the LLM to make a decision, and the agent calls a function on the contract with the result that is restricted to the agent's address.
- Users interact with the agent which makes decisions via the LLM and carries out certain on-chain actions based upon the decision (transfers, function calls, swaps, etc.).
1) The smart contract emits an event during a function call, the agent indexes this, uses the LLM to make a decision, and the agent calls a function on the contract with the result that is restricted to the agent's address.
2) Users interact with the agent which makes decisions via the LLM and carries out certain on-chain actions based upon the decision (transfers, function calls, swaps, etc.).

With this, you could create:
- A DAO with an AI President that makes decisions based on aggregate user opinions, historical context, and user reputation formulated from on-chain and off-chain data.
- A decentralized social platform that uses an LLM to moderate content.
- A treasury that trades assets according to news, sentiment, and historical price.

---

## Custom Authentication

Shade agents allow users to control accounts through ways other than a private key and have it be non-custodial.

- A prediction market that lets you create new markets and place bets all from Twitter (X).
- A more secure social onboarding experience where you can log in via Google, Email, etc.
- A Telegram bot for trading within a group chat.


## Flexible Oracles

Since Shade Agents can access off-chain data and APIs, they make great cheap, flexible, quick-to-spin-up oracles.

- A custom data oracle where app developers list a number of different sources, a consensus mechanism (4 of 5 sources state the same data), and the frequency with which data is pushed (or on demand), which allows smart contracts to access any data verifiably.
- A prediction market resolver agent that uses an LLM to interpret multiple webpages and APIs to resolve markets quickly and accurately.
- Verifiable randomness oracle.
- A Telegram bot for trading within a group chat.
Loading
Loading