| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.web3j.crypto.Credentials; |
| | | import org.web3j.protocol.Web3j; |
| | | import org.web3j.protocol.core.DefaultBlockParameter; |
| | | import org.web3j.protocol.core.DefaultBlockParameterName; |
| | | import org.web3j.protocol.core.DefaultBlockParameterNumber; |
| | | import org.web3j.protocol.core.methods.request.EthFilter; |
| | |
| | | } |
| | | |
| | | //private static String blockchainNode = "http://114.55.250.231:8545"; |
| | | private static String blockchainNode = "http://120.55.86.146:8545"; |
| | | private static String blockchainNode = "https://bsc-dataseed1.ninicoin.io"; |
| | | |
| | | // private static String contractAddr = "0xdac17f958d2ee523a2206206994597c13d831ec7"; |
| | | |
| | |
| | | ALL_ADDRESS_LIST.addAll(tdCoinWallets); |
| | | } |
| | | // 获取最新区块 |
| | | String string = redisUtils.getString(ETH_USDT_BLOCK_NUM); |
| | | // String string = redisUtils.getString(ETH_USDT_BLOCK_NUM); |
| | | String string = "24317595"; |
| | | if(string==null){ |
| | | string = "24317595"; |
| | | } |
| | | BigInteger blockNum = new BigInteger(string); |
| | | Credentials credentials = Credentials.create(privateKey); |
| | | EthUsdtContract contract = EthUsdtContract.load(contractAddr, getInstance(), credentials, getStaticGasProvider()); |
| | | EthFilter filter = getFilter(blockNum); |
| | | |
| | | EthFilter filter = getFilter(blockNum,null,contractAddr); |
| | | |
| | | Map<String,BigInteger> map = new HashMap<String,BigInteger>(); |
| | | map.put("blockNum",blockNum); |
| | | contract.transferEventFlowable(filter).subscribe(e->{ |
| | |
| | | return new EthFilter(DefaultBlockParameterName.EARLIEST, |
| | | DefaultBlockParameterName.LATEST, contractAddr); |
| | | } |
| | | |
| | | } |
| | | |
| | | private static EthFilter getFilter(BigInteger startBlock, BigInteger endBlock, String contractAddress) { |
| | | DefaultBlockParameter startParameterName = null; |
| | | DefaultBlockParameter endParameterName = null; |
| | | if (startBlock != null) { |
| | | startParameterName = new DefaultBlockParameterNumber(startBlock); |
| | | } else { |
| | | startParameterName = DefaultBlockParameterName.EARLIEST; |
| | | } |
| | | |
| | | if (endBlock != null) { |
| | | endParameterName = new DefaultBlockParameterNumber(endBlock); |
| | | } else { |
| | | endParameterName = DefaultBlockParameterName.LATEST; |
| | | } |
| | | |
| | | return new EthFilter(startParameterName, endParameterName, contractAddress); |
| | | } |
| | | |
| | | } |