Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions apps/example-app/src/solder/indexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const INDEXER_CONFIG: Partial<IndexerConfig> = {
databaseUrl:
process.env.DATABASE_URL, // 🔧 MODIFY: Use your actual database URL
cursorKey: "my-indexer", // 🔧 MODIFY: Use a unique identifier for your indexer
enableUIProgress: true, // 🔧 MODIFY: Set to false to disable progress UI
enableUIProgress: false, // 🔧 MODIFY: Set to false to disable progress UI
};

/**
Expand Down Expand Up @@ -101,18 +101,32 @@ export const initializeIndexer = async () => {
) => {
// 🔧 MODIFY: Replace this database insertion with your custom logic
await db.insert(tradesTable).values({ // 🔧 MODIFY: Replace tradesTable with your table
mint: event.parsed.mint.toBase58(),
mint: event.parsed.mint,
solAmount: event.parsed.sol_amount.toString(),
tokenAmount: event.parsed.token_amount.toString(),
isBuy: event.parsed.is_buy,
user: event.parsed.user.toBase58(),
user: event.parsed.user,
virtualSolReserves: event.parsed.virtual_sol_reserves.toString(),
virtualTokenReserves: event.parsed.virtual_token_reserves.toString(),
timestamp: new Date(Number(event.parsed.timestamp) * 1000),
});
},
});

await indexer.onTransactions({
filterByProgramIds: ["TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"],
filterByInstructions: ["transferChecked"],
handler: async (transaction) => {
console.log(
"Transaction parsed:",
JSON.stringify(transaction, (key, value) =>
typeof value === "bigint" ? value.toString() : value,
2)
);
},
});


/// start the indexer
await indexer.start();

Expand Down
17 changes: 14 additions & 3 deletions packages/core/src/examples/simple-indexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,31 @@ async function main() {
console.log("🚀 Starting Solder Indexer Example");

const indexer = new Indexer({
startBlock: 300000000,
rpcUrl: "https://solder-solanam-6597.mainnet.rpcpool.com/3b46c479-63d2-4713-8555-49171bd416eb",
startBlock: 379635639,
rpcUrl: "https://api.mainnet-beta.solana.com",
databaseUrl: "postgresql://postgres:password123@127.0.0.1:6500/app",
cursorKey: "my-indexer",
});

console.log("📝 Registering event handlers...");

await indexer.onEvent({
programId: "6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P",
idl: PUMP_FUN_IDL as unknown as Idl,
eventName: "TradeEvent",
handler: async (event) => {
console.log("Event parsed:", event);
}
});

await indexer.onTransactions({
handler: async (transaction) => {
console.log(
"Transaction parsed:",
JSON.stringify(transaction, (key, value) =>
typeof value === "bigint" ? value.toString() : value,
2)
);
},
});

Expand Down
3 changes: 3 additions & 0 deletions packages/core/src/indexer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ export {
type ExtractEventNames,
type ExtractEventData,
type IndexerEvent,
type IndexerTransaction,
type TransactionHandler,
type OnTransactionConfig,
} from "./indexer";
Loading