developers-evm-to-svm-eip2612.hero.eyebrow

developers-evm-to-svm-eip2612.hero.headline

developers-evm-to-svm-eip2612.contentEditor.intro

developers-evm-to-svm-eip2612.contentEditor.keyCharacteristics.title

  • developers-evm-to-svm-eip2612.contentEditor.keyCharacteristics.items.0.label: developers-evm-to-svm-eip2612.contentEditor.keyCharacteristics.items.0.description
  • developers-evm-to-svm-eip2612.contentEditor.keyCharacteristics.items.1.label: developers-evm-to-svm-eip2612.contentEditor.keyCharacteristics.items.1.description
  • developers-evm-to-svm-eip2612.contentEditor.keyCharacteristics.items.2.label: developers-evm-to-svm-eip2612.contentEditor.keyCharacteristics.items.2.description

developers-evm-to-svm-eip2612.contentEditor.whyUnnecessary.title

developers-evm-to-svm-eip2612.contentEditor.whyUnnecessary.body

developers-evm-to-svm-eip2612.contentEditor.tokenApprovalModel.title

developers-evm-to-svm-eip2612.contentEditor.tokenApprovalModel.body

developers-evm-to-svm-eip2612.contentEditor.feePayerModel.title

developers-evm-to-svm-eip2612.contentEditor.feePayerModel.body

developers-evm-to-svm-eip2612.contentEditor.howTo.title

developers-evm-to-svm-eip2612.contentEditor.howTo.body

developers-evm-to-svm-eip2612.contentEditor.exampleOne.title

developers-evm-to-svm-eip2612.contentEditor.exampleOne.body

javascript
import { Connection, Keypair, PublicKey, Transaction } from "@solana/web3.js";
import {
  createApproveInstruction,
  createTransferInstruction,
  getAssociatedTokenAddressSync
} from "@solana/spl-token";

const connection = new Connection("https://api.devnet.solana.com");
const owner = Keypair.generate();
const delegate = owner.publicKey;
const recipient = new PublicKey("DESTINATION_WALLET");
const mint = new PublicKey("TOKEN_MINT");
const amount = 1_000_000;

const ownerATA = getAssociatedTokenAddressSync(mint, owner.publicKey);
const recipientATA = getAssociatedTokenAddressSync(mint, recipient);

const ixApprove = createApproveInstruction(ownerATA, delegate, owner.publicKey, amount);
const ixTransfer = createTransferInstruction(ownerATA, recipientATA, owner.publicKey, amount);

const tx = new Transaction().add(ixApprove, ixTransfer);
tx.feePayer = owner.publicKey;
tx.recentBlockhash = (await connection.getLatestBlockhash()).blockhash;

tx.sign(owner);
const sig = await connection.sendRawTransaction(tx.serialize());
console.log("Sent (self-sponsored):", sig);

developers-evm-to-svm-eip2612.contentEditor.exampleTwo.title

developers-evm-to-svm-eip2612.contentEditor.exampleTwo.body

javascript
import { Connection, Keypair, PublicKey, Transaction } from "@solana/web3.js";
import { createTransferInstruction, getAssociatedTokenAddressSync } from "@solana/spl-token";

const connection = new Connection("https://api.devnet.solana.com");
const owner     = Keypair.generate();          // replace with real keypair
const feePayer  = Keypair.generate();          // replace with real keypair
const recipient = new PublicKey("DESTINATION_WALLET");
const mint      = new PublicKey("TOKEN_MINT");
const amount    = 500_000;

const ownerATA     = getAssociatedTokenAddressSync(mint, owner.publicKey);
const recipientATA = getAssociatedTokenAddressSync(mint, recipient);

const ix = createTransferInstruction(ownerATA, recipientATA, owner.publicKey, amount);

const tx = new Transaction().add(ix);
tx.feePayer        = feePayer.publicKey;
tx.recentBlockhash = (await connection.getLatestBlockhash()).blockhash;

tx.partialSign(owner);
tx.sign(feePayer);

const sig = await connection.sendRawTransaction(tx.serialize());
console.log("Sent (relayer-sponsored):", sig);
developers-evm-to-svm-eip2612.navHeading.eyebrow

developers-evm-to-svm-eip2612.resourceHeading.headline

Quản lý bởi

© 2026 Solana Foundation.
Đã đăng ký bản quyền.
Kết nối