-
Notifications
You must be signed in to change notification settings - Fork 94
Description
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 ()
at Transaction.compileMessage (transaction.ts:270)
at Transaction._compile (transaction.ts:376)
at Transaction.serializeMessage (transaction.ts:402)
at Wallet.signTransaction (index.js:184)
at sendTransaction (wallet.js:33)
`
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);
}
}
`