agentwallet-sdk 3.1.2 → 3.2.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/dist/ap2/index.d.ts +185 -0
- package/dist/ap2/index.d.ts.map +1 -0
- package/dist/ap2/index.js +255 -0
- package/dist/ap2/index.js.map +1 -0
- package/dist/identity/agent-identity.d.ts +276 -0
- package/dist/identity/agent-identity.d.ts.map +1 -0
- package/dist/identity/agent-identity.js +300 -0
- package/dist/identity/agent-identity.js.map +1 -0
- package/dist/identity/erc6551.d.ts +441 -0
- package/dist/identity/erc6551.d.ts.map +1 -0
- package/dist/identity/erc6551.js +517 -0
- package/dist/identity/erc6551.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,517 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MIT License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2026 AgentNexus / agentwallet-sdk contributors
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* ERC-6551: Token Bound Accounts (TBA)
|
|
26
|
+
*
|
|
27
|
+
* Implements the ERC-6551 registry interaction layer, enabling any ERC-721 NFT
|
|
28
|
+
* to own a smart contract wallet. Each agent NFT (ERC-8004) gets a unique,
|
|
29
|
+
* deterministic TBA address derived from its contract + tokenId + chainId.
|
|
30
|
+
*
|
|
31
|
+
* Architecture:
|
|
32
|
+
* ERC-8004 NFT → ERC-6551 TBA → AgentWallet (x402 + payments) → TaskBridge earnings
|
|
33
|
+
*
|
|
34
|
+
* Canonical registry: 0x000000006551c19487814612785009DA0394A50 (all EVM chains)
|
|
35
|
+
* Spec: https://eips.ethereum.org/EIPS/eip-6551
|
|
36
|
+
*
|
|
37
|
+
* @module identity/erc6551
|
|
38
|
+
*/
|
|
39
|
+
import { createPublicClient, http, encodeAbiParameters, parseAbiParameters, keccak256, concat, pad, } from 'viem';
|
|
40
|
+
import { base, baseSepolia, mainnet, arbitrum, polygon } from 'viem/chains';
|
|
41
|
+
// ─── Constants ────────────────────────────────────────────────────────────────
|
|
42
|
+
/**
|
|
43
|
+
* Canonical ERC-6551 Registry address — same on all EVM chains.
|
|
44
|
+
* Deployed via CREATE2 with deterministic address per EIP-6551.
|
|
45
|
+
*/
|
|
46
|
+
export const ERC6551_REGISTRY_ADDRESS = '0x000000006551c19487814612785009DA0394A50';
|
|
47
|
+
/**
|
|
48
|
+
* Default ERC-6551 account implementation deployed by the reference implementation team.
|
|
49
|
+
* This is the Tokenbound reference implementation on Base mainnet.
|
|
50
|
+
* Audited by OpenZeppelin. Source: https://github.com/tokenbound/reference
|
|
51
|
+
*/
|
|
52
|
+
export const ERC6551_DEFAULT_IMPLEMENTATION = '0x55266d75D1a14E4572138116aF39863Ed6596E7F';
|
|
53
|
+
/**
|
|
54
|
+
* Base mainnet chain ID.
|
|
55
|
+
*/
|
|
56
|
+
export const BASE_CHAIN_ID = 8453;
|
|
57
|
+
/**
|
|
58
|
+
* Default salt for TBA derivation (matches Tokenbound reference tooling default).
|
|
59
|
+
*/
|
|
60
|
+
export const DEFAULT_SALT = '0x0000000000000000000000000000000000000000000000000000000000000000';
|
|
61
|
+
// ─── Canonical ERC-6551 Registry ABI ─────────────────────────────────────────
|
|
62
|
+
/**
|
|
63
|
+
* Canonical ERC-6551 Registry ABI from EIP-6551 specification.
|
|
64
|
+
* Source: https://eips.ethereum.org/EIPS/eip-6551
|
|
65
|
+
*/
|
|
66
|
+
export const ERC6551RegistryAbi = [
|
|
67
|
+
/**
|
|
68
|
+
* createAccount — Deploy a TBA for a given NFT.
|
|
69
|
+
* Returns the address of the deployed account (or existing account if already deployed).
|
|
70
|
+
*/
|
|
71
|
+
{
|
|
72
|
+
name: 'createAccount',
|
|
73
|
+
type: 'function',
|
|
74
|
+
stateMutability: 'nonpayable',
|
|
75
|
+
inputs: [
|
|
76
|
+
{ name: 'implementation', type: 'address' },
|
|
77
|
+
{ name: 'salt', type: 'bytes32' },
|
|
78
|
+
{ name: 'chainId', type: 'uint256' },
|
|
79
|
+
{ name: 'tokenContract', type: 'address' },
|
|
80
|
+
{ name: 'tokenId', type: 'uint256' },
|
|
81
|
+
],
|
|
82
|
+
outputs: [{ name: 'account', type: 'address' }],
|
|
83
|
+
},
|
|
84
|
+
/**
|
|
85
|
+
* account — Compute the deterministic TBA address (does NOT deploy).
|
|
86
|
+
*/
|
|
87
|
+
{
|
|
88
|
+
name: 'account',
|
|
89
|
+
type: 'function',
|
|
90
|
+
stateMutability: 'view',
|
|
91
|
+
inputs: [
|
|
92
|
+
{ name: 'implementation', type: 'address' },
|
|
93
|
+
{ name: 'salt', type: 'bytes32' },
|
|
94
|
+
{ name: 'chainId', type: 'uint256' },
|
|
95
|
+
{ name: 'tokenContract', type: 'address' },
|
|
96
|
+
{ name: 'tokenId', type: 'uint256' },
|
|
97
|
+
],
|
|
98
|
+
outputs: [{ name: 'account', type: 'address' }],
|
|
99
|
+
},
|
|
100
|
+
/**
|
|
101
|
+
* AccountCreated event — emitted when a TBA is deployed.
|
|
102
|
+
*/
|
|
103
|
+
{
|
|
104
|
+
name: 'AccountCreated',
|
|
105
|
+
type: 'event',
|
|
106
|
+
inputs: [
|
|
107
|
+
{ name: 'account', type: 'address', indexed: false },
|
|
108
|
+
{ name: 'implementation', type: 'address', indexed: true },
|
|
109
|
+
{ name: 'salt', type: 'bytes32', indexed: false },
|
|
110
|
+
{ name: 'chainId', type: 'uint256', indexed: false },
|
|
111
|
+
{ name: 'tokenContract', type: 'address', indexed: true },
|
|
112
|
+
{ name: 'tokenId', type: 'uint256', indexed: true },
|
|
113
|
+
],
|
|
114
|
+
},
|
|
115
|
+
];
|
|
116
|
+
/**
|
|
117
|
+
* Minimal ABI for the ERC-6551 Account (TBA) — the wallet owned by the NFT.
|
|
118
|
+
* Implements IERC6551Account + IERC6551Executable per the reference implementation.
|
|
119
|
+
*/
|
|
120
|
+
export const ERC6551AccountAbi = [
|
|
121
|
+
/**
|
|
122
|
+
* execute — Execute a call from the TBA (the agent acts).
|
|
123
|
+
* Only callable by the NFT owner or approved operators.
|
|
124
|
+
*/
|
|
125
|
+
{
|
|
126
|
+
name: 'execute',
|
|
127
|
+
type: 'function',
|
|
128
|
+
stateMutability: 'payable',
|
|
129
|
+
inputs: [
|
|
130
|
+
{ name: 'to', type: 'address' },
|
|
131
|
+
{ name: 'value', type: 'uint256' },
|
|
132
|
+
{ name: 'data', type: 'bytes' },
|
|
133
|
+
{ name: 'operation', type: 'uint8' }, // 0 = call, 1 = delegatecall, 2 = staticcall
|
|
134
|
+
],
|
|
135
|
+
outputs: [{ name: 'result', type: 'bytes' }],
|
|
136
|
+
},
|
|
137
|
+
/**
|
|
138
|
+
* token — Returns the ERC-721 token that owns this account.
|
|
139
|
+
*/
|
|
140
|
+
{
|
|
141
|
+
name: 'token',
|
|
142
|
+
type: 'function',
|
|
143
|
+
stateMutability: 'view',
|
|
144
|
+
inputs: [],
|
|
145
|
+
outputs: [
|
|
146
|
+
{ name: 'chainId', type: 'uint256' },
|
|
147
|
+
{ name: 'tokenContract', type: 'address' },
|
|
148
|
+
{ name: 'tokenId', type: 'uint256' },
|
|
149
|
+
],
|
|
150
|
+
},
|
|
151
|
+
/**
|
|
152
|
+
* owner — Returns the current owner of the account (NFT owner).
|
|
153
|
+
*/
|
|
154
|
+
{
|
|
155
|
+
name: 'owner',
|
|
156
|
+
type: 'function',
|
|
157
|
+
stateMutability: 'view',
|
|
158
|
+
inputs: [],
|
|
159
|
+
outputs: [{ name: '', type: 'address' }],
|
|
160
|
+
},
|
|
161
|
+
/**
|
|
162
|
+
* state — Returns execution state (nonce-like value to prevent replay attacks).
|
|
163
|
+
*/
|
|
164
|
+
{
|
|
165
|
+
name: 'state',
|
|
166
|
+
type: 'function',
|
|
167
|
+
stateMutability: 'view',
|
|
168
|
+
inputs: [],
|
|
169
|
+
outputs: [{ name: '', type: 'uint256' }],
|
|
170
|
+
},
|
|
171
|
+
/**
|
|
172
|
+
* isValidSigner — Returns EIP-1271 magic value if signer is authorized.
|
|
173
|
+
*/
|
|
174
|
+
{
|
|
175
|
+
name: 'isValidSigner',
|
|
176
|
+
type: 'function',
|
|
177
|
+
stateMutability: 'view',
|
|
178
|
+
inputs: [
|
|
179
|
+
{ name: 'signer', type: 'address' },
|
|
180
|
+
{ name: 'context', type: 'bytes' },
|
|
181
|
+
],
|
|
182
|
+
outputs: [{ name: 'magicValue', type: 'bytes4' }],
|
|
183
|
+
},
|
|
184
|
+
];
|
|
185
|
+
// ─── Chain map ────────────────────────────────────────────────────────────────
|
|
186
|
+
const CHAINS = {
|
|
187
|
+
base,
|
|
188
|
+
'base-sepolia': baseSepolia,
|
|
189
|
+
ethereum: mainnet,
|
|
190
|
+
arbitrum,
|
|
191
|
+
polygon,
|
|
192
|
+
};
|
|
193
|
+
const CHAIN_IDS = {
|
|
194
|
+
base: 8453,
|
|
195
|
+
'base-sepolia': 84532,
|
|
196
|
+
ethereum: 1,
|
|
197
|
+
arbitrum: 42161,
|
|
198
|
+
polygon: 137,
|
|
199
|
+
};
|
|
200
|
+
// ─── ERC6551Client ────────────────────────────────────────────────────────────
|
|
201
|
+
/**
|
|
202
|
+
* ERC-6551 Token Bound Account client.
|
|
203
|
+
*
|
|
204
|
+
* Enables any ERC-721 NFT to own a smart contract wallet (TBA). Used to attach
|
|
205
|
+
* an autonomous spending account to every agent identity NFT (ERC-8004).
|
|
206
|
+
*
|
|
207
|
+
* All write operations require a WalletClient — keys never leave the caller's device.
|
|
208
|
+
* The TBA address is deterministic: same NFT + same salt = same address, always.
|
|
209
|
+
*
|
|
210
|
+
* @example
|
|
211
|
+
* ```typescript
|
|
212
|
+
* import { ERC6551Client } from 'agentwallet-sdk';
|
|
213
|
+
*
|
|
214
|
+
* const client = new ERC6551Client({ chain: 'base' });
|
|
215
|
+
*
|
|
216
|
+
* // Compute the TBA address before deploying
|
|
217
|
+
* const tbaAddress = await client.getTBAAddress('0xNFTContract', 1n);
|
|
218
|
+
*
|
|
219
|
+
* // Deploy it on-chain
|
|
220
|
+
* const { address } = await client.createTBA(walletClient, '0xNFTContract', 1n);
|
|
221
|
+
*
|
|
222
|
+
* // Execute a call from the TBA (the agent acts)
|
|
223
|
+
* const result = await client.executeTBA(walletClient, address, {
|
|
224
|
+
* to: '0xTarget',
|
|
225
|
+
* value: parseEther('0.01'),
|
|
226
|
+
* data: '0x',
|
|
227
|
+
* });
|
|
228
|
+
* ```
|
|
229
|
+
*/
|
|
230
|
+
export class ERC6551Client {
|
|
231
|
+
constructor(config = {}) {
|
|
232
|
+
const chainKey = config.chain ?? 'base';
|
|
233
|
+
const chain = CHAINS[chainKey];
|
|
234
|
+
if (!chain)
|
|
235
|
+
throw new Error(`ERC6551Client: Unsupported chain "${chainKey}"`);
|
|
236
|
+
this.chain = chain;
|
|
237
|
+
this.chainId = CHAIN_IDS[chainKey];
|
|
238
|
+
this.registryAddress = config.registryAddress ?? ERC6551_REGISTRY_ADDRESS;
|
|
239
|
+
this.implementationAddress = config.implementationAddress ?? ERC6551_DEFAULT_IMPLEMENTATION;
|
|
240
|
+
this.publicClient = createPublicClient({
|
|
241
|
+
chain,
|
|
242
|
+
transport: http(config.rpcUrl),
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
// ─── Core: Address derivation ─────────────────────────────────────────────
|
|
246
|
+
/**
|
|
247
|
+
* Compute the deterministic TBA address for an NFT (off-chain, no RPC needed).
|
|
248
|
+
*
|
|
249
|
+
* Uses the ERC-6551 registry's CREATE2 formula:
|
|
250
|
+
* address = keccak256(0xff ++ registry ++ salt' ++ keccak256(initCode))
|
|
251
|
+
* where salt' and initCode encode the chain + token details.
|
|
252
|
+
*
|
|
253
|
+
* This mirrors the registry's on-chain `account()` view function but does not
|
|
254
|
+
* require a network call. Use `getTBAAddress()` for on-chain verification.
|
|
255
|
+
*
|
|
256
|
+
* @param nftContract - Address of the ERC-721 contract
|
|
257
|
+
* @param tokenId - Token ID of the agent NFT
|
|
258
|
+
* @param salt - Optional salt (defaults to 0x000...0)
|
|
259
|
+
* @returns Deterministic TBA address
|
|
260
|
+
*/
|
|
261
|
+
computeTBAAddress(nftContract, tokenId, salt = DEFAULT_SALT) {
|
|
262
|
+
// ERC-6551 registry init code for CREATE2:
|
|
263
|
+
// The registry deploys a minimal proxy (EIP-1167) pointing to the implementation,
|
|
264
|
+
// appending the context (chainId, tokenContract, tokenId) after the bytecode.
|
|
265
|
+
// keccak256(creationCode ++ abi.encode(chainId, tokenContract, tokenId))
|
|
266
|
+
const encodedContext = encodeAbiParameters(parseAbiParameters('uint256, address, uint256'), [BigInt(this.chainId), nftContract, tokenId]);
|
|
267
|
+
// EIP-1167 minimal proxy init code for ERC-6551 (per reference implementation)
|
|
268
|
+
// Constructed as: prefix + implementation + suffix + encoded context
|
|
269
|
+
const eip1167Prefix = '0x3d60ad80600a3d3981f3363d3d373d3d3d363d73';
|
|
270
|
+
const eip1167Suffix = '0x5af43d82803e903d91602b57fd5bf3';
|
|
271
|
+
const implPadded = pad(this.implementationAddress, { size: 20 });
|
|
272
|
+
const creationCode = concat([eip1167Prefix, implPadded, eip1167Suffix]);
|
|
273
|
+
const initCodeHash = keccak256(concat([creationCode, encodedContext]));
|
|
274
|
+
// CREATE2: keccak256(0xff ++ deployer ++ salt ++ initCodeHash)[12:]
|
|
275
|
+
const create2Input = concat([
|
|
276
|
+
'0xff',
|
|
277
|
+
this.registryAddress,
|
|
278
|
+
salt,
|
|
279
|
+
initCodeHash,
|
|
280
|
+
]);
|
|
281
|
+
const hash = keccak256(create2Input);
|
|
282
|
+
// Take last 20 bytes as address
|
|
283
|
+
return `0x${hash.slice(-40)}`;
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Get the deterministic TBA address for an NFT via on-chain registry view call.
|
|
287
|
+
*
|
|
288
|
+
* Calls the registry's `account()` view function — authoritative and gas-free.
|
|
289
|
+
* For offline computation, use `computeTBAAddress()` instead.
|
|
290
|
+
*
|
|
291
|
+
* @param nftContract - Address of the ERC-721 contract
|
|
292
|
+
* @param tokenId - Token ID of the agent NFT
|
|
293
|
+
* @param salt - Optional salt (defaults to 0x000...0)
|
|
294
|
+
* @returns Deterministic TBA address from registry
|
|
295
|
+
*/
|
|
296
|
+
async getTBAAddress(nftContract, tokenId, salt = DEFAULT_SALT) {
|
|
297
|
+
const result = await this.publicClient.readContract({
|
|
298
|
+
address: this.registryAddress,
|
|
299
|
+
abi: ERC6551RegistryAbi,
|
|
300
|
+
functionName: 'account',
|
|
301
|
+
args: [this.implementationAddress, salt, BigInt(this.chainId), nftContract, tokenId],
|
|
302
|
+
});
|
|
303
|
+
return result;
|
|
304
|
+
}
|
|
305
|
+
// ─── Core: Deployment ────────────────────────────────────────────────────
|
|
306
|
+
/**
|
|
307
|
+
* Deploy a Token Bound Account for an agent NFT.
|
|
308
|
+
*
|
|
309
|
+
* Calls `createAccount()` on the ERC-6551 registry. If the TBA is already
|
|
310
|
+
* deployed, the registry returns the existing address without reverting.
|
|
311
|
+
* Idempotent and safe to call multiple times.
|
|
312
|
+
*
|
|
313
|
+
* Non-custodial: the walletClient signs the transaction locally.
|
|
314
|
+
* The deployer does NOT need to own the NFT — anyone can deploy a TBA.
|
|
315
|
+
*
|
|
316
|
+
* @param walletClient - WalletClient to sign the deployment transaction
|
|
317
|
+
* @param nftContract - Address of the ERC-721 contract
|
|
318
|
+
* @param tokenId - Token ID of the agent NFT
|
|
319
|
+
* @param salt - Optional salt for address uniqueness (defaults to 0x000...0)
|
|
320
|
+
* @returns Deployed TBAAccount with address and deployment metadata
|
|
321
|
+
*/
|
|
322
|
+
async createTBA(walletClient, nftContract, tokenId, salt = DEFAULT_SALT) {
|
|
323
|
+
if (!walletClient.account) {
|
|
324
|
+
throw new Error('ERC6551Client: WalletClient has no account');
|
|
325
|
+
}
|
|
326
|
+
const txHash = await walletClient.writeContract({
|
|
327
|
+
address: this.registryAddress,
|
|
328
|
+
abi: ERC6551RegistryAbi,
|
|
329
|
+
functionName: 'createAccount',
|
|
330
|
+
args: [this.implementationAddress, salt, BigInt(this.chainId), nftContract, tokenId],
|
|
331
|
+
account: walletClient.account,
|
|
332
|
+
chain: this.chain,
|
|
333
|
+
});
|
|
334
|
+
// Wait for receipt and extract the deployed address from event
|
|
335
|
+
const receipt = await this.publicClient.waitForTransactionReceipt({ hash: txHash });
|
|
336
|
+
// Try to extract address from AccountCreated event
|
|
337
|
+
let tbaAddress = null;
|
|
338
|
+
for (const log of receipt.logs) {
|
|
339
|
+
if (log.address.toLowerCase() === this.registryAddress.toLowerCase()) {
|
|
340
|
+
// AccountCreated event — non-indexed 'account' is the first topic after sig
|
|
341
|
+
// We can also just compute it deterministically since we have all params
|
|
342
|
+
tbaAddress = this.computeTBAAddress(nftContract, tokenId, salt);
|
|
343
|
+
break;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
// Fallback: compute deterministically
|
|
347
|
+
if (!tbaAddress) {
|
|
348
|
+
tbaAddress = this.computeTBAAddress(nftContract, tokenId, salt);
|
|
349
|
+
}
|
|
350
|
+
const owner = await this.getTBAOwner(tbaAddress).catch(() => null);
|
|
351
|
+
return {
|
|
352
|
+
address: tbaAddress,
|
|
353
|
+
nftContract,
|
|
354
|
+
tokenId,
|
|
355
|
+
salt,
|
|
356
|
+
chainId: this.chainId,
|
|
357
|
+
implementation: this.implementationAddress,
|
|
358
|
+
isDeployed: true,
|
|
359
|
+
owner,
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
// ─── Core: Execution ─────────────────────────────────────────────────────
|
|
363
|
+
/**
|
|
364
|
+
* Execute a call from a Token Bound Account (the agent acts autonomously).
|
|
365
|
+
*
|
|
366
|
+
* The TBA's `execute()` function routes the call through the NFT owner
|
|
367
|
+
* authorization check before dispatching to the target contract.
|
|
368
|
+
*
|
|
369
|
+
* Only the NFT owner (or an approved ERC-6551 operator) can execute calls.
|
|
370
|
+
* This is the primary mechanism by which agents interact with DeFi protocols,
|
|
371
|
+
* TaskBridge, and other on-chain systems.
|
|
372
|
+
*
|
|
373
|
+
* @param walletClient - WalletClient owning the NFT (authorized to execute)
|
|
374
|
+
* @param tbaAddress - Address of the deployed TBA
|
|
375
|
+
* @param params - Call parameters (to, value, data, operation)
|
|
376
|
+
* @returns Transaction hash and raw return data
|
|
377
|
+
*
|
|
378
|
+
* @example
|
|
379
|
+
* ```typescript
|
|
380
|
+
* // Agent pays for a TaskBridge task
|
|
381
|
+
* const result = await client.executeTBA(walletClient, tbaAddress, {
|
|
382
|
+
* to: TASKBRIDGE_CONTRACT,
|
|
383
|
+
* value: parseEther('0.1'),
|
|
384
|
+
* data: encodeFunctionData({ abi: TaskBridgeAbi, functionName: 'bidTask', args: [taskId] }),
|
|
385
|
+
* });
|
|
386
|
+
* ```
|
|
387
|
+
*/
|
|
388
|
+
async executeTBA(walletClient, tbaAddress, params) {
|
|
389
|
+
if (!walletClient.account) {
|
|
390
|
+
throw new Error('ERC6551Client: WalletClient has no account');
|
|
391
|
+
}
|
|
392
|
+
const txHash = await walletClient.writeContract({
|
|
393
|
+
address: tbaAddress,
|
|
394
|
+
abi: ERC6551AccountAbi,
|
|
395
|
+
functionName: 'execute',
|
|
396
|
+
args: [
|
|
397
|
+
params.to,
|
|
398
|
+
params.value ?? 0n,
|
|
399
|
+
params.data ?? '0x',
|
|
400
|
+
params.operation ?? 0,
|
|
401
|
+
],
|
|
402
|
+
account: walletClient.account,
|
|
403
|
+
chain: this.chain,
|
|
404
|
+
value: params.value ?? 0n,
|
|
405
|
+
});
|
|
406
|
+
// Read return data from receipt (emitted as event or in call trace)
|
|
407
|
+
// For simplicity, return the hash — result parsing requires simulation
|
|
408
|
+
return { txHash, returnData: null };
|
|
409
|
+
}
|
|
410
|
+
// ─── Core: Introspection ──────────────────────────────────────────────────
|
|
411
|
+
/**
|
|
412
|
+
* Check whether a TBA is deployed on-chain.
|
|
413
|
+
*
|
|
414
|
+
* A TBA address can be computed deterministically before deployment.
|
|
415
|
+
* This function checks if the contract actually exists at that address.
|
|
416
|
+
*
|
|
417
|
+
* @param tbaAddress - TBA address to check
|
|
418
|
+
* @returns true if code exists at tbaAddress (TBA is deployed)
|
|
419
|
+
*/
|
|
420
|
+
async isTBADeployed(tbaAddress) {
|
|
421
|
+
const code = await this.publicClient.getBytecode({ address: tbaAddress });
|
|
422
|
+
return code !== undefined && code !== '0x' && code.length > 2;
|
|
423
|
+
}
|
|
424
|
+
/**
|
|
425
|
+
* Get the current owner of a Token Bound Account.
|
|
426
|
+
*
|
|
427
|
+
* Returns the address that owns the underlying NFT, which is the authorized
|
|
428
|
+
* principal for this agent TBA. This is the human (or parent agent) who
|
|
429
|
+
* controls the agent.
|
|
430
|
+
*
|
|
431
|
+
* @param tbaAddress - Address of the deployed TBA
|
|
432
|
+
* @returns Address of the NFT owner (human principal)
|
|
433
|
+
*/
|
|
434
|
+
async getTBAOwner(tbaAddress) {
|
|
435
|
+
const owner = await this.publicClient.readContract({
|
|
436
|
+
address: tbaAddress,
|
|
437
|
+
abi: ERC6551AccountAbi,
|
|
438
|
+
functionName: 'owner',
|
|
439
|
+
args: [],
|
|
440
|
+
});
|
|
441
|
+
return owner;
|
|
442
|
+
}
|
|
443
|
+
/**
|
|
444
|
+
* Get the full TBA account details for an NFT.
|
|
445
|
+
*
|
|
446
|
+
* Computes the deterministic address, checks deployment status, and resolves
|
|
447
|
+
* the owner if deployed. A single call to get everything you need about a TBA.
|
|
448
|
+
*
|
|
449
|
+
* @param nftContract - ERC-721 contract address
|
|
450
|
+
* @param tokenId - Token ID
|
|
451
|
+
* @param salt - Optional salt (defaults to 0x000...0)
|
|
452
|
+
* @returns Full TBAAccount details
|
|
453
|
+
*/
|
|
454
|
+
async getTBAAccount(nftContract, tokenId, salt = DEFAULT_SALT) {
|
|
455
|
+
const address = this.computeTBAAddress(nftContract, tokenId, salt);
|
|
456
|
+
const isDeployed = await this.isTBADeployed(address);
|
|
457
|
+
const owner = isDeployed ? await this.getTBAOwner(address).catch(() => null) : null;
|
|
458
|
+
return {
|
|
459
|
+
address,
|
|
460
|
+
nftContract,
|
|
461
|
+
tokenId,
|
|
462
|
+
salt,
|
|
463
|
+
chainId: this.chainId,
|
|
464
|
+
implementation: this.implementationAddress,
|
|
465
|
+
isDeployed,
|
|
466
|
+
owner,
|
|
467
|
+
};
|
|
468
|
+
}
|
|
469
|
+
/**
|
|
470
|
+
* Get the NFT token info bound to a deployed TBA.
|
|
471
|
+
*
|
|
472
|
+
* Calls the TBA's `token()` function to retrieve the NFT contract + tokenId
|
|
473
|
+
* that governs ownership of this account.
|
|
474
|
+
*
|
|
475
|
+
* @param tbaAddress - Address of the deployed TBA
|
|
476
|
+
* @returns Chain ID, NFT contract, and token ID
|
|
477
|
+
*/
|
|
478
|
+
async getTBAToken(tbaAddress) {
|
|
479
|
+
const result = await this.publicClient.readContract({
|
|
480
|
+
address: tbaAddress,
|
|
481
|
+
abi: ERC6551AccountAbi,
|
|
482
|
+
functionName: 'token',
|
|
483
|
+
args: [],
|
|
484
|
+
});
|
|
485
|
+
return {
|
|
486
|
+
chainId: result[0],
|
|
487
|
+
tokenContract: result[1],
|
|
488
|
+
tokenId: result[2],
|
|
489
|
+
};
|
|
490
|
+
}
|
|
491
|
+
/**
|
|
492
|
+
* Get the current execution state (nonce) of a TBA.
|
|
493
|
+
* Increments on each execute() call — use for replay protection.
|
|
494
|
+
*
|
|
495
|
+
* @param tbaAddress - Address of the deployed TBA
|
|
496
|
+
* @returns Current state value (uint256)
|
|
497
|
+
*/
|
|
498
|
+
async getTBAState(tbaAddress) {
|
|
499
|
+
const state = await this.publicClient.readContract({
|
|
500
|
+
address: tbaAddress,
|
|
501
|
+
abi: ERC6551AccountAbi,
|
|
502
|
+
functionName: 'state',
|
|
503
|
+
args: [],
|
|
504
|
+
});
|
|
505
|
+
return state;
|
|
506
|
+
}
|
|
507
|
+
// ─── Getters ──────────────────────────────────────────────────────────────
|
|
508
|
+
/** Registry address used by this client. */
|
|
509
|
+
get registry() { return this.registryAddress; }
|
|
510
|
+
/** Implementation address used by this client. */
|
|
511
|
+
get implementation() { return this.implementationAddress; }
|
|
512
|
+
/** Chain this client is connected to. */
|
|
513
|
+
get connectedChain() { return this.chain; }
|
|
514
|
+
/** Chain ID this client is connected to. */
|
|
515
|
+
get connectedChainId() { return this.chainId; }
|
|
516
|
+
}
|
|
517
|
+
//# sourceMappingURL=erc6551.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"erc6551.js","sourceRoot":"","sources":["../../src/identity/erc6551.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH;;;;;;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iB;YACtB,YAAY,EAAE,OAAO;YACrB,IAAI,EAAE,EAAE;SACT,CAAuC,CAAC;QAEzC,OAAO;YACL,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;YAClB,aAAa,EAAE,MAAM,CAAC,CAAC,CAAC;YACxB,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;SACnB,CAAC;IACJ,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,WAAW,CAAC,UAAmB;QACnC,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC;YACjD,OAAO,EAAE,UAAU;YACnB,GAAG,EAAE,iBAAiB;YACtB,YAAY,EAAE,OAAO;YACrB,IAAI,EAAE,EAAE;SACT,CAAC,CAAC;QACH,OAAO,KAAe,CAAC;IACzB,CAAC;IAED,6EAA6E;IAE7E,4CAA4C;IAC5C,IAAI,QAAQ,KAAc,OAAO,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC;IAExD,kDAAkD;IAClD,IAAI,cAAc,KAAc,OAAO,IAAI,CAAC,qBAAqB,CAAC,CAAC,CAAC;IAEpE,yCAAyC;IACzC,IAAI,cAAc,KAAY,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAElD,4CAA4C;IAC5C,IAAI,gBAAgB,KAAa,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;CACxD"}
|
package/dist/index.d.ts
CHANGED
|
@@ -14,6 +14,10 @@ export { SolanaWallet, JupiterSwapClient, attachJupiterSwap, SolanaX402Client, c
|
|
|
14
14
|
export type { SolanaWalletConfig, SolanaTransferParams, SolanaCommitment, JupiterQuote, JupiterRoutePlan, JupiterSwapParams, JupiterSwapResult, SolanaX402PaymentProof, SolanaX402Requirements, SolanaX402Network, } from './solana/index.js';
|
|
15
15
|
export { ERC8004Client, ERC8004IdentityRegistryAbi, METADATA_KEYS, REGISTRATION_FILE_TYPE, KNOWN_REGISTRY_ADDRESSES, buildDataURI, parseDataURI, resolveAgentURI, validateRegistrationFile, formatAgentRegistry, } from './identity/erc8004.js';
|
|
16
16
|
export type { AgentIdentity, AgentRegistrationFile, AgentServiceEndpoint, AgentRegistrationRef, AgentModelMetadata, ERC8004ClientConfig, MetadataEntry, RegistrationResult, SupportedTrustMechanism, } from './identity/erc8004.js';
|
|
17
|
+
export { ERC6551Client, ERC6551RegistryAbi, ERC6551AccountAbi, ERC6551_REGISTRY_ADDRESS, ERC6551_DEFAULT_IMPLEMENTATION, BASE_CHAIN_ID, DEFAULT_SALT, } from './identity/erc6551.js';
|
|
18
|
+
export type { TBAConfig, TBAAccount, TBAExecuteResult, TBAExecuteParams, } from './identity/erc6551.js';
|
|
19
|
+
export { AgentIdentity as AgentIdentityManager } from './identity/agent-identity.js';
|
|
20
|
+
export type { AgentIdentityConfig, AgentIdentityState, AgentIdentityChain, } from './identity/agent-identity.js';
|
|
17
21
|
export { SwapModule, attachSwap, calcProtocolFee, applySlippage, calcDeadline, } from './swap/index.js';
|
|
18
22
|
export { UniswapV3RouterAbi, UniswapV3QuoterV2Abi, ERC20Abi, } from './swap/index.js';
|
|
19
23
|
export { BASE_TOKENS, UNISWAP_V3_BASE, PROTOCOL_FEE_BPS, DEFAULT_SLIPPAGE_BPS, } from './swap/index.js';
|
|
@@ -38534,4 +38538,6 @@ export type { BuiltTransaction } from './flash/index.js';
|
|
|
38534
38538
|
export type { FlashLoanConfig, FlashLoanResult, FlashOpportunity, ArbitrageOpportunity, LiquidationOpportunity, FlashScanResult, FlashOpportunityType, FlashLoanProvider, } from './flash/index.js';
|
|
38535
38539
|
export { CowSolverAdapter, AuctionAnalyzer, SolutionBuilder } from './solver/index.js';
|
|
38536
38540
|
export type { OrderKind, SigningScheme, TokenBalance, CowOrder, CowAuctionBatch, TokenInteraction, SolverSolution, SolutionSubmissionResult, SolverStats, SolverConfig, } from './solver/index.js';
|
|
38541
|
+
export { AP2Client, AP2Error, buildPacs008 } from './ap2/index.js';
|
|
38542
|
+
export type { AP2ClientConfig, AP2PaymentParams, AP2Quote, AP2Receipt, } from './ap2/index.js';
|
|
38537
38543
|
//# sourceMappingURL=index.d.ts.map
|