I have this test wallet:
% solana account 9AYXoP3b22KHRhVuvjZbynpjNd2SXKFLoC1jrPMkyFkS
Public Key: 9AYXoP3b22KHRhVuvjZbynpjNd2SXKFLoC1jrPMkyFkS
Balance: 12.98943736 SOL
Owner: (removed by me)
Executable: false
Rent Epoch: 248
And I have this javascript snippet:
const SOURCE_TOKEN_ACCOUNT = new PublicKey('9AYXoP3b22KHRhVuvjZbynpjNd2SXKFLoC1jrPMkyFkS');
const sourceInfo = await connection.getParsedAccountInfo(
SOURCE_TOKEN_ACCOUNT,
);
console.log('tok ', sourceInfo);
When I run, I get this output:
tok { context: { slot: 191644 }, value: null }
I would like to note that I'm trying to get this to function with multiple accounts. They all have the same slot value.
I want to know why value would be coming back null.
I have nothing to go on with why this would be happening. I just want some value to show up. Since I don't know what is supposed to show up when this works, I don't know what value is should be, short of showing some sort of SOL. All I know is, I'm getting the following error:
TypeError: Cannot read properties of null (reading 'data')
Accounts in Solana store lamports (SOL) and data, and in this case, your account only has SOL in it, and no data, which is why the value
is coming up as null
. For example, the token program at TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA
will also show the bytes of the data in the account along with the balance:
$ solana account TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA
Public Key: TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA
Balance: 1.08999168 SOL
Owner: BPFLoader2111111111111111111111111111111111
Executable: true
Rent Epoch: 161
Length: 156480 (0x26340) bytes
0000: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 .ELF............
.... rest omitted for length ....
If you want data inside your account, you must allocate data to it, assign it to a program, and use a transaction on the program to modify the data.
I would highly recommend reading up more on how accounts work: https://docs.solana.com/developing/programming-model/accounts