| | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import io.reactivex.Flowable; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import okhttp3.OkHttpClient; |
| | | import org.springframework.data.repository.query.ParameterOutOfBoundsException; |
| | | import org.web3j.crypto.Credentials; |
| | | import org.web3j.protocol.Web3j; |
| | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | /** |
| | | * @author |
| | |
| | | |
| | | private static EthUsdtContract contract(String privateKey, String contractAddress, String url) { |
| | | Credentials credentials = Credentials.create(privateKey); |
| | | return EthUsdtContract.load(contractAddress, Web3j.build(new HttpService(url)), credentials, new StaticGasProvider(BigInteger.valueOf(4500000L), BigInteger.valueOf(200000L))); |
| | | return EthUsdtContract.load(contractAddress, |
| | | Web3j.build(new HttpService(url, new OkHttpClient().newBuilder() |
| | | .connectTimeout(100, TimeUnit.SECONDS) |
| | | .writeTimeout(100, TimeUnit.SECONDS) |
| | | .readTimeout(100, TimeUnit.SECONDS) |
| | | .build())), |
| | | credentials, |
| | | new StaticGasProvider(BigInteger.valueOf(4500000L), BigInteger.valueOf(200000L))); |
| | | } |
| | | |
| | | private static EthFilter getFilter(BigInteger startBlock, String contractAddress) { |
| | |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | ChainEnum chain = ChainEnum.getValueByName(ChainEnum.BSC_TFC.name()); |
| | | assert chain != null; |
| | | // ChainEnum chain = ChainEnum.getValueByName(ChainEnum.BSC_TFC.name()); |
| | | // assert chain != null; |
| | | // |
| | | // EthUsdtContract contract = contract(chain.getPrivateKey(), chain.getContractAddress(), chain.getUrl()); |
| | | // EthFilter filter = getFilter(new BigInteger("18097238"), chain.getContractAddress()); |
| | | // |
| | | // contract.transferEventFlowable(filter).subscribe(e -> { |
| | | // System.out.println(1); |
| | | // }, error -> { |
| | | // log.error("--->", error); |
| | | // }); |
| | | |
| | | EthUsdtContract contract = contract(chain.getPrivateKey(), chain.getContractAddress(), chain.getUrl()); |
| | | EthFilter filter = getFilter(new BigInteger("18097238"), chain.getContractAddress()); |
| | | |
| | | contract.transferEventFlowable(filter).subscribe(e -> { |
| | | System.out.println(1); |
| | | }, error -> { |
| | | log.error("--->", error); |
| | | }); |
| | | System.out.println(ChainService.getInstance(ChainEnum.BSC_TFC.name()).totalSupply()); |
| | | } |
| | | |
| | | } |