Monitor anchor programs
You can also monitor Solana contracts built by Anchor in Sentio.
Here we use the Aurory example to demonstrate how to do this. Assuming we want to monitor its staking contract. We'd need to first copy the idl/abi json file generated by Anchor and put it into your directory abi/solana
Then run the following command to generate a type-safe processor.
yarn sentio build
You can find the generated processors under src/types
Then import the processor from types, with proper contract address bound. As what we have for evm, you can register instruction handlers into the processor, with auto-complete support in modern IDEs.
StepStakingProcessor.bind({ address: 'StKLLTf7CQ9n5BgXPSDXENovLTCuNc7N2ehvTb6JZ5x' })
.onStake((args, ctx) => {
const amount = args.amount.toNumber()
ctx.meter.Counter('total_token').add(amount)
})
.onUnstake((args, ctx) => {
const amount = args.amount.toNumber()
ctx.meter.Counter('total_token').sub(amount)
})
You could see the metrics are submitted using ctx.meter.Counter
See this repo for full implementation. To learn how to view metrics from the UI, go to view-metrics
Updated 2 days ago