proofgate-agentkit 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- proofgate_agentkit-0.1.0/LICENSE +21 -0
- proofgate_agentkit-0.1.0/PKG-INFO +343 -0
- proofgate_agentkit-0.1.0/README.md +312 -0
- proofgate_agentkit-0.1.0/proofgate_agentkit/__init__.py +30 -0
- proofgate_agentkit-0.1.0/proofgate_agentkit/action_provider.py +311 -0
- proofgate_agentkit-0.1.0/proofgate_agentkit/config.py +33 -0
- proofgate_agentkit-0.1.0/proofgate_agentkit/exceptions.py +48 -0
- proofgate_agentkit-0.1.0/proofgate_agentkit/py.typed +0 -0
- proofgate_agentkit-0.1.0/proofgate_agentkit/wrapper.py +290 -0
- proofgate_agentkit-0.1.0/pyproject.toml +63 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 ProofGate
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: proofgate-agentkit
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: ProofGate Action Provider for Coinbase AgentKit - Blockchain guardrails for AI agents
|
|
5
|
+
License: MIT
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Keywords: proofgate,agentkit,coinbase,blockchain,security,ai-agent,guardrails
|
|
8
|
+
Author: bytes0xcr6
|
|
9
|
+
Author-email: 102038261+bytes0xcr6@users.noreply.github.com
|
|
10
|
+
Requires-Python: >=3.10,<4.0
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
21
|
+
Classifier: Topic :: Security
|
|
22
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
23
|
+
Requires-Dist: coinbase-agentkit (>=0.1.0,<0.2.0)
|
|
24
|
+
Requires-Dist: proofgate (>=0.1.0,<0.2.0)
|
|
25
|
+
Requires-Dist: pydantic (>=2.0.0,<3.0.0)
|
|
26
|
+
Project-URL: Documentation, https://docs.proofgate.xyz
|
|
27
|
+
Project-URL: Homepage, https://github.com/proofgate/proofgate-agentkit
|
|
28
|
+
Project-URL: Repository, https://github.com/proofgate/proofgate-agentkit
|
|
29
|
+
Description-Content-Type: text/markdown
|
|
30
|
+
|
|
31
|
+
# proofgate-agentkit
|
|
32
|
+
|
|
33
|
+
> ProofGate Action Provider for Coinbase AgentKit - Blockchain guardrails for AI agents
|
|
34
|
+
|
|
35
|
+
[](https://pypi.org/project/proofgate-agentkit/)
|
|
36
|
+
[](https://www.python.org/downloads/)
|
|
37
|
+
[](https://opensource.org/licenses/MIT)
|
|
38
|
+
|
|
39
|
+
## What is this?
|
|
40
|
+
|
|
41
|
+
`proofgate-agentkit` integrates [ProofGate](https://proofgate.xyz) with [Coinbase AgentKit](https://github.com/coinbase/agentkit), providing security guardrails for AI agent blockchain transactions.
|
|
42
|
+
|
|
43
|
+
**ProofGate validates transactions before your AI agent executes them**, preventing:
|
|
44
|
+
|
|
45
|
+
- 🚫 **Wallet drains** from prompt injection attacks
|
|
46
|
+
- 🚫 **Infinite approvals** to malicious contracts
|
|
47
|
+
- 🚫 **Excessive spending** beyond daily limits
|
|
48
|
+
- 🚫 **High slippage** swaps that lose money
|
|
49
|
+
|
|
50
|
+
## Installation
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
pip install proofgate-agentkit
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Or with Poetry:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
poetry add proofgate-agentkit
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Quick Start
|
|
63
|
+
|
|
64
|
+
### 1. As an Action Provider
|
|
65
|
+
|
|
66
|
+
Add ProofGate as an action provider to validate transactions explicitly:
|
|
67
|
+
|
|
68
|
+
```python
|
|
69
|
+
from coinbase_agentkit import AgentKit, AgentKitConfig
|
|
70
|
+
from proofgate_agentkit import proofgate_action_provider
|
|
71
|
+
|
|
72
|
+
# Create the ProofGate action provider
|
|
73
|
+
proofgate = proofgate_action_provider(
|
|
74
|
+
api_key="pg_your_api_key", # Get from proofgate.xyz/dashboard
|
|
75
|
+
guardrail_id="your_guardrail", # Create at proofgate.xyz/guardrails
|
|
76
|
+
chain_id=8453, # Base mainnet
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
# Add to your AgentKit configuration
|
|
80
|
+
agent = AgentKit(
|
|
81
|
+
config=AgentKitConfig(
|
|
82
|
+
# ... your config
|
|
83
|
+
),
|
|
84
|
+
action_providers=[
|
|
85
|
+
proofgate,
|
|
86
|
+
# ... other providers
|
|
87
|
+
],
|
|
88
|
+
)
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Now your agent has access to these actions:
|
|
92
|
+
- `validate_transaction` - Validate a transaction before execution
|
|
93
|
+
- `check_agent_trust` - Check a wallet's trust score
|
|
94
|
+
|
|
95
|
+
### 2. Wrap Existing Providers
|
|
96
|
+
|
|
97
|
+
Automatically validate all transactions from any action provider:
|
|
98
|
+
|
|
99
|
+
```python
|
|
100
|
+
from coinbase_agentkit.action_providers import erc20_action_provider, wallet_action_provider
|
|
101
|
+
from proofgate_agentkit import wrap_with_proofgate, ProofGateConfig
|
|
102
|
+
|
|
103
|
+
config = ProofGateConfig(
|
|
104
|
+
api_key="pg_your_api_key",
|
|
105
|
+
guardrail_id="your_guardrail",
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
# Wrap providers - all their transaction actions will be validated
|
|
109
|
+
safe_erc20 = wrap_with_proofgate(erc20_action_provider(), config)
|
|
110
|
+
safe_wallet = wrap_with_proofgate(wallet_action_provider(), config)
|
|
111
|
+
|
|
112
|
+
agent = AgentKit(
|
|
113
|
+
config=AgentKitConfig(...),
|
|
114
|
+
action_providers=[safe_erc20, safe_wallet],
|
|
115
|
+
)
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### 3. Wrap the Wallet Provider
|
|
119
|
+
|
|
120
|
+
Validate ALL transactions at the wallet level:
|
|
121
|
+
|
|
122
|
+
```python
|
|
123
|
+
from coinbase_agentkit.wallet_providers import CdpWalletProvider
|
|
124
|
+
from proofgate_agentkit import ProofGateWrapper, ProofGateConfig
|
|
125
|
+
|
|
126
|
+
# Create wallet provider
|
|
127
|
+
wallet = CdpWalletProvider(...)
|
|
128
|
+
|
|
129
|
+
# Wrap with ProofGate
|
|
130
|
+
config = ProofGateConfig(
|
|
131
|
+
api_key="pg_your_api_key",
|
|
132
|
+
guardrail_id="your_guardrail",
|
|
133
|
+
)
|
|
134
|
+
wrapper = ProofGateWrapper(config)
|
|
135
|
+
safe_wallet = wrapper.wrap(wallet)
|
|
136
|
+
|
|
137
|
+
# Now every send_transaction() call is validated first
|
|
138
|
+
agent = AgentKit(
|
|
139
|
+
config=AgentKitConfig(...),
|
|
140
|
+
wallet_provider=safe_wallet,
|
|
141
|
+
)
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## Configuration
|
|
145
|
+
|
|
146
|
+
```python
|
|
147
|
+
from proofgate_agentkit import ProofGateConfig
|
|
148
|
+
|
|
149
|
+
config = ProofGateConfig(
|
|
150
|
+
# Required
|
|
151
|
+
api_key="pg_xxx", # Your ProofGate API key
|
|
152
|
+
|
|
153
|
+
# Optional
|
|
154
|
+
guardrail_id="xxx", # Default guardrail to use
|
|
155
|
+
chain_id=8453, # Default chain (8453 = Base)
|
|
156
|
+
base_url="https://...", # Custom API URL
|
|
157
|
+
timeout=30.0, # Request timeout (seconds)
|
|
158
|
+
fail_open=False, # Allow tx on API failure (default: False)
|
|
159
|
+
log_validations=True, # Log validation results (default: True)
|
|
160
|
+
)
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### Fail Open vs Fail Closed
|
|
164
|
+
|
|
165
|
+
By default, `fail_open=False` means:
|
|
166
|
+
- If ProofGate API is unreachable, transactions are **blocked**
|
|
167
|
+
- This is the secure default
|
|
168
|
+
|
|
169
|
+
Set `fail_open=True` for:
|
|
170
|
+
- Allow transactions when ProofGate is unavailable
|
|
171
|
+
- Useful for testing or when availability > security
|
|
172
|
+
|
|
173
|
+
## Usage Examples
|
|
174
|
+
|
|
175
|
+
### Explicit Validation
|
|
176
|
+
|
|
177
|
+
```python
|
|
178
|
+
from proofgate_agentkit import ProofGateActionProvider, ProofGateConfig, ProofGateValidationError
|
|
179
|
+
|
|
180
|
+
config = ProofGateConfig(api_key="pg_xxx", guardrail_id="xxx")
|
|
181
|
+
provider = ProofGateActionProvider(config)
|
|
182
|
+
|
|
183
|
+
try:
|
|
184
|
+
proof_id = provider.validate_transaction(
|
|
185
|
+
from_address="0xYourAgent...",
|
|
186
|
+
to="0xContract...",
|
|
187
|
+
data="0xa9059cbb...",
|
|
188
|
+
value="0",
|
|
189
|
+
)
|
|
190
|
+
print(f"✅ Safe! Proof ID: {proof_id}")
|
|
191
|
+
# Execute transaction...
|
|
192
|
+
|
|
193
|
+
except ProofGateValidationError as e:
|
|
194
|
+
print(f"🚫 Blocked: {e.reason}")
|
|
195
|
+
print(f"Evidence: {e.evidence_uri}")
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### With LangChain
|
|
199
|
+
|
|
200
|
+
```python
|
|
201
|
+
from langchain_openai import ChatOpenAI
|
|
202
|
+
from coinbase_agentkit import AgentKit
|
|
203
|
+
from coinbase_agentkit_langchain import get_langchain_tools
|
|
204
|
+
from proofgate_agentkit import proofgate_action_provider
|
|
205
|
+
|
|
206
|
+
# Setup AgentKit with ProofGate
|
|
207
|
+
agent_kit = AgentKit(
|
|
208
|
+
config=config,
|
|
209
|
+
action_providers=[
|
|
210
|
+
proofgate_action_provider(
|
|
211
|
+
api_key="pg_xxx",
|
|
212
|
+
guardrail_id="xxx",
|
|
213
|
+
),
|
|
214
|
+
# ... other providers
|
|
215
|
+
],
|
|
216
|
+
)
|
|
217
|
+
|
|
218
|
+
# Get tools for LangChain
|
|
219
|
+
tools = get_langchain_tools(agent_kit)
|
|
220
|
+
|
|
221
|
+
# Create agent
|
|
222
|
+
llm = ChatOpenAI(model="gpt-4")
|
|
223
|
+
agent = create_react_agent(llm, tools)
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
### Programmatic Validation in Custom Actions
|
|
227
|
+
|
|
228
|
+
```python
|
|
229
|
+
from coinbase_agentkit.action_providers import ActionProvider, create_action
|
|
230
|
+
from proofgate_agentkit import ProofGateActionProvider, ProofGateConfig
|
|
231
|
+
|
|
232
|
+
class MyCustomProvider(ActionProvider):
|
|
233
|
+
def __init__(self):
|
|
234
|
+
super().__init__("my_custom", [])
|
|
235
|
+
|
|
236
|
+
# Initialize ProofGate for validation
|
|
237
|
+
config = ProofGateConfig(api_key="pg_xxx")
|
|
238
|
+
self._proofgate = ProofGateActionProvider(config)
|
|
239
|
+
|
|
240
|
+
@create_action(name="dangerous_action", description="...", schema=MySchema)
|
|
241
|
+
def dangerous_action(self, wallet_provider, args):
|
|
242
|
+
# Validate first!
|
|
243
|
+
self._proofgate.validate_transaction(
|
|
244
|
+
from_address=wallet_provider.get_address(),
|
|
245
|
+
to=args["to"],
|
|
246
|
+
data=args["data"],
|
|
247
|
+
value=args["value"],
|
|
248
|
+
)
|
|
249
|
+
|
|
250
|
+
# If we get here, it's safe
|
|
251
|
+
return wallet_provider.send_transaction({...})
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
## Guardrails
|
|
255
|
+
|
|
256
|
+
Guardrails define what your agent can do. Create them at [proofgate.xyz/guardrails](https://www.proofgate.xyz/guardrails).
|
|
257
|
+
|
|
258
|
+
Example rules:
|
|
259
|
+
- ✅ **Whitelist contracts**: Only Uniswap, Aave, Compound
|
|
260
|
+
- ✅ **Max approval**: 1,000 USDC per approval
|
|
261
|
+
- ✅ **Max slippage**: 1% on swaps
|
|
262
|
+
- ✅ **Daily limit**: $10,000 total spending
|
|
263
|
+
- ✅ **Blocked methods**: No `setApprovalForAll`
|
|
264
|
+
|
|
265
|
+
## Error Handling
|
|
266
|
+
|
|
267
|
+
```python
|
|
268
|
+
from proofgate_agentkit import ProofGateValidationError
|
|
269
|
+
|
|
270
|
+
try:
|
|
271
|
+
provider.validate_transaction(...)
|
|
272
|
+
except ProofGateValidationError as e:
|
|
273
|
+
print(f"Blocked: {e.reason}")
|
|
274
|
+
print(f"Validation ID: {e.validation_id}")
|
|
275
|
+
print(f"Evidence URI: {e.evidence_uri}")
|
|
276
|
+
|
|
277
|
+
# Access individual check results
|
|
278
|
+
for check in e.checks:
|
|
279
|
+
print(f" - {check['name']}: {check['result']}")
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
## API Reference
|
|
283
|
+
|
|
284
|
+
### ProofGateActionProvider
|
|
285
|
+
|
|
286
|
+
The main action provider class.
|
|
287
|
+
|
|
288
|
+
**Methods:**
|
|
289
|
+
- `validate_transaction(from_address, to, data, value, chain_id, guardrail_id)` → `str`
|
|
290
|
+
- Returns proof_id if safe, raises `ProofGateValidationError` if blocked
|
|
291
|
+
|
|
292
|
+
**Actions (for LLM agents):**
|
|
293
|
+
- `validate_transaction` - Validate a transaction
|
|
294
|
+
- `check_agent_trust` - Check wallet trust score
|
|
295
|
+
|
|
296
|
+
### ProofGateWrapper
|
|
297
|
+
|
|
298
|
+
Wraps wallet providers for automatic validation.
|
|
299
|
+
|
|
300
|
+
**Methods:**
|
|
301
|
+
- `wrap(wallet_provider)` → `EvmWalletProvider`
|
|
302
|
+
- Returns the same provider with patched `send_transaction`
|
|
303
|
+
|
|
304
|
+
### wrap_with_proofgate
|
|
305
|
+
|
|
306
|
+
Factory function to wrap action providers.
|
|
307
|
+
|
|
308
|
+
```python
|
|
309
|
+
wrapped = wrap_with_proofgate(provider, config)
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
## Development
|
|
313
|
+
|
|
314
|
+
```bash
|
|
315
|
+
# Clone
|
|
316
|
+
git clone https://github.com/proofgate/proofgate-agentkit
|
|
317
|
+
cd proofgate-agentkit/python
|
|
318
|
+
|
|
319
|
+
# Install dependencies
|
|
320
|
+
poetry install
|
|
321
|
+
|
|
322
|
+
# Run tests
|
|
323
|
+
poetry run pytest
|
|
324
|
+
|
|
325
|
+
# Format
|
|
326
|
+
poetry run black .
|
|
327
|
+
poetry run ruff check --fix .
|
|
328
|
+
|
|
329
|
+
# Type check
|
|
330
|
+
poetry run mypy proofgate_agentkit
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
## License
|
|
334
|
+
|
|
335
|
+
MIT License - see [LICENSE](LICENSE) for details.
|
|
336
|
+
|
|
337
|
+
## Links
|
|
338
|
+
|
|
339
|
+
- 🌐 [ProofGate Website](https://proofgate.xyz)
|
|
340
|
+
- 📚 [Documentation](https://docs.proofgate.xyz)
|
|
341
|
+
- 🔧 [Coinbase AgentKit](https://github.com/coinbase/agentkit)
|
|
342
|
+
- 🐍 [proofgate Python SDK](https://pypi.org/project/proofgate/)
|
|
343
|
+
|
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
# proofgate-agentkit
|
|
2
|
+
|
|
3
|
+
> ProofGate Action Provider for Coinbase AgentKit - Blockchain guardrails for AI agents
|
|
4
|
+
|
|
5
|
+
[](https://pypi.org/project/proofgate-agentkit/)
|
|
6
|
+
[](https://www.python.org/downloads/)
|
|
7
|
+
[](https://opensource.org/licenses/MIT)
|
|
8
|
+
|
|
9
|
+
## What is this?
|
|
10
|
+
|
|
11
|
+
`proofgate-agentkit` integrates [ProofGate](https://proofgate.xyz) with [Coinbase AgentKit](https://github.com/coinbase/agentkit), providing security guardrails for AI agent blockchain transactions.
|
|
12
|
+
|
|
13
|
+
**ProofGate validates transactions before your AI agent executes them**, preventing:
|
|
14
|
+
|
|
15
|
+
- 🚫 **Wallet drains** from prompt injection attacks
|
|
16
|
+
- 🚫 **Infinite approvals** to malicious contracts
|
|
17
|
+
- 🚫 **Excessive spending** beyond daily limits
|
|
18
|
+
- 🚫 **High slippage** swaps that lose money
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
pip install proofgate-agentkit
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Or with Poetry:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
poetry add proofgate-agentkit
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Quick Start
|
|
33
|
+
|
|
34
|
+
### 1. As an Action Provider
|
|
35
|
+
|
|
36
|
+
Add ProofGate as an action provider to validate transactions explicitly:
|
|
37
|
+
|
|
38
|
+
```python
|
|
39
|
+
from coinbase_agentkit import AgentKit, AgentKitConfig
|
|
40
|
+
from proofgate_agentkit import proofgate_action_provider
|
|
41
|
+
|
|
42
|
+
# Create the ProofGate action provider
|
|
43
|
+
proofgate = proofgate_action_provider(
|
|
44
|
+
api_key="pg_your_api_key", # Get from proofgate.xyz/dashboard
|
|
45
|
+
guardrail_id="your_guardrail", # Create at proofgate.xyz/guardrails
|
|
46
|
+
chain_id=8453, # Base mainnet
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
# Add to your AgentKit configuration
|
|
50
|
+
agent = AgentKit(
|
|
51
|
+
config=AgentKitConfig(
|
|
52
|
+
# ... your config
|
|
53
|
+
),
|
|
54
|
+
action_providers=[
|
|
55
|
+
proofgate,
|
|
56
|
+
# ... other providers
|
|
57
|
+
],
|
|
58
|
+
)
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Now your agent has access to these actions:
|
|
62
|
+
- `validate_transaction` - Validate a transaction before execution
|
|
63
|
+
- `check_agent_trust` - Check a wallet's trust score
|
|
64
|
+
|
|
65
|
+
### 2. Wrap Existing Providers
|
|
66
|
+
|
|
67
|
+
Automatically validate all transactions from any action provider:
|
|
68
|
+
|
|
69
|
+
```python
|
|
70
|
+
from coinbase_agentkit.action_providers import erc20_action_provider, wallet_action_provider
|
|
71
|
+
from proofgate_agentkit import wrap_with_proofgate, ProofGateConfig
|
|
72
|
+
|
|
73
|
+
config = ProofGateConfig(
|
|
74
|
+
api_key="pg_your_api_key",
|
|
75
|
+
guardrail_id="your_guardrail",
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
# Wrap providers - all their transaction actions will be validated
|
|
79
|
+
safe_erc20 = wrap_with_proofgate(erc20_action_provider(), config)
|
|
80
|
+
safe_wallet = wrap_with_proofgate(wallet_action_provider(), config)
|
|
81
|
+
|
|
82
|
+
agent = AgentKit(
|
|
83
|
+
config=AgentKitConfig(...),
|
|
84
|
+
action_providers=[safe_erc20, safe_wallet],
|
|
85
|
+
)
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### 3. Wrap the Wallet Provider
|
|
89
|
+
|
|
90
|
+
Validate ALL transactions at the wallet level:
|
|
91
|
+
|
|
92
|
+
```python
|
|
93
|
+
from coinbase_agentkit.wallet_providers import CdpWalletProvider
|
|
94
|
+
from proofgate_agentkit import ProofGateWrapper, ProofGateConfig
|
|
95
|
+
|
|
96
|
+
# Create wallet provider
|
|
97
|
+
wallet = CdpWalletProvider(...)
|
|
98
|
+
|
|
99
|
+
# Wrap with ProofGate
|
|
100
|
+
config = ProofGateConfig(
|
|
101
|
+
api_key="pg_your_api_key",
|
|
102
|
+
guardrail_id="your_guardrail",
|
|
103
|
+
)
|
|
104
|
+
wrapper = ProofGateWrapper(config)
|
|
105
|
+
safe_wallet = wrapper.wrap(wallet)
|
|
106
|
+
|
|
107
|
+
# Now every send_transaction() call is validated first
|
|
108
|
+
agent = AgentKit(
|
|
109
|
+
config=AgentKitConfig(...),
|
|
110
|
+
wallet_provider=safe_wallet,
|
|
111
|
+
)
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Configuration
|
|
115
|
+
|
|
116
|
+
```python
|
|
117
|
+
from proofgate_agentkit import ProofGateConfig
|
|
118
|
+
|
|
119
|
+
config = ProofGateConfig(
|
|
120
|
+
# Required
|
|
121
|
+
api_key="pg_xxx", # Your ProofGate API key
|
|
122
|
+
|
|
123
|
+
# Optional
|
|
124
|
+
guardrail_id="xxx", # Default guardrail to use
|
|
125
|
+
chain_id=8453, # Default chain (8453 = Base)
|
|
126
|
+
base_url="https://...", # Custom API URL
|
|
127
|
+
timeout=30.0, # Request timeout (seconds)
|
|
128
|
+
fail_open=False, # Allow tx on API failure (default: False)
|
|
129
|
+
log_validations=True, # Log validation results (default: True)
|
|
130
|
+
)
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### Fail Open vs Fail Closed
|
|
134
|
+
|
|
135
|
+
By default, `fail_open=False` means:
|
|
136
|
+
- If ProofGate API is unreachable, transactions are **blocked**
|
|
137
|
+
- This is the secure default
|
|
138
|
+
|
|
139
|
+
Set `fail_open=True` for:
|
|
140
|
+
- Allow transactions when ProofGate is unavailable
|
|
141
|
+
- Useful for testing or when availability > security
|
|
142
|
+
|
|
143
|
+
## Usage Examples
|
|
144
|
+
|
|
145
|
+
### Explicit Validation
|
|
146
|
+
|
|
147
|
+
```python
|
|
148
|
+
from proofgate_agentkit import ProofGateActionProvider, ProofGateConfig, ProofGateValidationError
|
|
149
|
+
|
|
150
|
+
config = ProofGateConfig(api_key="pg_xxx", guardrail_id="xxx")
|
|
151
|
+
provider = ProofGateActionProvider(config)
|
|
152
|
+
|
|
153
|
+
try:
|
|
154
|
+
proof_id = provider.validate_transaction(
|
|
155
|
+
from_address="0xYourAgent...",
|
|
156
|
+
to="0xContract...",
|
|
157
|
+
data="0xa9059cbb...",
|
|
158
|
+
value="0",
|
|
159
|
+
)
|
|
160
|
+
print(f"✅ Safe! Proof ID: {proof_id}")
|
|
161
|
+
# Execute transaction...
|
|
162
|
+
|
|
163
|
+
except ProofGateValidationError as e:
|
|
164
|
+
print(f"🚫 Blocked: {e.reason}")
|
|
165
|
+
print(f"Evidence: {e.evidence_uri}")
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### With LangChain
|
|
169
|
+
|
|
170
|
+
```python
|
|
171
|
+
from langchain_openai import ChatOpenAI
|
|
172
|
+
from coinbase_agentkit import AgentKit
|
|
173
|
+
from coinbase_agentkit_langchain import get_langchain_tools
|
|
174
|
+
from proofgate_agentkit import proofgate_action_provider
|
|
175
|
+
|
|
176
|
+
# Setup AgentKit with ProofGate
|
|
177
|
+
agent_kit = AgentKit(
|
|
178
|
+
config=config,
|
|
179
|
+
action_providers=[
|
|
180
|
+
proofgate_action_provider(
|
|
181
|
+
api_key="pg_xxx",
|
|
182
|
+
guardrail_id="xxx",
|
|
183
|
+
),
|
|
184
|
+
# ... other providers
|
|
185
|
+
],
|
|
186
|
+
)
|
|
187
|
+
|
|
188
|
+
# Get tools for LangChain
|
|
189
|
+
tools = get_langchain_tools(agent_kit)
|
|
190
|
+
|
|
191
|
+
# Create agent
|
|
192
|
+
llm = ChatOpenAI(model="gpt-4")
|
|
193
|
+
agent = create_react_agent(llm, tools)
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### Programmatic Validation in Custom Actions
|
|
197
|
+
|
|
198
|
+
```python
|
|
199
|
+
from coinbase_agentkit.action_providers import ActionProvider, create_action
|
|
200
|
+
from proofgate_agentkit import ProofGateActionProvider, ProofGateConfig
|
|
201
|
+
|
|
202
|
+
class MyCustomProvider(ActionProvider):
|
|
203
|
+
def __init__(self):
|
|
204
|
+
super().__init__("my_custom", [])
|
|
205
|
+
|
|
206
|
+
# Initialize ProofGate for validation
|
|
207
|
+
config = ProofGateConfig(api_key="pg_xxx")
|
|
208
|
+
self._proofgate = ProofGateActionProvider(config)
|
|
209
|
+
|
|
210
|
+
@create_action(name="dangerous_action", description="...", schema=MySchema)
|
|
211
|
+
def dangerous_action(self, wallet_provider, args):
|
|
212
|
+
# Validate first!
|
|
213
|
+
self._proofgate.validate_transaction(
|
|
214
|
+
from_address=wallet_provider.get_address(),
|
|
215
|
+
to=args["to"],
|
|
216
|
+
data=args["data"],
|
|
217
|
+
value=args["value"],
|
|
218
|
+
)
|
|
219
|
+
|
|
220
|
+
# If we get here, it's safe
|
|
221
|
+
return wallet_provider.send_transaction({...})
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
## Guardrails
|
|
225
|
+
|
|
226
|
+
Guardrails define what your agent can do. Create them at [proofgate.xyz/guardrails](https://www.proofgate.xyz/guardrails).
|
|
227
|
+
|
|
228
|
+
Example rules:
|
|
229
|
+
- ✅ **Whitelist contracts**: Only Uniswap, Aave, Compound
|
|
230
|
+
- ✅ **Max approval**: 1,000 USDC per approval
|
|
231
|
+
- ✅ **Max slippage**: 1% on swaps
|
|
232
|
+
- ✅ **Daily limit**: $10,000 total spending
|
|
233
|
+
- ✅ **Blocked methods**: No `setApprovalForAll`
|
|
234
|
+
|
|
235
|
+
## Error Handling
|
|
236
|
+
|
|
237
|
+
```python
|
|
238
|
+
from proofgate_agentkit import ProofGateValidationError
|
|
239
|
+
|
|
240
|
+
try:
|
|
241
|
+
provider.validate_transaction(...)
|
|
242
|
+
except ProofGateValidationError as e:
|
|
243
|
+
print(f"Blocked: {e.reason}")
|
|
244
|
+
print(f"Validation ID: {e.validation_id}")
|
|
245
|
+
print(f"Evidence URI: {e.evidence_uri}")
|
|
246
|
+
|
|
247
|
+
# Access individual check results
|
|
248
|
+
for check in e.checks:
|
|
249
|
+
print(f" - {check['name']}: {check['result']}")
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
## API Reference
|
|
253
|
+
|
|
254
|
+
### ProofGateActionProvider
|
|
255
|
+
|
|
256
|
+
The main action provider class.
|
|
257
|
+
|
|
258
|
+
**Methods:**
|
|
259
|
+
- `validate_transaction(from_address, to, data, value, chain_id, guardrail_id)` → `str`
|
|
260
|
+
- Returns proof_id if safe, raises `ProofGateValidationError` if blocked
|
|
261
|
+
|
|
262
|
+
**Actions (for LLM agents):**
|
|
263
|
+
- `validate_transaction` - Validate a transaction
|
|
264
|
+
- `check_agent_trust` - Check wallet trust score
|
|
265
|
+
|
|
266
|
+
### ProofGateWrapper
|
|
267
|
+
|
|
268
|
+
Wraps wallet providers for automatic validation.
|
|
269
|
+
|
|
270
|
+
**Methods:**
|
|
271
|
+
- `wrap(wallet_provider)` → `EvmWalletProvider`
|
|
272
|
+
- Returns the same provider with patched `send_transaction`
|
|
273
|
+
|
|
274
|
+
### wrap_with_proofgate
|
|
275
|
+
|
|
276
|
+
Factory function to wrap action providers.
|
|
277
|
+
|
|
278
|
+
```python
|
|
279
|
+
wrapped = wrap_with_proofgate(provider, config)
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
## Development
|
|
283
|
+
|
|
284
|
+
```bash
|
|
285
|
+
# Clone
|
|
286
|
+
git clone https://github.com/proofgate/proofgate-agentkit
|
|
287
|
+
cd proofgate-agentkit/python
|
|
288
|
+
|
|
289
|
+
# Install dependencies
|
|
290
|
+
poetry install
|
|
291
|
+
|
|
292
|
+
# Run tests
|
|
293
|
+
poetry run pytest
|
|
294
|
+
|
|
295
|
+
# Format
|
|
296
|
+
poetry run black .
|
|
297
|
+
poetry run ruff check --fix .
|
|
298
|
+
|
|
299
|
+
# Type check
|
|
300
|
+
poetry run mypy proofgate_agentkit
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
## License
|
|
304
|
+
|
|
305
|
+
MIT License - see [LICENSE](LICENSE) for details.
|
|
306
|
+
|
|
307
|
+
## Links
|
|
308
|
+
|
|
309
|
+
- 🌐 [ProofGate Website](https://proofgate.xyz)
|
|
310
|
+
- 📚 [Documentation](https://docs.proofgate.xyz)
|
|
311
|
+
- 🔧 [Coinbase AgentKit](https://github.com/coinbase/agentkit)
|
|
312
|
+
- 🐍 [proofgate Python SDK](https://pypi.org/project/proofgate/)
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"""ProofGate Action Provider for Coinbase AgentKit.
|
|
2
|
+
|
|
3
|
+
Blockchain guardrails for AI agents - validate transactions before execution.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from .action_provider import (
|
|
7
|
+
ProofGateActionProvider,
|
|
8
|
+
proofgate_action_provider,
|
|
9
|
+
)
|
|
10
|
+
from .config import ProofGateConfig
|
|
11
|
+
from .exceptions import ProofGateValidationError
|
|
12
|
+
from .wrapper import (
|
|
13
|
+
ProofGateWrapper,
|
|
14
|
+
wrap_with_proofgate,
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
__version__ = "0.1.0"
|
|
18
|
+
|
|
19
|
+
__all__ = [
|
|
20
|
+
# Action Provider
|
|
21
|
+
"ProofGateActionProvider",
|
|
22
|
+
"proofgate_action_provider",
|
|
23
|
+
# Config
|
|
24
|
+
"ProofGateConfig",
|
|
25
|
+
# Wrapper
|
|
26
|
+
"ProofGateWrapper",
|
|
27
|
+
"wrap_with_proofgate",
|
|
28
|
+
# Exceptions
|
|
29
|
+
"ProofGateValidationError",
|
|
30
|
+
]
|