Programs

代理工具

Last updated March 12, 2026

代理工具程序管理代理资产的执行委托,允许资产所有者将执行权限委托给执行档案。

Summary

代理工具程序(TLREGni9ZEyGC3vnPZtqUh95xQ8oPqJSvNjvB7FGK8S)提供两个管理执行委托的指令:RegisterExecutiveV1 创建执行档案,DelegateExecutionV1 授予该档案代表代理资产执行的权限。

  • 两个指令RegisterExecutiveV1(一次性档案设置)和 DelegateExecutionV1(按资产委托)
  • ExecutiveProfileV1 — 从 ["executive_profile", <authority>] 派生的 40 字节 PDA,每个钱包一个
  • ExecutionDelegateRecordV1 — 将执行档案与特定代理资产关联的 104 字节 PDA
  • 仅所有者委托 — 只有资产所有者才能创建委托记录;程序在链上验证所有权

程序 ID

相同的程序地址部署在主网和开发网上。

网络地址
主网TLREGni9ZEyGC3vnPZtqUh95xQ8oPqJSvNjvB7FGK8S
开发网TLREGni9ZEyGC3vnPZtqUh95xQ8oPqJSvNjvB7FGK8S

概述

工具程序提供两个指令:

  1. RegisterExecutiveV1 — 创建可作为代理资产执行者的执行档案
  2. DelegateExecutionV1 — 授予执行档案代表代理资产执行的权限

执行档案每个权限方注册一次。委托按资产进行——资产所有者创建将其代理资产与特定执行档案关联的委托记录。

指令:RegisterExecutiveV1

为指定权限方创建执行档案 PDA。

账户

需要四个账户:待创建的档案 PDA、付款方、可选权限方和系统程序。

账户可写签名者可选描述
executiveProfile待创建的 PDA(从权限方自动派生)
payer支付账户租金和费用
authority此执行档案的权限方(默认为 payer
systemProgram系统程序

操作内容

  1. 从种子 ["executive_profile", <authority>] 派生 PDA
  2. 验证账户未初始化
  3. 创建并初始化存储权限方的 ExecutiveProfileV1 账户(40 字节)

指令:DelegateExecutionV1

将代理资产的执行权限委托给执行档案。

账户

需要七个账户,包括执行档案、代理资产、其身份 PDA 和待创建的委托记录 PDA。

账户可写签名者可选描述
executiveProfile已注册的执行档案
agentAsset要委托的 MPL Core 资产
agentIdentity资产的代理身份 PDA
executionDelegateRecord待创建的 PDA(自动派生)
payer支付账户租金和费用
authority必须是资产所有者(默认为 payer
systemProgram系统程序

操作内容

  1. 验证执行档案存在且已初始化
  2. 验证代理资产是有效的 MPL Core 资产
  3. 验证代理身份已为该资产注册
  4. 验证签名者是资产所有者
  5. 从种子 ["execution_delegate_record", <executive_profile>, <agent_asset>] 派生 PDA
  6. 创建并初始化 ExecutionDelegateRecordV1 账户(104 字节)

PDA 派生

两种账户类型都是从确定性种子派生的 PDA。使用 SDK 辅助函数计算它们。

账户种子大小
ExecutiveProfileV1["executive_profile", <authority>]40 字节
ExecutionDelegateRecordV1["execution_delegate_record", <executive_profile>, <agent_asset>]104 字节
import {
findExecutiveProfileV1Pda,
findExecutionDelegateRecordV1Pda,
} from '@metaplex-foundation/mpl-agent-registry';
const profilePda = findExecutiveProfileV1Pda(umi, {
authority: authorityPublicKey,
});
const delegatePda = findExecutionDelegateRecordV1Pda(umi, {
executiveProfile: profilePda,
agentAsset: assetPublicKey,
});

账户:ExecutiveProfileV1

存储拥有此执行档案的权限方。40 字节,8 字节对齐。

偏移字段类型大小描述
0keyu81账户鉴别器(1 = ExecutiveProfileV1)
1_padding[u8; 7]7对齐填充
8authorityPubkey32此执行档案的权限方

账户:ExecutionDelegateRecordV1

将执行档案与代理资产关联,记录谁有权代表其执行。104 字节,8 字节对齐。

偏移字段类型大小描述
0keyu81账户鉴别器(2 = ExecutionDelegateRecordV1)
1bumpu81PDA bump 种子
2_padding[u8; 6]6对齐填充
8executiveProfilePubkey32执行档案地址
40authorityPubkey32执行权限方
72agentAssetPubkey32代理资产地址

错误

程序在注册或委托过程中验证失败时返回这些错误。

代码名称描述
0InvalidSystemProgram系统程序账户不正确
1InvalidInstructionData指令数据格式错误
2InvalidAccountData无效的账户数据
3InvalidMplCoreProgramMPL Core 程序账户不正确
4InvalidCoreAsset资产不是有效的 MPL Core 资产
5ExecutiveProfileMustBeUninitialized执行档案已存在
6InvalidExecutionDelegateRecordDerivation委托记录 PDA 派生不匹配
7ExecutionDelegateRecordMustBeUninitialized委托记录已存在
8InvalidAgentIdentity代理身份账户无效
9AgentIdentityNotRegistered资产没有已注册的身份
10AssetOwnerMustBeTheOneToDelegateExecution只有资产所有者才能委托执行
11InvalidExecutiveProfileDerivation执行档案 PDA 派生不匹配

Metaplex 维护 · 最后验证于 2026 年 3 月 · 在 GitHub 上查看源代码