This library contains tooling to interact with Jito Labs MEV software.
PRs and contributions are welcome.
- Features
- Installing
- RPC Methods
- Installing
- Keypair Authentication
- Examples
- Disclaimer
- Support
- License
- Searcher
- Block Engine
- Relayer
- ShredStream (WIP, help welcome 😊)
- Geyser
🤡* methods which are disabled by Jito due to malicious use
- Searcher
SubscribeMempoolAccounts
🤡SubscribeMempoolPrograms
🤡GetNextScheduledLeader
GetRegions
GetConnectedLeaders
GetConnectedLeadersRegioned
GetTipAccounts
SimulateBundle
SendBundle
SendBundleWithConfirmation
SubscribeBundleResults
- Block Engine
- Validator
SubscribePackets
SubscribeBundles
GetBlockBuilderFeeInfo
- Relayer
SubscribeAccountsOfInterest
SubscribeProgramsOfInterest
StartExpiringPacketStream
- Validator
- Geyser
SubscribePartialAccountUpdates
SubscribeBlockUpdates
SubscribeAccountUpdates
SubscribeProgramUpdates
SubscribeTransactionUpdates
SubscribeSlotUpdates
- ShredStream
- Others (pkg/util.go)
SubscribeTipStream
go get github.com/weeaa/jito-go@latest
If you want to run tests:
- Install Task.
- Initialize your
.env
file by runningtask install:<os>
(darwin/linux/windows). - Run tests with
task test
.
To access Jito MEV functionalities, you'll need a whitelisted Public Key obtained from a fresh KeyPair; submit your Public Key here.
In order to generate a new KeyPair, you can use the following function GenerateKeypair()
from the /pkg
package.
package main
import (
"context"
"github.com/gagliardetto/solana-go"
"github.com/gagliardetto/solana-go/programs/system"
"github.com/gagliardetto/solana-go/rpc"
"github.com/weeaa/jito-go"
"github.com/weeaa/jito-go/clients/searcher_client"
"log"
"os"
)
func main() {
client, err := searcher_client.NewSearcherClient(
jito_go.NewYork.BlockEngineURL,
rpc.New(rpc.MainNetBeta_RPC),
solana.MustPrivateKeyFromBase58(os.Getenv("PRIVATE_KEY")),
nil,
)
if err != nil {
log.Fatal(err)
}
// max per bundle is 5 transactions
txns := make([]*solana.Transaction, 0, 5)
block, err := client.RpcConn.GetRecentBlockhash(context.TODO(), rpc.CommitmentFinalized)
if err != nil {
log.Fatal(err)
}
from := solana.MustPrivateKeyFromBase58("Tq5gFBU4QG6b6aUYAwi87CUx64iy5tZT1J6nuphN4FXov3UZahMYGSbxLGhb8a9UZ1VvxWB4NzDavSzTorqKCio")
to := solana.MustPublicKeyFromBase58("BLrQPbKruZgFkNhpdGGrJcZdt1HnfrBLojLYYgnrwNrz")
tx, err := solana.NewTransaction(
[]solana.Instruction{
system.NewTransferInstruction(
10000,
from.PublicKey(),
to,
).Build(),
},
block.Value.Blockhash,
solana.TransactionPayer(from.PublicKey()),
)
if err != nil {
log.Fatal(err)
}
if _, err = tx.Sign(
func(key solana.PublicKey) *solana.PrivateKey {
if from.PublicKey().Equals(key) {
return &from
}
return nil
},
); err != nil {
log.Fatal(err)
}
txns = append(txns, tx)
resp, err := client.BroadcastBundleWithConfirmation(txns, 100)
if err != nil {
log.Fatal(err)
}
log.Println(resp)
}
package main
import (
"context"
"github.com/gagliardetto/solana-go"
"github.com/gagliardetto/solana-go/rpc"
"github.com/weeaa/jito-go"
"github.com/weeaa/jito-go/clients/searcher_client"
"log"
"os"
)
func main() {
client, err := searcher_client.NewSearcherClient(
jito_go.NewYork.BlockEngineURL,
rpc.New(rpc.MainNetBeta_RPC),
solana.MustPrivateKeyFromBase58(os.Getenv("PRIVATE_KEY")),
nil,
)
if err != nil {
log.Fatal(err)
}
txSub := make(chan *solana.Transaction)
regions := []string{jito_go.NewYork.Region}
accounts := []string{
"GuHvDyajPfQpHrg2oCWmArYHrZn2ynxAkSxAPFn9ht1g",
"4EKP9SRfykwQxDvrPq7jUwdkkc93Wd4JGCbBgwapeJhs",
"Hn98nGFGfZwJPjd4bk3uAX5pYHJe5VqtrtMhU54LNNhe",
"MuUEAu5tFfEMhaFGoz66jYTFBUHZrwfn3KWimXLNft2",
"CSGeQFoSuN56QZqf9WLqEEkWhRFt6QksTjMDLm68PZKA",
}
payload := &searcher_client.SubscribeAccountsMempoolTransactionsPayload{
Ctx: context.TODO(),
Accounts: accounts,
Regions: regions,
TxCh: make(chan *solana.Transaction),
ErrCh: make(chan error),
}
if err = client.SubscribeAccountsMempoolTransactions(payload); err != nil {
log.Fatal(err)
}
for tx := range txSub {
log.Println(tx)
}
}
package main
import (
"github.com/gagliardetto/solana-go"
"github.com/gagliardetto/solana-go/rpc"
"github.com/weeaa/jito-go"
"github.com/weeaa/jito-go/clients/searcher_client"
"log"
"os"
)
func main() {
client, err := searcher_client.NewSearcherClient(
jito_go.NewYork.BlockEngineURL,
rpc.New(rpc.MainNetBeta_RPC),
solana.MustPrivateKeyFromBase58(os.Getenv("PRIVATE_KEY")),
nil,
)
if err != nil {
log.Fatal(err)
}
resp, err := client.GetRegions()
if err != nil {
log.Fatal(err)
}
log.Println(resp)
}
package main
import (
"context"
"github.com/weeaa/jito-go/clients/geyser_client"
"github.com/weeaa/jito-go/proto"
"log"
)
func main() {
rpcAddr := "myGeyserRpcNodeURL"
// establish conn to geyser node...
client, err := geyser_client.NewGeyserClient(context.Background(), rpcAddr, nil)
if err != nil {
log.Fatal(err)
}
// create block update sub
sub, err := client.SubscribeBlockUpdates()
if err != nil {
log.Fatal(err)
}
// create chan to receive block updates
ch := make(chan *proto.BlockUpdate)
// feed the chan with block updates
client.OnBlockUpdates(context.Background(), sub, ch)
// loop to read new block updates from chan
for {
block := <-ch
log.Println(block)
}
}
This library is not affiliated with Jito Labs. It is a community project and is not officially supported by Jito Labs. Use at your own risk.
If my work has been useful in building your for-profit services/infra/bots/etc, consider donating at
EcrHvqa5Vh4NhR3bitRZVrdcUGr1Z3o6bXHz7xgBU2FB
(SOL).