9
votes
Accepted
How to parse event in transaction log with Anchor
After some digging to Anchor documentation I found the EventParser which is exactly what I wanted.
import * as anchor from "@project-serum/anchor";
import {BorshCoder, EventParser, Program, ...
5
votes
What is the Solana idiomatic way of logging/accessing information about who sent tokens via a program?
A way to do this would be to create a separate account for each wallet that contributes. That account would be a PDA to prevent duplicity, and would store contribution details such as the amount ...
4
votes
Relating logs to their instructions
Instructions in a transaction are processed in order. So the order you add the instruction to the transaction is the order the of the program logs. You can also use msg!("Some Message") to ...
4
votes
How to log into terminal in anchor program
If you're using Anchor then you can start the test suite with the detach option anchor test --detach to keep the local validator running after the tests pass/fail. This is useful if you want to look ...
3
votes
Accepted
get transactions/logs from different program, on a span of blocks
You're doing the right thing for your situation -- fetching the whole block and iterating through it is perfectly valid.
Your other question seems to be about actually iterating through the ...
3
votes
Accepted
How to view logs on anchor rust client
If you boot the local validator yourself in another terminal using solana-test-validator, then in another terminal subscribe to the logs using solana logs -ul, then you can run anchor test --skip-...
3
votes
Accepted
Where do InstructionErrors go?
Ok I found what I was doing wrong. I wasn't handling caught errors correctly on client side. I had to change this from
the wrong way
...
} catch {
console.log(Error)
}
to the right way
...
} ...
2
votes
Am I able to search for specific transactions based what's in the program instruction logs?
All Geyser plugin does is it streams current account updates and transactions. Unless you need listen to many programs, you can do the same with RPC by using subscribe to websocket API.
To subscribe ...
2
votes
Cost of logging vs storing data in Solana programs?
As you correctly stated, you can store data onchain either as part of logs or in smart contracts. As with all things for SVM vs EVM, there's a few small differences though:
Logs vs Events: On EVM, ...
2
votes
How to log into terminal in anchor program
To add to the answer, which is correct, you can use the solana logs to get live logging from your local validator ie:
$ solana logs -ul TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA
Streaming ...
2
votes
Accepted
How to get all transaction logs for a specific program? Both old and new transactions
How do I monitor a program and get inflight transaction logs?
The absolute best way is hooking up a geyser plugin and filtering based on your program.
A less infra-heavy way would be to use the RPC ...
2
votes
How can i parse program data in program event
There's a proposal about event logging: Program log binary data
The program data is a base64-encoded string.
It starts with an 8-byte event discriminator followed by each field data, similar to ...
1
vote
need a better way to analyse tests working for transactions that exceed timeout
Im guessing whats happening here is that you have global
let context; and let provider: BankrunProvider;
And since jest tests can also run in parallel the provider gets killed during the tests or ...
1
vote
Decode OnLogs Data
Unfortunately, what you're trying to achieve is not possible using the logsSubscribe RPC method. This method only streams the signature and the logs of the transactions.
The transfer amount is ...
1
vote
Accepted
Filtering Instruction Data for Revoke Authority Events in Solana Blockchain using logsSubscribe
The logsSubscribe endpoint will only tell you when the SetAuthority instruction is called, but won't give any other information unfortunately.
Here's the only log from it: https://github.com/solana-...
1
vote
Can anyone tell me how to get logs of "confirm" transaction not the finalized?
You've almost got it, but you need to specify "commitment": "confirmed" in the configuration object, ie:
curl https://api.devnet.solana.com -X POST -H "Content-Type: ...
1
vote
Accepted
How can I make `msg!` print to stdout when run off-chain?
Depending on what you mean by "off-chain", ie. in a test or an application, you can set your own override for the syscall at the start of the program. Start by defining a type that ...
1
vote
How to log into terminal in anchor program
your Anchor msg!() logs and Solana program logs will be saved inside your project in a file:
[in 2023]: .anchor/validator-1700296750844.log
[2024 Anchor 0.30.1] .anchor/program-logs/YOUR_PROGRAM_ID....
1
vote
Sometimes receiving duplicate logs using solana_client::nonblocking::pubsub_client::PubsubClient
The WebSocket indeed seems to be extremely buggy. I sometimes don't even receive notifications, and then sometimes I get duplicates too.
Could you check if the subscription ID is the same for both?
1
vote
Relating logs to their instructions
When a program emits logs inside of a transaction, each log is effectively just added to a single, flat array of strings. So in order to actually determine the instruction that caused a program to ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
logs × 23anchor × 4
solana-program × 4
rust × 3
web3.js × 3
websocket × 3
transactions × 2
program × 2
spl × 2
instructions × 2
spl-token × 1
rpc × 1
token × 1
anchor-client × 1
anchor-test × 1
mint × 1
error × 1
typescript × 1
rent × 1
jsonrpc-api × 1
data × 1
geyser × 1
decode × 1
invoke × 1
api × 1