oyster icon indicating copy to clipboard operation
oyster copied to clipboard

TypeError: Cannot read property '_disableBlockhashCaching' of undefined

Open ZEAL-MATCH-LTD opened this issue 3 years ago • 0 comments

I am trying to implement a transaction.


const { publicKey } = useWallet();
const seller_public_key = new PublicKey('DJ5RuoXViJWiLHBrSkH74D9LbTf6iardcnEeQHqCPjKx');

const onClick = React.useCallback(async (_publicKey: PublicKey, _secretKey: Uint8Array) => {
    if (!_publicKey || !_secretKey.length) throw new WalletNotConnectedError();

    const keypair =  Keypair.generate();
    const address = keypair?.publicKey.toString();
    const secret = JSON.stringify(Array.from(keypair?.secretKey));

    const transaction = new Transaction().add(
        SystemProgram.transfer({
          fromPubkey: seller_public_key,
          toPubkey: _publicKey,
          lamports: 1,
        })
    );

    console.log('[transaction]', transaction);

    const signature = await sendTransaction(
      transaction,
      [{
        publicKey: seller_public_key,
        secretKey: Uint8Array.from(JSON.parse(secret as string)),
      }],
    );

    console.log('[signature]', signature);

    await confirmTransaction(signature, 'processed');
  }, [publicKey, sendTransaction]);


{userAccounts?.map((account) => {
              return (
                <div key={account.pubkey} style={{ border: '2px solid tomato', margin: '1rem'}}>
                  <h2>{account.pubkey}</h2>
                  <h3>{account.account.lamports}</h3>
                  <button onClick={() => onClick(account.account.owner, account.account.data)} disabled={!account.account.owner} style={{ color: 'black' }}>
                    Send 1 lamport to a random address!
                  </button>
                </div>
              );
            })}

The transaction goes through but when i go to sendTransaction i get the titled error.

ZEAL-MATCH-LTD avatar Sep 05 '21 13:09 ZEAL-MATCH-LTD