22
33import java .io .IOException ;
44import java .math .BigInteger ;
5+ import java .nio .file .Paths ;
56import java .util .List ;
67import java .util .concurrent .CompletableFuture ;
78import java .util .concurrent .ExecutionException ;
89
10+ import io .github .cdimascio .dotenv .Dotenv ;
911import io .reactivex .disposables .Disposable ;
1012import net .flashbots .MevShareClient ;
1113import net .flashbots .models .bundle .BundleItemType ;
3335public class RpcMevSendBundle {
3436
3537 public static void main (String [] args ) throws ExecutionException , InterruptedException , IOException {
36- Credentials sender = Credentials .create ("<hex string of privateKey>" );
37- var web3j = Web3j .build (new HttpService ("<L1 network url>" ));
38- var mevShareClient = new MevShareClient (Network .GOERLI , sender , web3j );
38+ Dotenv dotenv = Dotenv .configure ()
39+ .directory (Paths .get ("" , "example" ).toAbsolutePath ().toString ())
40+ .filename (".env" )
41+ .load ();
42+ Credentials authSigner = Credentials .create (dotenv .get ("AUTH_PRIVATE_KEY" ));
43+ Web3j web3j = Web3j .build (new HttpService (dotenv .get ("PROVIDER_URL" )));
44+ var mevShareClient = new MevShareClient (Network .GOERLI , authSigner , web3j );
3945
4046 CompletableFuture <MevShareEvent > future = new CompletableFuture <>();
4147 Disposable eventSource = mevShareClient .subscribe (mevShareEvent -> {
@@ -56,14 +62,14 @@ public static void main(String[] args) throws ExecutionException, InterruptedExc
5662
5763 BundleItemType .HashItem bundleItem = new BundleItemType .HashItem ().setHash (mevShareEvent .getHash ());
5864
59- Credentials signer = Credentials .create ("<private key>" );
65+ Credentials signer = Credentials .create (dotenv . get ( "SENDER_PRIVATE_KEY" ) );
6066 BigInteger nonce = web3j .ethGetTransactionCount (signer .getAddress (), DefaultBlockParameterName .PENDING )
6167 .send ()
6268 .getTransactionCount ();
6369 BigInteger gasPrice = web3j .ethGasPrice ().send ().getGasPrice ();
6470 BigInteger gasLimit = DefaultGasProvider .GAS_LIMIT ;
65- final String to = "<to address> " ;
66- final String amount = "<ether amount> " ;
71+ final String to = "0x56EdF679B0C80D528E17c5Ffe514dc9a1b254b9c " ;
72+ final String amount = "0.001 " ;
6773 RawTransaction rawTransaction = RawTransaction .createEtherTransaction (
6874 nonce ,
6975 gasPrice ,
0 commit comments