No project description provided
Project description
Wrappers around CompassLabs' API to provide support for the GAME SDK.
Description
Compass Labs runs an API that allows users to interact and transact on DeFi with ease.
This API allows users to intuitively and transparently read information from decentralised exchanges. Users can then use the API to build a transaction, which can be safely and securely signed and submitted by the user once the transaction is fully built by the API.
This allows users to retain full custody of their funds, and full visibility of where their funds are moved.
Virtuals GAME SDK
The GAME Framework is a modular agentic framework that enables an agent to plan actions and make decisions autonomously based on the information provided to it.
Compass Labs publishes a library containing Python functions which allow clients to easily interact with their API (compass.api_client). This package is a wrapper around that package, presenting the API endpoints as tools for the GAME agents to utilise. This means that any agent can be given the power to transact on-chain - without any difficult prompt engineering or further tools that requires the agent to decipher Solidity, or the mixed technical and financial documentation of decentralised platforms!
Examples
Setup
Install this package using your favourite package manager, e.g.
pip install compass.virtuals_sdk
Then create a .env file at the root of whatever project directory you want to use for you virtuals code.
Include the following variables:
ETHEREUM_RPC_URL=<JSON RPC NODE URL>
ETHEREUM_PRIVATE_KEY=<PRIVATE KEY>
GAME_API_KEY=<api key>
You can get an rpc url from a provider like Anker, or check your Metamask settings to see which node it talks to.
Your private key can be obtained from whatever wallet you use. We encourage you to read the code of this package to see how the private key is handled; it is never sent on the network, and is entirely used locally to sign transactions for the agent. The Game framework never sees the private key, only knows that it can request for a transaction to be signed and sent. Similarly, Compass Labs will never see your private key.
However: by giving the agent the ability to send transactions on your wallet, all your funds in the associated wallet are liable to be lost! The agents you build will have full power to submit any transaction on behalf of that wallet. A well-tuned agent can make money; but a recklessly prompted one (e.g. "send all my tokens to Vitalik"!) would be capable of transferring funds recklessly. Compass Labs accepts no liability for the funds associated with any wallet that an agent is given the key to.
The Game SDK API can be obtained from the Virtuals Game Console.
The Sample Agent
If you want to immediately try out the capabilities offered by this SDK then you can run our simple agent provided in our package.
python -c 'import compass.virtuals_sdk.simple_agent as s; s.compass_agent.compile(); s.compass_agent.run()'
You should see that the agent first figures out its address, then checks all of its capabilities. It will proceed to check some prices, and finally send some transactions! (Tip: You can easily prevent the agent from having access to funds by providing an invalid PRIVATE_KEY in the .env file.)
Using the API in your own agents
We suggest creating one worker per protocol that our API supports, and then one worker for interacting with your wallet.
You can do this by importing our classes from compass.virtuals_sdk.api_wrapper and compass.virtuals_sdk.wallet.
For example, the simple agent code looks like this:
from game_sdk.game.agent import Agent, WorkerConfig
from compass.api_client import Chain
from compass.virtuals_sdk.api_wrapper import (
AaveV3,
Aerodrome,
Others,
UniswapV3,
)
from compass.virtuals_sdk.config import api_key
from compass.virtuals_sdk.shared_defaults import get_state_fn
from compass.virtuals_sdk.wallet import Wallet
available_chains = [i.value for i in Chain]
worker_instruction = "Interact with your assigned defi protocol."
compass_agent = Agent(
api_key=api_key,
name="A defi agent that can operate on multiple defi exchanges",
agent_goal=f"Make some money. Your ethereum wallet address is can be obtained via the wallet worker.When you need to set the sender or user of a transaction request, set if to to your wallet address. When you must choose between chains, choose one of {available_chains}",
agent_description="defi agent",
get_agent_state_fn=get_state_fn,
workers=[
WorkerConfig(cls.id, cls.worker_description, cls.get_state_fn, cls.action_space)
for cls in [Wallet, Aerodrome, AaveV3, Others, UniswapV3]
],
)
Note that each of the classes that we provide for suggested WorkerConfig's contains an id, worker_description, get_state_fn, and action_space. You can change any of these as you like. The action_space is the only really crucial part.
If you would like to pick and choose which tools you use with which agents, then as well as all tools being listed in the respective action_space, each tool is set as a method on the helper classes. For example, you can get the game_sdk Function instance for checking on-chain balances from compass.virtuals_sdk.api_wrapper.Others.generic_balance_get.
Have fun building with Compass Labs' DeFi API!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file compass_virtuals_sdk-0.1.78.tar.gz.
File metadata
- Download URL: compass_virtuals_sdk-0.1.78.tar.gz
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5fd64abe29a8766e4d7dd22ab1ce956bddcd87dfba11676203d4f1ec3d574ca3
|
|
| MD5 |
2394a285834780a941368ed47cdcc433
|
|
| BLAKE2b-256 |
b85537ca4333bbef050704726a9db49203dd4dfe35069fa73fe6d372d2f71b1f
|
File details
Details for the file compass_virtuals_sdk-0.1.78-py3-none-any.whl.
File metadata
- Download URL: compass_virtuals_sdk-0.1.78-py3-none-any.whl
- Upload date:
- Size: 9.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ccf658ff73a5c377099918aaad8048f084c26903887e866e2321f7a8b324981c
|
|
| MD5 |
3942523a42c1f5deecf9c72b1a175238
|
|
| BLAKE2b-256 |
44729254ee75452cb29798f245ce5423012b509f5b03628ea734e0d1f62e4fa3
|