@vorionsys/basis 1.0.1
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.
- package/.env.example +22 -0
- package/AMOY-MIGRATION.md +188 -0
- package/DEPLOY-AMOY.md +368 -0
- package/DEPLOY-NOW.md +216 -0
- package/DEPLOYMENT.md +239 -0
- package/GET-WALLET.md +286 -0
- package/QUICK-WALLET-SETUP.md +268 -0
- package/README.md +195 -0
- package/artifacts/@openzeppelin/contracts/access/AccessControl.sol/AccessControl.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/access/AccessControl.sol/AccessControl.json +236 -0
- package/artifacts/@openzeppelin/contracts/access/IAccessControl.sol/IAccessControl.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/access/IAccessControl.sol/IAccessControl.json +204 -0
- package/artifacts/@openzeppelin/contracts/interfaces/IERC4906.sol/IERC4906.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/interfaces/IERC4906.sol/IERC4906.json +328 -0
- package/artifacts/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC1155Errors.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC1155Errors.json +113 -0
- package/artifacts/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC20Errors.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC20Errors.json +97 -0
- package/artifacts/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC721Errors.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC721Errors.json +114 -0
- package/artifacts/@openzeppelin/contracts/token/ERC721/ERC721.sol/ERC721.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/token/ERC721/ERC721.sol/ERC721.json +444 -0
- package/artifacts/@openzeppelin/contracts/token/ERC721/IERC721.sol/IERC721.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/token/ERC721/IERC721.sol/IERC721.json +296 -0
- package/artifacts/@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol/IERC721Receiver.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol/IERC721Receiver.json +45 -0
- package/artifacts/@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol/ERC721Enumerable.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol/ERC721Enumerable.json +521 -0
- package/artifacts/@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol/ERC721URIStorage.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol/ERC721URIStorage.json +476 -0
- package/artifacts/@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol/IERC721Enumerable.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol/IERC721Enumerable.json +352 -0
- package/artifacts/@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol/IERC721Metadata.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol/IERC721Metadata.json +341 -0
- package/artifacts/@openzeppelin/contracts/token/ERC721/utils/ERC721Utils.sol/ERC721Utils.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/token/ERC721/utils/ERC721Utils.sol/ERC721Utils.json +10 -0
- package/artifacts/@openzeppelin/contracts/utils/Context.sol/Context.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/utils/Context.sol/Context.json +10 -0
- package/artifacts/@openzeppelin/contracts/utils/Panic.sol/Panic.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/utils/Panic.sol/Panic.json +10 -0
- package/artifacts/@openzeppelin/contracts/utils/Strings.sol/Strings.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/utils/Strings.sol/Strings.json +37 -0
- package/artifacts/@openzeppelin/contracts/utils/introspection/ERC165.sol/ERC165.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/utils/introspection/ERC165.sol/ERC165.json +30 -0
- package/artifacts/@openzeppelin/contracts/utils/introspection/IERC165.sol/IERC165.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/utils/introspection/IERC165.sol/IERC165.json +30 -0
- package/artifacts/@openzeppelin/contracts/utils/math/Math.sol/Math.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/utils/math/Math.sol/Math.json +10 -0
- package/artifacts/@openzeppelin/contracts/utils/math/SafeCast.sol/SafeCast.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/utils/math/SafeCast.sol/SafeCast.json +65 -0
- package/artifacts/@openzeppelin/contracts/utils/math/SignedMath.sol/SignedMath.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/utils/math/SignedMath.sol/SignedMath.json +10 -0
- package/artifacts/build-info/357d1bba4062d461f497f221490811a3.json +1 -0
- package/artifacts/contracts/AgentCard.sol/AgentCard.dbg.json +4 -0
- package/artifacts/contracts/AgentCard.sol/AgentCard.json +1430 -0
- package/build_errors.txt +0 -0
- package/build_output.txt +0 -0
- package/cache/solidity-files-cache.json +885 -0
- package/contracts/AgentCard.sol +478 -0
- package/contracts/deploy/01-deploy-agentcard.ts +66 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/kya/accountability.d.ts.map +1 -0
- package/dist/kya/accountability.js +100 -0
- package/dist/kya/authorization.d.ts.map +1 -0
- package/dist/kya/authorization.js +258 -0
- package/dist/kya/behavior.d.ts.map +1 -0
- package/dist/kya/behavior.js +142 -0
- package/dist/kya/identity.d.ts.map +1 -0
- package/dist/kya/identity.js +187 -0
- package/dist/kya/index.d.ts.map +1 -0
- package/dist/kya/index.js +99 -0
- package/dist/kya/types.d.ts.map +1 -0
- package/dist/kya/types.js +5 -0
- package/dist/trust-1000-agents.test.d.ts.map +1 -0
- package/dist/trust-1000-agents.test.js +608 -0
- package/dist/trust-capabilities.d.ts.map +1 -0
- package/dist/trust-capabilities.js +478 -0
- package/dist/trust-factors.d.ts.map +1 -0
- package/dist/trust-factors.js +588 -0
- package/dist/trust-factors.test.d.ts.map +1 -0
- package/dist/trust-factors.test.js +179 -0
- package/dist/validation-gate.d.ts.map +1 -0
- package/dist/validation-gate.js +468 -0
- package/dist/validation-gate.test.d.ts.map +1 -0
- package/dist/validation-gate.test.js +419 -0
- package/hardhat.config.ts +55 -0
- package/package.json +57 -0
- package/scripts/certify-agent.ts +91 -0
- package/scripts/deploy-agentcard.ts +63 -0
- package/scripts/mint-agentcard.ts +87 -0
- package/specs/adversarial-sandbox-test-suite.md +1055 -0
- package/specs/kya-framework.md +910 -0
- package/specs/trust-factors-v2.md +437 -0
- package/src/index.ts +14 -0
- package/src/kya/accountability.ts +132 -0
- package/src/kya/authorization.ts +325 -0
- package/src/kya/behavior.ts +169 -0
- package/src/kya/identity.ts +224 -0
- package/src/kya/index.ts +125 -0
- package/src/kya/types.ts +242 -0
- package/src/trust-1000-agents.test.ts +745 -0
- package/src/trust-capabilities.ts +517 -0
- package/src/trust-factors.test.ts +241 -0
- package/src/trust-factors.ts +666 -0
- package/src/validation-gate.test.ts +531 -0
- package/src/validation-gate.ts +665 -0
- package/test-kya-simple.ts +258 -0
- package/test-kya.ts +245 -0
- package/tsconfig.json +14 -0
- package/typechain-types/@openzeppelin/contracts/access/AccessControl.ts +324 -0
- package/typechain-types/@openzeppelin/contracts/access/IAccessControl.ts +292 -0
- package/typechain-types/@openzeppelin/contracts/access/index.ts +5 -0
- package/typechain-types/@openzeppelin/contracts/index.ts +11 -0
- package/typechain-types/@openzeppelin/contracts/interfaces/IERC4906.ts +462 -0
- package/typechain-types/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC1155Errors.ts +69 -0
- package/typechain-types/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC20Errors.ts +69 -0
- package/typechain-types/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC721Errors.ts +69 -0
- package/typechain-types/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/index.ts +6 -0
- package/typechain-types/@openzeppelin/contracts/interfaces/index.ts +6 -0
- package/typechain-types/@openzeppelin/contracts/token/ERC721/ERC721.ts +420 -0
- package/typechain-types/@openzeppelin/contracts/token/ERC721/IERC721.ts +393 -0
- package/typechain-types/@openzeppelin/contracts/token/ERC721/IERC721Receiver.ts +110 -0
- package/typechain-types/@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.ts +470 -0
- package/typechain-types/@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.ts +489 -0
- package/typechain-types/@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.ts +443 -0
- package/typechain-types/@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.ts +420 -0
- package/typechain-types/@openzeppelin/contracts/token/ERC721/extensions/index.ts +7 -0
- package/typechain-types/@openzeppelin/contracts/token/ERC721/index.ts +8 -0
- package/typechain-types/@openzeppelin/contracts/token/index.ts +5 -0
- package/typechain-types/@openzeppelin/contracts/utils/Strings.ts +69 -0
- package/typechain-types/@openzeppelin/contracts/utils/index.ts +8 -0
- package/typechain-types/@openzeppelin/contracts/utils/introspection/ERC165.ts +94 -0
- package/typechain-types/@openzeppelin/contracts/utils/introspection/IERC165.ts +94 -0
- package/typechain-types/@openzeppelin/contracts/utils/introspection/index.ts +5 -0
- package/typechain-types/@openzeppelin/contracts/utils/math/SafeCast.ts +69 -0
- package/typechain-types/@openzeppelin/contracts/utils/math/index.ts +4 -0
- package/typechain-types/@openzeppelin/index.ts +5 -0
- package/typechain-types/common.ts +131 -0
- package/typechain-types/contracts/AgentCard.ts +1415 -0
- package/typechain-types/contracts/index.ts +4 -0
- package/typechain-types/factories/@openzeppelin/contracts/access/AccessControl__factory.ts +250 -0
- package/typechain-types/factories/@openzeppelin/contracts/access/IAccessControl__factory.ts +218 -0
- package/typechain-types/factories/@openzeppelin/contracts/access/index.ts +5 -0
- package/typechain-types/factories/@openzeppelin/contracts/index.ts +7 -0
- package/typechain-types/factories/@openzeppelin/contracts/interfaces/IERC4906__factory.ts +339 -0
- package/typechain-types/factories/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC1155Errors__factory.ts +127 -0
- package/typechain-types/factories/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC20Errors__factory.ts +111 -0
- package/typechain-types/factories/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC721Errors__factory.ts +128 -0
- package/typechain-types/factories/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/index.ts +6 -0
- package/typechain-types/factories/@openzeppelin/contracts/interfaces/index.ts +5 -0
- package/typechain-types/factories/@openzeppelin/contracts/token/ERC721/ERC721__factory.ts +455 -0
- package/typechain-types/factories/@openzeppelin/contracts/token/ERC721/IERC721Receiver__factory.ts +59 -0
- package/typechain-types/factories/@openzeppelin/contracts/token/ERC721/IERC721__factory.ts +307 -0
- package/typechain-types/factories/@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable__factory.ts +535 -0
- package/typechain-types/factories/@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage__factory.ts +490 -0
- package/typechain-types/factories/@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable__factory.ts +366 -0
- package/typechain-types/factories/@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata__factory.ts +355 -0
- package/typechain-types/factories/@openzeppelin/contracts/token/ERC721/extensions/index.ts +7 -0
- package/typechain-types/factories/@openzeppelin/contracts/token/ERC721/index.ts +7 -0
- package/typechain-types/factories/@openzeppelin/contracts/token/index.ts +4 -0
- package/typechain-types/factories/@openzeppelin/contracts/utils/Strings__factory.ts +90 -0
- package/typechain-types/factories/@openzeppelin/contracts/utils/index.ts +6 -0
- package/typechain-types/factories/@openzeppelin/contracts/utils/introspection/ERC165__factory.ts +41 -0
- package/typechain-types/factories/@openzeppelin/contracts/utils/introspection/IERC165__factory.ts +41 -0
- package/typechain-types/factories/@openzeppelin/contracts/utils/introspection/index.ts +5 -0
- package/typechain-types/factories/@openzeppelin/contracts/utils/math/SafeCast__factory.ts +118 -0
- package/typechain-types/factories/@openzeppelin/contracts/utils/math/index.ts +4 -0
- package/typechain-types/factories/@openzeppelin/index.ts +4 -0
- package/typechain-types/factories/contracts/AgentCard__factory.ts +1480 -0
- package/typechain-types/factories/contracts/index.ts +4 -0
- package/typechain-types/factories/index.ts +5 -0
- package/typechain-types/index.ts +44 -0
- package/vitest.config.ts +8 -0
package/DEPLOY-NOW.md
ADDED
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
# 🚀 AgentCard Deployment - Ready to Deploy!
|
|
2
|
+
|
|
3
|
+
## Status: ✅ CONTRACT COMPILED SUCCESSFULLY
|
|
4
|
+
|
|
5
|
+
All dependencies installed and contract compiled. You're ready to deploy!
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Prerequisites Complete ✅
|
|
10
|
+
|
|
11
|
+
- ✅ Node.js 22+ installed
|
|
12
|
+
- ✅ Dependencies installed (474 packages)
|
|
13
|
+
- ✅ Contract compiled (23 Solidity files)
|
|
14
|
+
- ✅ TypeScript types generated (64 typings)
|
|
15
|
+
- ✅ `.env` file created (needs your private key)
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Step 1: Get Testnet MATIC (5 minutes)
|
|
20
|
+
|
|
21
|
+
### Mumbai Faucet
|
|
22
|
+
Visit: **https://faucet.polygon.technology/**
|
|
23
|
+
|
|
24
|
+
1. Select **"Mumbai"** network
|
|
25
|
+
2. Paste your wallet address
|
|
26
|
+
3. Click **"Submit"**
|
|
27
|
+
4. Wait 1-2 minutes for tokens
|
|
28
|
+
|
|
29
|
+
**Recommended**: Get 1-2 MATIC (enough for ~100 mints)
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## Step 2: Configure .env File
|
|
34
|
+
|
|
35
|
+
Edit `C:\Axiom\packages\basis\.env`:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
# Required: Your deployment wallet private key
|
|
39
|
+
# ⚠️ TESTNET ONLY - Never use mainnet keys!
|
|
40
|
+
PRIVATE_KEY=0x1234567890abcdef... # 66 characters starting with 0x
|
|
41
|
+
|
|
42
|
+
# Optional: Custom RPC (default works fine)
|
|
43
|
+
MUMBAI_RPC_URL=https://rpc-mumbai.maticvigil.com
|
|
44
|
+
|
|
45
|
+
# Optional: For contract verification on PolygonScan
|
|
46
|
+
POLYGONSCAN_API_KEY=YOUR_API_KEY_HERE
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
**Get PolygonScan API Key** (free):
|
|
50
|
+
1. Visit https://polygonscan.com/apis
|
|
51
|
+
2. Sign up for free account
|
|
52
|
+
3. Create API key
|
|
53
|
+
4. Copy to .env
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## Step 3: Deploy to Mumbai Testnet (2 minutes)
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
cd C:\Axiom\packages\basis
|
|
61
|
+
|
|
62
|
+
# Deploy AgentCard contract
|
|
63
|
+
npx hardhat run scripts/deploy-agentcard.ts --network mumbai
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
**Expected Output**:
|
|
67
|
+
```
|
|
68
|
+
Deploying AgentCard to mumbai...
|
|
69
|
+
AgentCard deployed to: 0x1234567890abcdef1234567890abcdef12345678
|
|
70
|
+
Granting CERTIFIER_ROLE to deployer...
|
|
71
|
+
✅ Deployment complete!
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
**📝 SAVE THE CONTRACT ADDRESS** - you'll need it for the next steps!
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## Step 4: Verify Contract on PolygonScan (optional, 2 minutes)
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
npx hardhat verify --network mumbai <CONTRACT_ADDRESS>
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
**View on PolygonScan**:
|
|
85
|
+
```
|
|
86
|
+
https://mumbai.polygonscan.com/address/<CONTRACT_ADDRESS>
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## Step 5: Mint First AgentCard (CC Agent)
|
|
92
|
+
|
|
93
|
+
Edit `scripts/mint-agentcard.ts` and set the contract address:
|
|
94
|
+
|
|
95
|
+
```typescript
|
|
96
|
+
const agentCard = await AgentCard.attach(
|
|
97
|
+
'<YOUR_CONTRACT_ADDRESS_FROM_STEP_3>'
|
|
98
|
+
);
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Then mint:
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
npx hardhat run scripts/mint-agentcard.ts --network mumbai
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
**Expected Output**:
|
|
108
|
+
```
|
|
109
|
+
Minting AgentCard with account: 0x...
|
|
110
|
+
✅ AgentCard minted successfully!
|
|
111
|
+
Token ID: 0
|
|
112
|
+
DID: did:vorion:google:cc-agent-v1
|
|
113
|
+
Owner: 0x...
|
|
114
|
+
Name: CC AI Agent (Google Labs)
|
|
115
|
+
|
|
116
|
+
📋 AgentCard Details:
|
|
117
|
+
-------------------
|
|
118
|
+
DID: did:vorion:google:cc-agent-v1
|
|
119
|
+
Name: CC AI Agent (Google Labs)
|
|
120
|
+
Trust Score: 0
|
|
121
|
+
Tier: T0 (Sandbox)
|
|
122
|
+
Certified: false
|
|
123
|
+
|
|
124
|
+
🔗 View on PolygonScan:
|
|
125
|
+
https://mumbai.polygonscan.com/token/0x.../0
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## Step 6: Certify Agent with AgentAnchor
|
|
131
|
+
|
|
132
|
+
Edit `scripts/certify-agent.ts` and set contract address, then:
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
npx hardhat run scripts/certify-agent.ts --network mumbai
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
**Expected Output**:
|
|
139
|
+
```
|
|
140
|
+
Certifying AgentCard #0...
|
|
141
|
+
Trust Score: 350 (T2: Standard)
|
|
142
|
+
Expiry: <12 months from now>
|
|
143
|
+
|
|
144
|
+
✅ Agent certified successfully!
|
|
145
|
+
DID: did:vorion:google:cc-agent-v1
|
|
146
|
+
Trust Score: 350
|
|
147
|
+
Tier: T2 (Standard)
|
|
148
|
+
Certified: true
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## You've Deployed!
|
|
154
|
+
|
|
155
|
+
### What You Now Have:
|
|
156
|
+
|
|
157
|
+
1. ✅ **AgentCard NFT Contract** deployed on Polygon Mumbai
|
|
158
|
+
2. ✅ **First AgentCard** minted (Token ID: 0)
|
|
159
|
+
3. ✅ **CC Agent Certified** with T2 trust score (350)
|
|
160
|
+
4. ✅ **On-Chain Identity** for `did:vorion:google:cc-agent-v1`
|
|
161
|
+
|
|
162
|
+
### Next Steps:
|
|
163
|
+
|
|
164
|
+
1. **View on PolygonScan**: Explore your contract and AgentCard
|
|
165
|
+
2. **Integrate with KYA SDK**: Use the AgentCard in your applications
|
|
166
|
+
3. **Mint More AgentCards**: Create cards for other agents
|
|
167
|
+
4. **Deploy Portal UI**: Set up AgentAnchor certification portal
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
## Need Help?
|
|
172
|
+
|
|
173
|
+
### Common Issues:
|
|
174
|
+
|
|
175
|
+
**"Insufficient funds for gas"**
|
|
176
|
+
- Get more testnet MATIC from faucet
|
|
177
|
+
- Check balance: `npx hardhat run scripts/check-balance.ts --network mumbai`
|
|
178
|
+
|
|
179
|
+
**"Network error"**
|
|
180
|
+
- Mumbai testnet might be congested
|
|
181
|
+
- Try again in a few minutes
|
|
182
|
+
- Or use different RPC: https://polygon-rpc.com/
|
|
183
|
+
|
|
184
|
+
**"Contract verification failed"**
|
|
185
|
+
- Make sure PolygonScan API key is correct
|
|
186
|
+
- Try again after a few minutes
|
|
187
|
+
- Verification is optional - contract works without it
|
|
188
|
+
|
|
189
|
+
### Scripts Reference:
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
# Compile contract
|
|
193
|
+
npx hardhat compile
|
|
194
|
+
|
|
195
|
+
# Deploy to Mumbai
|
|
196
|
+
npx hardhat run scripts/deploy-agentcard.ts --network mumbai
|
|
197
|
+
|
|
198
|
+
# Mint AgentCard
|
|
199
|
+
npx hardhat run scripts/mint-agentcard.ts --network mumbai
|
|
200
|
+
|
|
201
|
+
# Certify agent
|
|
202
|
+
npx hardhat run scripts/certify-agent.ts --network mumbai
|
|
203
|
+
|
|
204
|
+
# Query AgentCard
|
|
205
|
+
npx hardhat run scripts/query-agentcard.ts --network mumbai
|
|
206
|
+
|
|
207
|
+
# Verify contract
|
|
208
|
+
npx hardhat verify --network mumbai <CONTRACT_ADDRESS>
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
---
|
|
212
|
+
|
|
213
|
+
**You're ready to deploy! 🎯**
|
|
214
|
+
|
|
215
|
+
**Estimated time**: 10-15 minutes total
|
|
216
|
+
**Estimated cost**: ~0.01 MATIC (~$0.008 USD)
|
package/DEPLOYMENT.md
ADDED
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
# AgentCard Smart Contract Deployment Guide
|
|
2
|
+
|
|
3
|
+
## Prerequisites
|
|
4
|
+
|
|
5
|
+
1. **Node.js** 20+ and npm
|
|
6
|
+
2. **Polygon Mumbai testnet** MATIC tokens (get from faucet)
|
|
7
|
+
3. **Private key** with funds
|
|
8
|
+
4. **PolygonScan API key** (optional, for verification)
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Setup
|
|
13
|
+
|
|
14
|
+
### 1. Install Dependencies
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
cd packages/basis
|
|
18
|
+
npm install
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### 2. Configure Environment
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
cp .env.example .env
|
|
25
|
+
# Edit .env with your values
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
**Required**:
|
|
29
|
+
- `PRIVATE_KEY`: Your deployer wallet private key (DO NOT COMMIT)
|
|
30
|
+
- `MUMBAI_RPC_URL`: Polygon Mumbai RPC (default works)
|
|
31
|
+
- `POLYGONSCAN_API_KEY`: For contract verification (optional)
|
|
32
|
+
|
|
33
|
+
### 3. Get Testnet MATIC
|
|
34
|
+
|
|
35
|
+
Visit: https://faucet.polygon.technology/
|
|
36
|
+
- Network: Mumbai
|
|
37
|
+
- Paste your wallet address
|
|
38
|
+
- Request tokens
|
|
39
|
+
|
|
40
|
+
**Check balance**:
|
|
41
|
+
```bash
|
|
42
|
+
npx hardhat run scripts/check-balance.ts --network mumbai
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## Deployment
|
|
48
|
+
|
|
49
|
+
### Mumbai Testnet (Recommended First)
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
npm run deploy:mumbai
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
**Expected output**:
|
|
56
|
+
```
|
|
57
|
+
Deploying AgentCard to mumbai...
|
|
58
|
+
AgentCard deployed to: 0x1234567890abcdef1234567890abcdef12345678
|
|
59
|
+
Granting CERTIFIER_ROLE to 0x...
|
|
60
|
+
CERTIFIER_ROLE granted
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
**Save the contract address!**
|
|
64
|
+
|
|
65
|
+
### Verify on PolygonScan
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
npx hardhat verify --network mumbai <CONTRACT_ADDRESS>
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
**View on PolygonScan**: https://mumbai.polygonscan.com/address/<CONTRACT_ADDRESS>
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## Testing Deployment
|
|
76
|
+
|
|
77
|
+
### 1. Mint First AgentCard
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
npx hardhat run scripts/mint-agentcard.ts --network mumbai
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### 2. Certify Agent
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
npx hardhat run scripts/certify-agent.ts --network mumbai
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### 3. Query AgentCard
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
npx hardhat run scripts/query-agentcard.ts --network mumbai
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## Production Deployment (Polygon Mainnet)
|
|
98
|
+
|
|
99
|
+
**ONLY AFTER TESTING ON MUMBAI!**
|
|
100
|
+
|
|
101
|
+
### 1. Get Real MATIC
|
|
102
|
+
|
|
103
|
+
Purchase MATIC on exchange, withdraw to your wallet.
|
|
104
|
+
|
|
105
|
+
### 2. Update .env
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
POLYGON_RPC_URL=https://polygon-rpc.com
|
|
109
|
+
# Use production private key (with real funds)
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### 3. Deploy
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
npm run deploy:polygon
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### 4. Verify
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
npx hardhat verify --network polygon <CONTRACT_ADDRESS>
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
## Smart Contract Details
|
|
127
|
+
|
|
128
|
+
### Contract: `AgentCard.sol`
|
|
129
|
+
|
|
130
|
+
**Address** (Mumbai): `0x...` (after deployment)
|
|
131
|
+
**Address** (Polygon): `0x...` (after deployment)
|
|
132
|
+
|
|
133
|
+
**Roles**:
|
|
134
|
+
- `DEFAULT_ADMIN_ROLE`: Full admin (deployer)
|
|
135
|
+
- `MINTER_ROLE`: Can mint new AgentCards
|
|
136
|
+
- `CERTIFIER_ROLE`: Can certify agents (AgentAnchor)
|
|
137
|
+
|
|
138
|
+
### Key Functions
|
|
139
|
+
|
|
140
|
+
#### Mint AgentCard
|
|
141
|
+
```solidity
|
|
142
|
+
function mint(
|
|
143
|
+
address to,
|
|
144
|
+
string memory did,
|
|
145
|
+
string memory name,
|
|
146
|
+
string memory description,
|
|
147
|
+
string[] memory capabilities,
|
|
148
|
+
string memory metadataURI
|
|
149
|
+
) public onlyRole(MINTER_ROLE) returns (uint256)
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
#### Certify Agent
|
|
153
|
+
```solidity
|
|
154
|
+
function certify(
|
|
155
|
+
uint256 tokenId,
|
|
156
|
+
uint256 trustScore,
|
|
157
|
+
uint256 expiryTimestamp
|
|
158
|
+
) public onlyRole(CERTIFIER_ROLE)
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
#### Update Trust Score
|
|
162
|
+
```solidity
|
|
163
|
+
function updateTrustScore(
|
|
164
|
+
uint256 tokenId,
|
|
165
|
+
uint256 newTrustScore
|
|
166
|
+
) public onlyRole(CERTIFIER_ROLE)
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
#### Revoke Certification
|
|
170
|
+
```solidity
|
|
171
|
+
function revokeCertification(
|
|
172
|
+
uint256 tokenId,
|
|
173
|
+
string memory reason
|
|
174
|
+
) public onlyRole(CERTIFIER_ROLE)
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
## Gas Costs (Estimated)
|
|
180
|
+
|
|
181
|
+
| Operation | Gas | Cost (20 gwei) | Cost (USD @ $0.80/MATIC) |
|
|
182
|
+
|-----------|-----|----------------|---------------------------|
|
|
183
|
+
| Deploy contract | ~3,500,000 | 0.07 MATIC | ~$0.056 |
|
|
184
|
+
| Mint AgentCard | ~250,000 | 0.005 MATIC | ~$0.004 |
|
|
185
|
+
| Certify agent | ~80,000 | 0.0016 MATIC | ~$0.0013 |
|
|
186
|
+
| Update trust score | ~50,000 | 0.001 MATIC | ~$0.0008 |
|
|
187
|
+
| Revoke certification | ~60,000 | 0.0012 MATIC | ~$0.001 |
|
|
188
|
+
|
|
189
|
+
**Total to deploy + mint + certify**: ~$0.06 on Mumbai, ~$0.10 on Polygon mainnet
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
## Troubleshooting
|
|
194
|
+
|
|
195
|
+
### Error: "Insufficient funds"
|
|
196
|
+
|
|
197
|
+
**Solution**: Get more MATIC from faucet (testnet) or purchase (mainnet)
|
|
198
|
+
|
|
199
|
+
### Error: "Nonce too high"
|
|
200
|
+
|
|
201
|
+
**Solution**: Reset Hardhat:
|
|
202
|
+
```bash
|
|
203
|
+
npx hardhat clean
|
|
204
|
+
rm -rf cache artifacts
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### Error: "Contract already deployed"
|
|
208
|
+
|
|
209
|
+
**Solution**: Check `deployments/mumbai/` folder, contract may already exist
|
|
210
|
+
|
|
211
|
+
### Error: "Verification failed"
|
|
212
|
+
|
|
213
|
+
**Solution**: Wait 1-2 minutes after deployment, then retry verify command
|
|
214
|
+
|
|
215
|
+
---
|
|
216
|
+
|
|
217
|
+
## Next Steps
|
|
218
|
+
|
|
219
|
+
After successful deployment:
|
|
220
|
+
|
|
221
|
+
1. **Update documentation** with contract addresses
|
|
222
|
+
2. **Grant roles** to AgentAnchor backend
|
|
223
|
+
3. **Integrate SDK** into applications
|
|
224
|
+
4. **Test minting** via API
|
|
225
|
+
5. **Monitor** contract on PolygonScan
|
|
226
|
+
|
|
227
|
+
---
|
|
228
|
+
|
|
229
|
+
## Support
|
|
230
|
+
|
|
231
|
+
- **Polygon Docs**: https://docs.polygon.technology/
|
|
232
|
+
- **Hardhat Docs**: https://hardhat.org/docs
|
|
233
|
+
- **OpenZeppelin**: https://docs.openzeppelin.com/contracts/
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
**Document Version**: 1.0.0
|
|
238
|
+
**Last Updated**: 2026-01-22
|
|
239
|
+
**Network**: Polygon Mumbai (testnet) → Polygon Mainnet (production)
|