このページの内容
トランザクション
署名前にプロバイダーに接続し、選択中のネットワークを確認してください。直接注入されるプロバイダーと Aptos Wallet Standard アダプターでは引数の型が異なるため、例を混用しないでください。省略されたアドレスを置き換え、読み取り専用の呼び出し用に SDK クライアントを用意してください。
Aptos でトランザクションに署名して送信する方法を説明します。
トランザクションに署名して送信
// Simple APT transfer
const payload = {
type: 'entry_function_payload',
function: '0x1::aptos_account::transfer',
type_arguments: [],
arguments: [
'0x1234...', // Recipient address
'100000000', // Amount in Octas (1 APT = 100000000 Octas)
],
}
const response = await provider.signAndSubmitTransaction(payload)
console.log('Transaction hash:', response.hash)トランザクションに署名 (送信なし)
const payload = {
type: 'entry_function_payload',
function: '0x1::coin::transfer',
type_arguments: ['0x1::aptos_coin::AptosCoin'],
arguments: ['0x1234...', '100000000'],
}
const signedTxn = await provider.signTransaction(payload)
// Submit later using Aptos SDK
// const pendingTxn = await client.submitTransaction(signedTxn)トランザクションに署名 V2 (BCS シリアライズ済み)
BCS シリアライズ済みトランザクションを使用する高度なユースケース向け:
const rawTransaction = '<BCS_SERIALIZED_TRANSACTION>'; // Use the encoding expected by your wallet version
const signedTxn = await provider.signTransactionV2({
transaction: rawTransaction,
transactionType: 'simple', // 'simple' or 'multi_agent'
asFeePayer: false,
})トランザクションのオプション
const payload = {
type: 'entry_function_payload',
function: '0x1::aptos_account::transfer',
type_arguments: [],
arguments: ['0x1234...', '100000000'],
}
// The legacy direct method takes only a payload.
const response = await provider.signAndSubmitTransaction(payload)
// For gas options, use signAndSubmitTransactionV2 with the matching Wallet Standard input.スマートコントラクト操作
View 関数を呼び出す
// View functions don't require signing
const result = await client.view({
function: '0x1::coin::balance',
type_arguments: ['0x1::aptos_coin::AptosCoin'],
arguments: [accountAddress],
})
console.log('Balance:', result[0])Entry 関数を呼び出す
// Mint NFT example
const payload = {
type: 'entry_function_payload',
function: '0x3::token::create_collection_script',
type_arguments: [],
arguments: [
'My Collection', // Collection name
'Description', // Description
'https://example.com', // URI
'1000', // Maximum supply
[false, false, false], // Mutability config
],
}
const response = await provider.signAndSubmitTransaction(payload)マルチエージェントトランザクション
複数の署名者が必要なトランザクション向け:
const signedTxn = await provider.signTransactionV2({
transaction: rawTransaction,
transactionType: 'multi_agent',
})手数料支払者付きトランザクション
スポンサー付きトランザクションの手数料支払者として署名します:
const signedTxn = await provider.signTransactionV2({
transaction: rawTransaction,
transactionType: 'simple',
asFeePayer: true,
})最終更新日