Skip to main content

CurateClick

github.com favicon

Magician-Scanning

Magician-Scanning是一个用Java开发的区块链扫描工具包,支持监控ETH(BSC、POLYGON等)、SOL和TRON链上的交易和合约调用,可自动触发程序方法处理特定交易事件。

Check out Magician-Scanning on CurateClick

• Copy the embed code to showcase this product on your website

• Share on X to spread the word about this amazing tool

Magician-Scanning是一个用Java开发的扫描区块链的工具包,当我们在程序中需要一些功能时,它可以派上用场,比如说。- 当一个地址收到ETH时,程序中的一个方法会被自动触发,这个交易会被传入该方法。- 当一个合约的某个功能被调用时(比如ERC20转账),它会自动触发程序中的一个方法,并将这个交易传递给这个方法。它甚至可以只在代币被转移到指定地址时被触发。- 当程序需要保留一个区块高度开始以来的所有交易记录时,也可以使用这个工具包。它计划支持三种链,ETH(BSC,POLYGON等),SOL和TRONgithub地址: https://github.com/Magician-Blockchain/Magician-Scanning## 示例如果你想监控,某合约内的某函数 被调用的交易javapublic EthMonitorFilter ethMonitorFilter() { return EthMonitorFilter.builder() .setToAddress("0x552115849813d334C58f2757037F68E2963C4c5e") // 合约地址 .setInputDataFilter( // 根据inputData筛选 InputDataFilter.builder() .setFunctionCode("0xadasasdf") // 被调用的函数编码(inputData前十位) );}如果 有一个合约[0x552115849813d334C58f2757037F68E2963C4c5e], 里面有一个函数是 transferFrom(address from, address to, uint256 amount)你想 实现一个监控:如果有人用这个合约里的这个函数,将代币转给[0x552115849813d334C58f2757037F68E2963C4c5e]时,就触发 Monitor事件,那么你可以这样写javapublic EthMonitorFilter ethMonitorFilter() { return EthMonitorFilter.builder() .setToAddress("0x552115849813d334C58f2757037F68E2963C4c5e") // 合约地址 .setInputDataFilter( // 根据inputData筛选 InputDataFilter.builder() .setFunctionCode(ERC20.TRANSFER_FROM.getFunctionCode()) // 被调用的函数编码(inputData前十位) .setTypeReferences( // 此方法的参数列表(仅类型) new TypeReference<Address>(){}, // 第一个参数的类型 new TypeReference<Address>(){}, // 第二个参数的类型 new TypeReference<Uint256>(){} // 第三个参数的类型 ) .setValue(null, "0x552115849813d334C58f2757037F68E2963C4c5e", null)// 筛选第二个参数(to) = 0x552115849813d334C58f2757037F68E2963C4c5e );}全部的过滤条件,你可以根据自己的需求 自由设置java/** * 创建一个类,实现 EthMonitorEvent接口 即可 */public class EventDemo implements EthMonitorEvent { /** * 筛选条件,如果遇到了符合条件的交易,会自动触发 call方法 * 这些条件都是 并且的关系,必须要同时满足才行 * 如果不想根据某个条件筛选,直接不给那个条件设置值就好了 * 这个方法如果不实现,或者返回null, 那么就代表监听任意交易 */ @Override public EthMonitorFilter ethMonitorFilter() { return EthMonitorFilter.builder() .setFromAddress("0x131231249813d334C58f2757037F68E2963C4crc") // 筛选 fromAddress 发送的交易 .setToAddress("0x552115849813d334C58f2757037F68E2963C4c5e") // 筛选 toAddress 或 合约地址 收到的交易 .setMinValue(BigInteger.valueOf(1)) // 筛选发送的主链币数量 >= minValue 的交易 .setMaxValue(BigInteger.valueOf(10)) // 筛选发送的主链币数量 <= maxValue 的交易 .setInputDataFilter( // 根据inputData筛选 InputDataFilter.builder() .setFunctionCode(ERC20.TRANSFER.getFunctionCode()) // 函数签名(被调用的合约内的某方法), 支持任意函数,这里的枚举只是一部分标准的合约函数 .setTypeReferences( // 此方法的参数列表(仅类型) new TypeReference<Address>(){}, new TypeReference<Uint256>(){} ) .setValue("0x552115849813d334C58f2757037F68E2963C4c5e", null)// 筛选第几个参数 = 什么值 ); } /** * 如果遇到了符合上面条件的交易,就会触发这个方法 * transactionModel.getEthTransactionModel() 是一个交易对象,内部包含hash,value,from,to 等 所有的数据 */ @Override public void call(TransactionModel transactionModel) { String template = "EventOne 扫描到了, hash:{0}, from:{1}, to: {2}, input: {3}"; template = template.replace("{0}", transactionModel.getEthTransactionModel().getBlockHash()); template = template.replace("{1}", transactionModel.getEthTransactionModel().getFrom()); template = template.replace("{2}", transactionModel.getEthTransactionModel().getTo()); template = template.replace("{3}", transactionModel.getEthTransactionModel().getInput()); System.out.println(template); }}

Latest Weekly Picks

Predict video virality before you publish.

Virality Predictor

Powerful Motion Control AI Video Generator

Motion Control AI

PlusGO 是面向中国大陆用户的 ChatGPT Plus 代充值服务平台。使用官方 CDKey,支持支付宝和微信扫码支付,平均 2 分钟完成 Plus 开通,自 2025 年起已为超过 10,000 名用户完成充值。

www.toolcenter.ai favicon
Weekly Pick

Discover the Best AI & Productivity Tools — 1,500+ tools with honest reviews.

ToolCenter
huntereyes.net favicon
Weekly Pick

AI Eye Area Evaluation

Hunter Eyes
www.payforchat.com favicon
Weekly Pick

Subscribe to ChatGPT Plus/Pro in 1 minute — no international credit card needed.

PayForChat
happyhorseai.ai favicon
Weekly Pick

Happy Horse AI Creates Videos with Motion and Storytelling

Happy Horse
promptbuilder.cc favicon
Weekly Pick

Generate, optimize, test, and manage AI prompts in one place. Turn an idea into a ready-to-use prompt in seconds.

Prompt Builder