聪明钱监控
聪明钱跟单指监听链上胜率高的地址后跟随买入和卖出,本文提供了一个简单的demo,教你如何监控聪明钱地址。主要内容包括:① 基于geyser grpc监听聪明钱包地址与pump和raydium交互的交易;② 解析交易中的余额变动
用到的库
import "dotenv/config";
import Client, {CommitmentLevel, SubscribeRequest} from '@triton-one/yellowstone-grpc';
import bs58 from "bs58";
import {Connection, PublicKey, LAMPORTS_PER_SOL} from "@solana/web3.js";
import{ Metadata, deprecated } from "@metaplex-foundation/mpl-token-metadata";监听包含聪明钱账户的交易
const addr = ['orcACRJYTFjTeo2pV8TfYRTpmqfoYgbVi9GeANXTCc8'] // 聪明钱地址
const client = new Client('https://grpc.chainbuff.com', undefined, {
"grpc.max_receive_message_length": 64 * 1024 * 1024, // 64MiB
});
const stream = await client.subscribe();
const streamClosed = new Promise<void>((resolve, reject) => {
stream.on("error", (error) => {
reject(error);
stream.end();
});
stream.on("end", () => {
resolve();
});
stream.on("close", () => {
resolve();
});
});
stream.on("data", async (data) => {
if (data.transaction) {
const accountKeys = data.transaction.transaction.transaction.message.accountKeys.map(ak => bs58.encode(ak));
if (accountKeys.includes('6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P') || accountKeys.includes('675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8')) {
// 解析余额变动
checkBalances(data)
}
}
});
// 配置订阅
const request = {
accounts: {},
slots: {},
transactions: {},
blocks: {},
blocksMeta: {},
entry: {},
commitment: CommitmentLevel.CONFIRMED,
accountsDataSlice: [],
ping: undefined,
};
request.transactions.tx = {
vote: false,
failed: false,
signature: undefined,
accountInclude: addr,
accountExclude: [],
accountRequired: [],
};
await new Promise<void>((resolve, reject) => {
stream.write(request, (err) => {
if (err === null || err === undefined) {
resolve();
} else {
reject(err);
}
});
}).catch((reason) => {
console.error(reason);
throw reason;
});
await streamClosed;解析余额变动



最后更新于