Here my code:
const web3 = require('@solana/web3.js');
const connection = new web3.Connection('https://solana-api.projectserum.com');
connection.onAccountChange(
wallet.publicKey,
(updatedAccountInfo, context) => {
let tx = web3.Transaction.from(updatedAccountInfo.data);
console.log('TX: ', tx);
},
'confirmed',
);
When Solana comes to my wallet, or when I send Solana via Solana CLI, the onAccountChange event is triggered, but shows null:
What am I doing wrong and how do I read the transaction data?