sol-wallet-adapter
sol-wallet-adapter copied to clipboard
TypeError: Cannot read property toString of undefined while trying to signTransaction
I'm running the code below with some logs and at the point of running wallet.signTransaction it fails with the error given in the title. The entire error below. The code to get connections and setup and connect the wallet all work. As does the setup of the Transaction itself.
I am running: devnet solana: 1.6.6 sol-wallet-adapter: 0.2.0 web3.js: 1.9.1
react_devtools_backend.js:2557 Failed TypeError: Cannot read property 'toString' of undefined
at transaction.ts:271
at Array.forEach (
` import Wallet from "@project-serum/sol-wallet-adapter"; import { Connection, SystemProgram, Transaction, clusterApiUrl, sendAndConfirmTransaction, } from "@solana/web3.js";
const network = clusterApiUrl("devnet"); const connection = new Connection("https://devnet.solana.com", "confirmed"); const wallet = new Wallet("https://www.sollet.io", network);
export async function sendTransaction() { try { await wallet.connect(); console.log("network", network); console.log("connection", connection); console.log("wallet", wallet);
let transaction = new Transaction().add(
SystemProgram.transfer({
fromPubkey: wallet.publickey,
toPubkey: wallet.publicKey,
lamports: 100,
})
);
transaction.recentBlockhash = (
await connection.getRecentBlockhash()
).blockhash;
transaction.feePayer = wallet.publicKey;
console.log("finished setting up transaction");
let signed = await wallet.signTransaction(transaction);
console.log("signed transaction");
let signature = await connection.sendRawTransaction(signed.serialize());
console.log("sent raw transaction");
await connection.confirmTransaction(signature, "singleGossip");
console.log("transaction attempt confirm");
} catch (e) { console.warn("Failed", e); } } `
hi @jsoneaday did you find out how to fix it? thanks
any solution to this ?