Skip to content

Commit

Permalink
update example-02-subNewPool
Browse files Browse the repository at this point in the history
  • Loading branch information
XingqiWang committed Nov 16, 2024
1 parent 579abdb commit 5088258
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
10 changes: 10 additions & 0 deletions example-02-subNewPool/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# 监听raydium新流动池创建

此例子使用 `onLogs` 方法来订阅和过滤raydium v4地址 `675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8` 的新流动池创建。

通过 `npx esrun example-02-subNewPool/index.ts`运行。

```
新流动池被创建: https://solscan.io/tx/28XF272z2ipWMfQ2dtdJgRFiSuJojCaxKknXRyekbzKd1ygtrjciikTjcvTCDeHzTJfe9hPvnkDQuMztaRWRdbGa
新流动池被创建: https://solscan.io/tx/4pMQnmpnoGcaSmH1apS91Gknj94vedDkdfaAQKMeaq3GqU6WFq5o5uySRTCTCQcaQqpL9F5Cjw3ncrtnqEdMHa4x
```
20 changes: 20 additions & 0 deletions example-02-subNewPool/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import {
Connection,
PublicKey
} from '@solana/web3.js';

const connection = new Connection("https://api.mainnet-beta.solana.com", "confirmed");
// const connection = new Connection("https://mainnet-ams.chainbuff.com", "confirmed");
const raydiumV4PublicKey = new PublicKey('675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8');

connection.onLogs(
raydiumV4PublicKey,
({ logs, err, signature }) => {
if (err) return;

if (logs && logs.some(log => log.includes("initialize2"))) {
console.log(`新流动池被创建: https://solscan.io/tx/${signature}`);
}
},
"confirmed"
);

0 comments on commit 5088258

Please sign in to comment.