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

make.ink favicon
Weekly Pick

Your AI tattoo generator for pro-grade concepts

Leo Wade
sellfy.com favicon
Weekly Pick

A code-free online store builder to turn views into revenue. Sell digital products, subscriptions, and merch, without fees or hassle.

Maris
www.videotoblog.ai favicon
Weekly Pick

Convert videos into awesome blog posts.

Video To Blog
www.sellerpic.ai favicon
Weekly Pick

SellerPic is the all-in-one AI design platform for e-commerce

SellerPic
fastimage.ai favicon
Weekly Pick

Fast Image AI instantly transforms your photos into stunning styles like Ghibli, Sketch, and Pixar. Effortlessly control image elements and create amazing effects with just one click.

Fast AI Team
linkedinpro.daisy.so favicon
Weekly Pick

AI-powered tool that transforms casual photos into professional LinkedIn headshots instantly. No photographer needed—just upload and download.

Gabriel
crevas.ai favicon
Weekly Pick

Crevas unifies Veo 3, Sora 2, Nano Banana and more into one intuitive canvas — so filmmakers can script, prompt, and generate cinematic stories without switching tools or losing consistency.

Spark Alpha
fotominiatur.com favicon
Weekly Pick

AI Foto Edit - Text to Image & Image Edit

foto miniatur