Now I'm going to connect solana and React.js. And I tried to get wallet like this.
import { useConnection, useWallet } from '@solana/wallet-adapter-react';
....
function Header(props) {
const wallet = useWallet();
const initialize = async () => {
const provider = await getProvider()
const program = new Program(contractJson, programID, provider);
console.log('program', program)
try {
/* interact with the program via rpc */
await program.rpc.initialize({
accounts: {
myOntology: provider.wallet.publicKey,
user: provider.wallet.publicKey,
systemProgram: SystemProgram.programId,
rent: anchor.web3.SYSVAR_RENT_PUBKEY,
clock: anchor.web3.SYSVAR_CLOCK_PUBKEY,
},
});
} catch (err) {
console.log("Transaction error: ", err);
}
}
}
when I call initialize method, I got this error. TypeError: this.wallet.signTransaction is not a function So I've logged about wallet and signTransaction is null. enter image description here
How can I solve this problem?