web3j icon indicating copy to clipboard operation
web3j copied to clipboard

Main network Subscribe to listen to ERC2O transaction event NullPointerException?

Open feixz opened this issue 7 years ago • 3 comments

clientVersion: Geth/v1.8.20-stable/linux-amd64/go1.11.2 web3j-core.version: 4.1.0

val filter = EthFilter(
                    DefaultBlockParameterName.EARLIEST,
                    DefaultBlockParameterName.LATEST,
                    contractAddresses)
            val event = Event("Transfer", listOf(
                    object : TypeReference<Address>(true) {},
                    object : TypeReference<Address>(true) {},
                    object : TypeReference<Uint256>(false) {}))

            val topicData = EventEncoder.encode(event)
            filter.addSingleTopic(topicData)
            this.erc20TransactionSubscribe = web3j.ethLogFlowable(filter).subscribe({ log ->
                log?.run {
                    logger.debug("Monitored the new erc20 transaction.. {}", JSON.toJSONString(this))
                    val addresses = this.topics.filter { it != topicData }.map { Address(it).value }
                    transactionService.saveERC20Transaction(this.transactionIndex.toString(),
                            this.transactionHash,
                            this.blockHash,
                            this.blockNumber.toString(),
                            this.address,
                            Numeric.decodeQuantity(this.data),
                            addresses)
                }
            }, { ex ->
                logger.error("An exception occurred while listening to the erc20 transaction: ${ex.message}", ex)
            })

** error log **

java.lang.NullPointerException: null
        at org.web3j.protocol.core.filters.LogFilter.process(LogFilter.java:36)
        at org.web3j.protocol.core.filters.Filter.getInitialFilterLogs(Filter.java:106)
        at org.web3j.protocol.core.filters.Filter.run(Filter.java:61)
        at org.web3j.protocol.rx.JsonRpc2_0Rx.run(JsonRpc2_0Rx.java:73)
        at org.web3j.protocol.rx.JsonRpc2_0Rx.lambda$ethLogFlowable$2(JsonRpc2_0Rx.java:65)
        at io.reactivex.internal.operators.flowable.FlowableCreate.subscribeActual(FlowableCreate.java:71)
        at io.reactivex.Flowable.subscribe(Flowable.java:14479)
        at io.reactivex.Flowable.subscribe(Flowable.java:14416)
        at io.reactivex.Flowable.subscribe(Flowable.java:14337)
        at com.jidian.blkchn.wallet.component.Web3jTransactionFilter.erc20TokenTransactionFilter(Web3jTransactionFilter.kt:69)
        at com.jidian.blkchn.wallet.component.Web3jTransactionFilter.restartERC20TokenTransactionFilter(Web3jTransactionFilter.kt:97)
        at com.jidian.blkchn.wallet.component.Web3jTransactionFilter$$FastClassBySpringCGLIB$$359d233b.invoke(<generated>)
        at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
        at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:746)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
        at org.springframework.aop.interceptor.AsyncExecutionInterceptor.lambda$invoke$0(AsyncExecutionInterceptor.java:115)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.lang.Thread.run(Thread.java:748)

feixz avatar Jan 09 '19 05:01 feixz

I am very surprised that it has no problem under the rinkeby network. When I switched to the main network, this error occurred. Of course, my contract address is the contract address of the main network.

feixz avatar Jan 09 '19 05:01 feixz

@zhangfei9734 will the error persist if you narrow down you search range and use web3j 4.3.x ?

AlexandrouR avatar Jul 24 '19 13:07 AlexandrouR

Issue closed due to inactivity.

AlexandrouR avatar Aug 16 '19 16:08 AlexandrouR