-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathSseHistorical.java
More file actions
49 lines (42 loc) · 1.85 KB
/
SseHistorical.java
File metadata and controls
49 lines (42 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package event;
import java.math.BigInteger;
import java.nio.file.Paths;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import io.github.cdimascio.dotenv.Dotenv;
import net.flashbots.MevShareClient;
import net.flashbots.models.common.Network;
import net.flashbots.models.event.EventHistoryEntry;
import net.flashbots.models.event.EventHistoryInfo;
import net.flashbots.models.event.EventHistoryParams;
import org.web3j.crypto.Credentials;
import org.web3j.protocol.Web3j;
import org.web3j.protocol.http.HttpService;
/**
* SSE historical example
*
* @author kaichen
* @since 0.1.0
*/
public class SseHistorical {
public static void main(String[] args) throws ExecutionException, InterruptedException {
Dotenv dotenv = Dotenv.configure()
.directory(Paths.get("", "example").toAbsolutePath().toString())
.filename(".env")
.load();
Credentials authSigner = Credentials.create(dotenv.get("AUTH_PRIVATE_KEY"));
Web3j web3j = Web3j.build(new HttpService(dotenv.get("PROVIDER_URL")));
var mevShareClient = new MevShareClient(Network.GOERLI, authSigner, web3j);
// get event history info
CompletableFuture<EventHistoryInfo> historyInfoFuture = mevShareClient.getEventHistoryInfo();
EventHistoryInfo eventHistoryInfo = historyInfoFuture.get();
System.out.println(eventHistoryInfo);
// get event history entry
var historyParams = new EventHistoryParams().setLimit(20).setBlockStart(BigInteger.valueOf(1_000_000L));
CompletableFuture<List<EventHistoryEntry>> eventHistory = mevShareClient.getEventHistory(historyParams);
List<EventHistoryEntry> eventHistoryEntries = eventHistory.get();
System.out.println(eventHistoryEntries);
mevShareClient.close();
}
}