solana指令解析-address lookup table
什么是address lookup table?
address lookup table称为地址查找表,用于存储地址的索引信息,为了快速查找和索引账户地址而存在的数据结构。它允许开发人员创建相关地址的集合,以便在单个事务中有效地加载更多地址,可以帮助快速查找账户的公钥,并提供与这些账户相关联的一些元数据,例如账户的所有者、状态等信息。这些信息可以被智能合约或其他程序用于执行特定的操作,例如检索数据、更新状态等。以便在处理交易和指令时快速查找和访问相关账户。
ProgramID:
AddressLookupTab1e1111111111111111111111111
address_lookup_table指令汇总:
指令 | 值 | 说明 |
---|---|---|
CreateLookupTable | 0 | 创建地址查找表 |
FreezeLookupTable | 1 | 冻结地址查找表 |
ExtendLookupTable | 2 | 扩展地址查找表 |
DeactivateLookupTable | 3 | 停用地址查找表 |
CloseLookupTable | 4 | 关闭地址查找表 |
源码地址:github.com/blocto/solana-go-sdk/program/address_lookup_table
1.CreateLookupTable 创建地址查找表
此指令用于在 Solana 区块链上创建新的地址查找表。创建地址查找表时需要指定所有者、支付创建费用等信息。
源码:
type CreateLookupTableParams struct {
LookupTable common.PublicKey
Authority common.PublicKey
Payer common.PublicKey
RecentSlot uint64
BumpSeed uint8
}
func CreateLookupTable(params CreateLookupTableParams) types.Instruction {
return types.Instruction{
ProgramID: common.AddressLookupTableProgramID,
Accounts: []types.AccountMeta{
{
PubKey: params.LookupTable,
IsSigner: false,
IsWritable: true,
},
{
PubKey: params.Authority,
IsSigner: true,
IsWritable: false,
},
{
PubKey: params.Payer,
IsSigner: true,
IsWritable: true,
},
{
PubKey: common.SystemProgramID,
IsSigner: false,
IsWritable: false,
},
},
Data: bincode.MustSerializeData(struct {
Instruction Instruction
RecentSlot uint64
BumpSeed uint8
}{