Official Go client for the Router Protocol Xplore API, providing Go definitions and client implementations for the Xplore Aggregator service.
go get github.com/router-protocol/xplore-types-goFor a specific version:
go get github.com/router-protocol/[email protected]package main
import (
"context"
"fmt"
"log"
"time"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
client "github.com/router-protocol/xplore-types-go"
)
func main() {
// Set up a connection to the server
conn, err := grpc.Dial("your-grpc-server.com:50051", grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
log.Fatalf("Failed to connect: %v", err)
}
defer conn.Close()
// Create a client using the connection
xploreClient := client.NewAggregatorClient(conn)
// Create a request
req := &client.XploreRequest{
InputToken: &client.ChainToken{
ChainId: "chain-1",
Address: "0x123...",
Decimals: 18,
},
OutputToken: &client.ChainToken{
ChainId: "chain-2",
Address: "0x456...",
Decimals: 18,
},
AmountIn: "1000000000000000000", // 1 token with 18 decimals
AmountOutMin: "900000000000000000", // 0.9 token with 18 decimals
SlippageTolerance: 50, // 0.5%
RecipientAddress: "0x789...",
SenderAddress: "0xabc...",
}
// Create context with timeout
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
// Make the gRPC call
resp, err := xploreClient.AggregateCall(ctx, req)
if err != nil {
log.Fatalf("Error calling AggregateCall: %v", err)
}
// Process the response
fmt.Printf("Amount out: %s\n", resp.AmountOut)
fmt.Printf("Price impact: %f\n", resp.PriceImpact)
}The Go client provides access to all methods of the Xplore Aggregator service:
AggregateCall: Request token swap quotesAggregateMultiCall: Request multiple token swap quotesGetTransactionRecord: Get details of a transactionAggregateCallSplit: Request split token swap quotesAggregateCallCrossChainSplit: Request cross-chain split quotesRegisterDynamicNode: Register a node with the serviceListRegisteredNodes: List all registered nodesDisableNode: Disable a specific nodeEnableNode: Enable a specific nodeWhitelistAddress: Whitelist an addressListWhitelistedAddresses: List all whitelisted addressesRemoveWhitelistedAddress: Remove an address from the whitelistListActiveNodes: List all active nodesHealthCheck: Check the health of the service
This library follows semantic versioning. Each release is tagged in the format vX.Y.Z.
You can find all available versions on the releases page.
This client is automatically generated from the Xplore proto files in the main xplore-types repository. Updates are published whenever a new version tag is pushed to the main repository.
MIT