トランザクション手数料

すべてのSolanaトランザクションには、SOLで支払うトランザクション手数料が必要です。トランザクション手数料は基本手数料と優先手数料の2つに分かれています。基本手数料はvalidatorがトランザクションを処理するための報酬です。優先手数料はオプションの手数料で、現在のリーダーがあなたのトランザクションを処理する可能性を高めるためのものです。

基本手数料

すべてのトランザクションには、含まれる署名ごとに5000ラムポートのコストがかかります。この手数料はトランザクションの最初の署名者が支払います。System Programが所有するアカウントのみがトランザクション手数料を支払うことができます。基本手数料は以下のように分配されます:

優先手数料

優先手数料 は、現在のリーダー(validator)があなたのトランザクションを処理する可能性を高めるためのオプションの手数料です。validatorは 優先手数料の100%を受け取ります。優先手数料は、トランザクションの コンピュートユニット(CU)価格とCU上限を調整することで設定できます。(優先手数料の詳細については 優先手数料の使用方法ガイド を参照してください。)

優先手数料は次のように計算されます:

優先手数料 = コンピュートユニット上限 × コンピュートユニット価格

優先手数料は、他のトランザクションと比較して トランザクションの優先順位 を決定するために使用されます。これは次の式を使用して計算されます:

トランザクション優先度 = 優先手数料 / トランザクションサイズ(バイト)

コンピュートユニット上限

デフォルトでは、各instructionには 200,000 CUが割り当てられ、各トランザクションには 140万 CUが割り当てられます。これらのデフォルト値は、トランザクションに ComputeBudgetInstruction::set_compute_unit_limit インストラクションを含めることで変更できます。

トランザクションに適切なCU(コンピュートユニット)制限を計算するために、以下の手順をお勧めします:

  1. トランザクションをシミュレーションして必要なCUユニットを見積もる
  2. この見積もりに10%の安全マージンを追加する

優先手数料は、実際に使用されたコンピュートユニット数ではなく、リクエストされたコンピュートユニット制限によって決定されます。制限を高く設定しすぎたり、デフォルト値を使用したりすると、使用されないコンピュートユニットに対しても支払いが発生する可能性があります。

コンピュートユニット価格

コンピュートユニット価格は、リクエストされた各CUに対して支払われるオプションのマイクロラムポートの量です。CU価格は、validatorがあなたのトランザクションを優先するよう促すチップと考えることができます。CU価格を設定するには、トランザクションにComputeBudgetInstruction::set_compute_unit_price命令を含めてください。

デフォルトのCU価格は0であり、つまりデフォルトの優先手数料も0です。

トランザクションに最適なCU価格を決定するには、以下の表に記載されているリアルタイムのCU価格推奨サービスを参照してください。

以下の例は、Solana SDKを使用してトランザクションにCU制限とCU価格を設定する方法を示しています。

SDKソースコード参照
@solana/web3.js (Typescript)ComputeBudgetProgram
solana-sdk (Rust)ComputeBudgetInstruction
const limitInstruction = ComputeBudgetProgram.setComputeUnitLimit({
units: 300_000
});
const priceInstruction = ComputeBudgetProgram.setComputeUnitPrice({
microLamports: 1
});
import {
LAMPORTS_PER_SOL,
SystemProgram,
Transaction,
Keypair,
Connection,
ComputeBudgetProgram,
sendAndConfirmTransaction
} from "@solana/web3.js";
const connection = new Connection("http://localhost:8899", "confirmed");
const sender = Keypair.generate();
const recipient = new Keypair();
const airdropSignature = await connection.requestAirdrop(
sender.publicKey,
LAMPORTS_PER_SOL
);
await connection.confirmTransaction(airdropSignature, "confirmed");
// Create compute budget instructions
const limitInstruction = ComputeBudgetProgram.setComputeUnitLimit({
units: 300_000
});
const priceInstruction = ComputeBudgetProgram.setComputeUnitPrice({
microLamports: 1
});
const transferInstruction = SystemProgram.transfer({
fromPubkey: sender.publicKey,
toPubkey: recipient.publicKey,
lamports: 0.01 * LAMPORTS_PER_SOL
});
// Add the compute budget and transfer instructions to a new transaction
const transaction = new Transaction()
.add(limitInstruction)
.add(priceInstruction)
.add(transferInstruction);
const signature = await sendAndConfirmTransaction(connection, transaction, [
sender
]);
console.log("Transaction Signature:", signature);
Console
Click to execute the code.

Is this page helpful?

目次

ページを編集

管理運営

© 2025 Solana Foundation.
無断転載を禁じます。