Documentation Index
Fetch the complete documentation index at: https://docs.magicblock.gg/llms.txt
Use this file to discover all available pages before exploring further.
快速访问
Magic Actions Example
在 GitHub 上查看参考实现
设置 Router 连接
使用 Magic Router 将交易路由并发送到 ER 和基础层。
import { Connection } from "@magicblock-labs/ephemeral-rollups-kit";
// Initialize connection
const connection = await Connection.create(
"https://devnet-router.magicblock.app",
"wss://devnet-router.magicblock.app"
);
// ... create transaction
// Send and confirm transaction
const txHash = await connection.sendAndConfirmTransaction(
transactionMessage,
[userKeypair],
{ commitment: "confirmed", skipPreflight: true }
);
交易流程
- 将计数器委托给 ER
const delegateTx = await program.methods
.delegate()
.accounts({
payer: anchor.Wallet.local().publicKey,
pda: pda,
})
.transaction();
- 在 ER 上实时递增计数器
const incrementTx = await program.methods
.increment()
.accounts({
counter: pda,
})
.transaction();
- 使用 Magic Action 提交
const commitTx = await program.methods
.commitAndUpdateLeaderboard()
.accounts({ payer: wallet.publicKey /* your accounts */ })
.transaction();
Quickstart Ephemeral Rollups
ER 使用端到端演练