Magician-web3,開發(fā)語言是 java ,底層依賴了 Web3J , 廢話不多說,直接上示例文章來源:http://www.zghlxwxcb.cn/news/detail-600511.html
引入依賴
<dependency>
<groupId>com.github.yuyenews</groupId>
<artifactId>Magician-web3</artifactId>
<version>1.0.0</version>
</dependency>
<!-- This is the logging package, you must have it or the console will not see anything, any logging package that can bridge with slf4j is supported -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<version>1.7.12</version>
</dependency>
復(fù)制代碼
創(chuàng)建監(jiān)聽器
監(jiān)聽器 可以創(chuàng)建多個(gè),根據(jù)你的需求 分別設(shè)置監(jiān)聽條件文章來源地址http://www.zghlxwxcb.cn/news/detail-600511.html
/**
* 創(chuàng)建一個(gè)類,實(shí)現(xiàn) EthMonitorEvent 接口 即可
*/
public class EventDemo implements EthMonitorEvent {
/**
* 篩選條件,如果遇到了符合條件的交易,會(huì)自動(dòng)觸發(fā) call 方法
* 這些條件都是 并且的關(guān)系,必須要同時(shí)滿足才行
* 如果不想根據(jù)某個(gè)條件篩選,直接不給那個(gè)條件設(shè)置值就好了
* 這個(gè)方法如果不實(shí)現(xiàn),或者返回 null , 那么就代表監(jiān)聽任意交易
*/
@Override
public EthMonitorFilter ethMonitorFilter() {
return EthMonitorFilter.builder()
.setFromAddress("0x131231249813d334C58f2757037F68E2963C4crc") // 篩選 fromAddress 發(fā)送的交易
.setToAddress("0x552115849813d334C58f2757037F68E2963C4c5e") // 篩選 toAddress 或 合約地址 收到的交易
.setMinValue(BigInteger.valueOf(1)) // 篩選發(fā)送的主鏈幣數(shù)量 >= minValue 的交易
.setMaxValue(Bi
到了這里,關(guān)于以太坊怎么掃塊?推薦你一個(gè)Java工具包的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!