Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Cannot read property toString of undefined while trying to signTransaction #30

Open
jsoneaday opened this issue May 6, 2021 · 2 comments

Comments

@jsoneaday
Copy link

jsoneaday commented May 6, 2021

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);
}
}
`

@ctoSolaland
Copy link

hi @jsoneaday did you find out how to fix it? thanks

@Abdulkereem
Copy link

any solution to this ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants