sendAndConfirmTransaction does not exist for typ connection
sendAndConfirmTransaction does not exist for typ connection
Loading saved threads...
JackSparrow · External communityPost link
External question — Solana Stack Exchange
Author: JackSparrow
Original post: https://solana.stackexchange.com/questions/12380
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
How can I solve this? as far as I have seen, it has the typ connection..
export async function createMint(
wallet: WalletAdapter,
mintAuthority: Keypair,
decimals: number
) {
if (!wallet.connected) {
throw new Error('Wallet is not connected');
}
const mint = Keypair.generate();
const instructions: TransactionInstruction[] = [];
instructions.push(
TokenInstructions.initializeMint({
mint: mint.publicKey,
decimals: decimals,
mintAuthority: mintAuthority.publicKey,
})
);
if (!mintAuthority.secretKey || mintAuthority.secretKey.length === 0) {
throw new Error('mintAuthority does not contain a private key');
}
const connection = new Connection('https://devnet.helius-rpc.com/?api-key=5d69c879-36f4-4acf-87b4-e44a64c07acc');
const transaction = new Transaction().add(...instructions);
transaction.feePayer = wallet.publicKey;
transaction.recentBlockhash = (await connection.getLatestBlockhash()).blockhash;
// Sign the transaction with the payer
transaction.sign(mintAuthority);
// Serialize and send the transaction
try{
const signature = await connection.sendAndConfirmTransaction(transaction,[mintAuthority]); // sendAndConfirmTransaction does not exist for typ connection
return {
mint,
transaction: signature,
};
} catch (error) {
console.error('Transaction error', error);
throw error;
}
} ```
Quote
Report
Jon C · External communityPost link
External answer — Solana Stack Exchange
Author: Jon C
Original post: https://solana.stackexchange.com/a/12469
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
sendAndConfirmTransaction
is a helper function in the web3.js library, and you can see its implementation at
https://github.com/solana-labs/solana-web3.js/blob/5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be/packages/library-legacy/src/utils/send-and-confirm-transaction.ts#L18
Be sure to import it properly using something like:
import { sendAndConfirmTransaction } from '@solana/web3.js';
Quote
Report
Edinaldo Junior · External communityPost link
External answer — Solana Stack Exchange
Author: Edinaldo Junior
Original post: https://solana.stackexchange.com/a/16264
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
Instead of calling
connection.sendAndConfirmTransaction
, you can use the
sendAndConfirmTransaction
function imported from
@solana/web3.js
.
Quote
Report
Post Reply
Quoted from Forex.com.bd-Editorial External answer — Solana Stack Exchange Author: Edinaldo Junior Source score (net votes, not local likes): 0 Original post: https://solana.stackexchange.com/a/16264 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. Instead of calling connection.sendAndConfirmTransaction , you can use the sendAndConfirmTransaction function imported from @solana/web3.js .
Checking account access…