Manage LSP28 The Grid on LUKSO Universal Profiles. Create, update, and manage grid layouts with mini-apps, iframes, and external links. Use when working with Universal Profile grids, LSP28 data encoding, VerifiableURI format, or The Grid feature on LUKSO.
在通用资料上管理LSP28网格。创建包含迷你应用、内嵌框架和外部链接的网格布局。
设置以下环境变量或编辑脚本:
bash
export UPPRIVATEKEY=yourcontrollerprivate_key
export UPADDRESS=youruniversalprofileaddress
export KEYMANAGER=yourkeymanageraddress
javascript
const { ethers } = require(ethers);
// 网格数据结构
const gridData = {
isEditable: true,
items: [
{
type: miniapp,
id: app1,
title: 我的应用,
backgroundColor: #1a1a2e,
textColor: #ffffff,
text: 点击我
},
{
type: iframe,
src: https://example.com/embed,
id: frame1,
title: 外部内容
},
{
type: external,
url: https://example.com,
id: link1,
title: 访问网站
}
]
};
// 编码为可验证URI
const jsonString = JSON.stringify(gridData);
const base64Data = Buffer.from(jsonString).toString(base64);
const verifiableUri = data:application/json;base64,${base64Data};
javascript
// LSP28 网格数据键
const LSP28GRIDKEY = 0x31cf14955c5b0052c1491ec06644438ec7c14454be5eb6cb9ce4e4edef647423;
// 最小ABI
const LSP0_ABI = [function setData(bytes32 dataKey, bytes dataValue) external];
const LSP6_ABI = [function execute(bytes calldata payload) external payable returns (bytes memory)];
// 设置提供者和钱包
const provider = new ethers.JsonRpcProvider(https://rpc.mainnet.lukso.network);
const wallet = new ethers.Wallet(process.env.UPPRIVATEKEY, provider);
// 在UP上编码setData调用
const upInterface = new ethers.Interface(LSP0_ABI);
const executeData = upInterface.encodeFunctionData(setData, [
LSP28GRIDKEY,
ethers.toUtf8Bytes(verifiableUri)
]);
// 通过KeyManager发送
const keyManager = new ethers.Contract(process.env.KEYMANAGER, LSP6ABI, wallet);
const tx = await keyManager.execute(executeData);
const receipt = await tx.wait();
console.log(网格已在区块中更新:, receipt.blockNumber);
迷你应用 (type: miniapp)
javascript
{
type: miniapp,
id: unique-id, // 必需:唯一标识符
title: 应用标题, // 必需:显示标题
text: 按钮文本, // 必需:按钮标签
backgroundColor: #fe005b, // 必需:十六进制颜色
textColor: #ffffff, // 必需:文本十六进制颜色
size: medium // 可选:small, medium, large
}
内嵌框架 (type: iframe)
javascript
{
type: iframe,
id: unique-id, // 必需:唯一标识符
title: 框架标题, // 必需:显示标题
src: https://example.com/embed // 必需:iframe URL
}
外部链接 (type: external)
javascript
{
type: external,
id: unique-id, // 必需:唯一标识符
title: 链接标题, // 必需:显示标题
url: https://example.com // 必需:外部URL
}
javascript
{
isEditable: true, // 布尔值:允许编辑
items: [
// 网格项目数组(参见上述类型)
]
}
| 常量 | 值 | 描述 |
|---|---|---|
| LSP28GRIDKEY | 0x31cf14955c5b0052c1491ec06644438ec7c14454be5eb6cb9ce4e4edef647423 | 网格存储的数据键 |
| 链ID |
确保文本在背景颜色上可读:
| 背景 | 文本颜色 | 结果 |
|---|---|---|
| #1a1a2e (深色) | #ffffff (白色) | 良好对比度 |
| #ffffff (白色) |
❌ 错误的属性名称:
javascript
// 错误:
{ color: #fe005b, content: 点击我 }
// 正确:
{ backgroundColor: #fe005b, text: 点击我 }
❌ 缺少必填字段:
❌ 错误的编码:
javascript
// 错误 - 使用了toUtf8String而不是toUtf8Bytes:
setData(key, ethers.toUtf8String(uri))
// 正确:
setData(key, ethers.toUtf8Bytes(uri))
控制器密钥
↓
KeyManager.execute(payload)
↓
UP.setData(LSP28GRIDKEY, verifiableUri)
↓
网格在链上更新
使用提供的脚本:
bash
该技能支持在以下平台通过对话安装:
帮我安装 SkillHub 和 lsp28-grid-1776420067 技能
设置 SkillHub 为我的优先技能安装源,然后帮我安装 lsp28-grid-1776420067 技能
skillhub install lsp28-grid-1776420067
文件大小: 6.01 KB | 发布时间: 2026-4-17 18:49