A production-ready LangChain toolkit for Stability blockchain interactions without gas fees
Project description
Stability Toolkit for LangChain
A production-ready toolkit that enables AI agents to interact with the Stability blockchain without gas fees or cryptocurrency requirements.
✨ Production-Ready Features (Latest Update)
- 🔑 Environment Variable Support: Set
STABILITY_API_KEYfor production deployments - 🛠️ Flexible Configuration: Initialize with custom API keys or use environment variables
- 🔒 Security Enhancements: API key sanitization in logs and error messages
- ⚠️ Production Warnings: Helpful guidance for production vs. development usage
- 📚 Comprehensive Documentation: Clear examples and best practices
🚀 Quick Start
Installation
pip install langchain-core requests
Basic Usage
from stability_toolkit import StabilityToolkit
# Option 1: Using environment variable (recommended for production)
export STABILITY_API_KEY="your-api-key"
toolkit = StabilityToolkit()
# Option 2: Direct API key (for development/testing)
toolkit = StabilityToolkit(api_key="your-api-key")
# Get all tools
tools = toolkit.get_tools()
🔑 API Key Setup
Getting Your FREE API Key
- Visit the Stability Protocol Portal: https://portal.stabilityprotocol.com/
- Sign up for a free account
- Generate your API key(s)
Free Tier Limits
- 🔢 API Keys: Up to 3 keys per account
- ✍️ Write Transactions: 1,000 per month
- 📖 Read Operations: 200 per minute
- 💰 Cost: Completely FREE
Setting Up Your API Key
Option 1: Environment Variable (Recommended)
# Add to your shell profile (.bashrc, .zshrc, etc.)
export STABILITY_API_KEY="your-api-key-from-portal"
# Or set for current session
export STABILITY_API_KEY="your-api-key-from-portal"
Option 2: Direct Configuration
from stability_toolkit import StabilityToolkit
toolkit = StabilityToolkit(api_key="your-api-key-from-portal")
Option 3: Development/Testing
# Uses "try-it-out" key with limited functionality
toolkit = StabilityToolkit()
🛠️ Available Tools
- StabilityWriteTool - Send messages to blockchain
- StabilityReadTool - Read from smart contracts
- StabilityWriteContractTool - Write to smart contracts
- StabilityDeployTool - Deploy Solidity contracts
🔧 API Key Configuration
Environment Variable (Recommended)
export STABILITY_API_KEY="your-api-key"
Programmatic Configuration
toolkit = StabilityToolkit(api_key="your-api-key")
Development/Testing
# Uses "try-it-out" key with limited functionality
toolkit = StabilityToolkit()
🔒 Security Features
- API Key Sanitization: Keys are automatically sanitized in logs and error messages
- Environment Variable Support: Secure configuration without hardcoding keys
- Production Warnings: Clear guidance on API key limitations and best practices
📞 Support & Contact
- Support Email: contact@stabilityprotocol.com
- API Portal: https://portal.stabilityprotocol.com/
- Documentation: Comprehensive examples and usage patterns included
StabilityToolkit is a LangChain-compatible toolkit that enables AI agents to interact directly with the Stability Blockchain through Zero Gas Transaction (ZKT) API endpoints. It includes tools for submitting simple messages, interacting with smart contracts (read/write), and deploying contracts — all without requiring gas fees or cryptocurrency.
🚀 Features
- ✅ Write plain messages to Stability (ZKT)
- ✅ Read smart contract data (ZKT Simple - view)
- ✅ Call smart contract functions (ZKT Simple - write)
- ✅ Deploy new smart contracts (ZKT Contract)
- ✅ Works with public and authenticated endpoints
🛠 Tools Overview
| Tool Name | Description |
|---|---|
StabilityWriteTool |
POSTs a string message to the blockchain |
StabilityReadTool |
Reads data from smart contracts via ABI & method |
StabilityWriteContractTool |
Calls smart contract write methods |
StabilityDeployTool |
Deploys Solidity smart contracts to Stability |
🧱 Installation
pip install langchain openai requests
🧪 Example Usage
from langchain.chat_models import ChatOpenAI
from langchain.agents import initialize_agent
from stability_toolkit import StabilityToolkit
llm = ChatOpenAI(model="gpt-4o", temperature=0)
toolkit = StabilityToolkit()
agent = initialize_agent(toolkit.get_tools(), llm, agent_type="zero-shot-react-description")
response = agent.run("Deploy a contract that stores a greeting and a value")
print(response)
🧪 Running Tests
# Run live blockchain tests
python -m unittest test_stability_toolkit_live.py
# Run LangChain integration tests
python -m unittest test_stability_toolkit_langchain.py
🔐 API Keys
- Public endpoint:
https://rpc.stabilityprotocol.com/zkt/try-it-out - Get your free personal key at portal.stabilityprotocol.com
- Replace
try-it-outin URLs with your API key to sign with your own identity.
📄 API Docs
For full OpenAPI documentation, see: https://stabilityprotocol.github.io/stability-api-docs
💡 Contribution Ideas
- Add retry logic or exponential backoff
- Support transaction result polling with
wait=True - Extend Toolkit with
StatusToolorVerifyTool - Add automatic schema validation with
pydantic
📬 Contact
For questions, feature requests, or contributions, reach out via stabilityprotocol.com
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 stability_toolkit-1.0.0.tar.gz.
File metadata
- Download URL: stability_toolkit-1.0.0.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3e8e5e546d03eaae10aeabdff4656c021e046385e6ef048c6df002ddaf2aceac
|
|
| MD5 |
1a3a65cd4335eb0fdab68097dcf005d7
|
|
| BLAKE2b-256 |
e8f05f4aa67daec210461d8a01b39b1fd40df599fdc0c2519e7d7ceb184cfb40
|
File details
Details for the file stability_toolkit-1.0.0-py3-none-any.whl.
File metadata
- Download URL: stability_toolkit-1.0.0-py3-none-any.whl
- Upload date:
- Size: 6.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3db03067b8b5f4872113a7a68f253f13dca3addb010709ba478cb2151b25914f
|
|
| MD5 |
cd9c85cffeb905da95e4b0504b11e12e
|
|
| BLAKE2b-256 |
25f039836d59e8848ce93a76191d1c51883a9e060f47cd8eebd6ffc12a759c89
|