-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from APRO-com/main
feat: add the new plugin from APRO
- Loading branch information
Showing
13 changed files
with
4,133 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
dist/ | ||
node_modules/ | ||
.env | ||
*.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
PROXY_ADDRESS= | ||
PRIVATE_KEY= | ||
RPC_URL= | ||
AGENT_API_KEY= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
dist/ | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
src | ||
tsconfig.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
# ATTPs Plugin for Virtuals Game | ||
|
||
The ATTPs Plugin enables G.A.M.E agents to interact with the ATTPs Platform, providing capabilities for agent creation, data verification, and price querying functionalities. | ||
|
||
### Features | ||
- Create and register new agents on the ATTPs Platform | ||
- Verify data with agent signatures | ||
- Query price data from various feeds | ||
|
||
### Available Functions | ||
1. `createAndRegisterAgent`: Creates and registers a new agent with specified signers and settings | ||
2. `verifyData`: Verifies data with provided signatures and metadata | ||
3. `priceQuery`: Fetches price data for specific feeds and agents | ||
|
||
## Installation | ||
|
||
To install the plugin, use npm or yarn: | ||
|
||
```bash | ||
npm install @virtuals-protocol/game-attps-plugin | ||
``` | ||
|
||
or | ||
|
||
```bash | ||
yarn add @virtuals-protocol/game-attps-plugin | ||
``` | ||
|
||
## Usage | ||
|
||
### Importing the Plugin | ||
|
||
First, import the `AttpsPlugin` class from the plugin: | ||
|
||
```typescript | ||
import AttpsPlugin from "@virtuals-protocol/game-attps-plugin"; | ||
``` | ||
|
||
### Setup environment variables | ||
|
||
Set the following environment variables: | ||
- `RPC_URL`: The RPC URL for the blockchain network | ||
- `PRIVATE_KEY`: Your private key for transaction signing | ||
- `PROXY_ADDRESS`: The proxy address for the ATTPs Platform | ||
|
||
### Creating a Worker | ||
|
||
Create a worker with the necessary credentials: | ||
|
||
```typescript | ||
const attpsPlugin = new AttpsPlugin({ | ||
credentials: { | ||
proxyAddress: process.env.PROXY_ADDRESS, | ||
privateKey: process.env.PRIVATE_KEY, | ||
rpcUrl: process.env.RPC_URL, | ||
} | ||
}); | ||
``` | ||
|
||
### Creating an Agent | ||
|
||
Create an agent and add the worker to it: | ||
|
||
```typescript | ||
import { GameAgent } from "@virtuals-protocol/game"; | ||
|
||
const agent = new GameAgent("GAME_API_KEY", { | ||
name: "ATTPs Bot", | ||
goal: "Create agents, verify data, and query price data.", | ||
description: "A bot that can interact with the ATTPs Platform", | ||
workers: [attpsPlugin.getWorker({})], | ||
}); | ||
``` | ||
|
||
### Running the Agent | ||
|
||
Initialize and run the agent: | ||
|
||
```typescript | ||
(async () => { | ||
await agent.init(); | ||
|
||
while (true) { | ||
await agent.step({ | ||
verbose: true, | ||
}); | ||
} | ||
})(); | ||
``` |
Oops, something went wrong.