Ephemeral Signers
// Generate a random seed.
const seed = Keypair.generate().publicKey.toBase58().slice(0, 32);
// Calculate a publicKey that will be controlled by the walletPubkey.
const auxAccountPubkey = await PublicKey.createWithSeed(
walletPubkey,
seed,
TOKEN_PROGRAM_ID
);
// Create token account.
// Using `createAccountWithSeed` allows us to avoid the second signer,
// because this instruction requires signing only from `basePubkey`.
const createAccountIx = SystemProgram.createAccountWithSeed({
fromPubkey: walletPubkey,
basePubkey: walletPubkey,
seed,
newAccountPubkey: auxAccountPubkey,
lamports: (await getMinimumBalanceForRentExemptAccount(connection)) + amount,
space: ACCOUNT_SIZE,
programId: TOKEN_PROGRAM_ID,
});// Some codeLast updated