BlockRazor
Go to website
繁体中文
繁体中文
  • 👉关于BlockRazor
  • 👨‍💻用户案例
    • 钱包
    • 去中心化交易所
    • Trading Bot
    • Searcher
    • 量化交易系统
  • 💸Solana
    • 总览
    • Authentication
    • APIs
      • sendTransaction
      • getTransactionFee
      • Sandwich Detector
  • 🖥️BSC
    • Authentication
    • Dedicate Node
      • 創建Dedicate Node
      • 使用Dedicate Node
    • 高性能網絡
      • Proto
      • Subscribe NewTxs
      • Subscribe NewBlocks
      • Send RawTx
      • Send RawTxBatch
      • 全節點同步
    • Block Builder
      • Send Bundle
      • Send PrivateTransaction
      • Call Bundle
      • Trace Bundle
    • APIs
      • GetGasPriceStream
      • GetAllGasPriceStream
      • Sandwich Detector
  • 🛡️Scutum(ETH & BSC)
    • 总览
    • New to MEV
    • 項目專屬RPC
    • 錢包用戶通用RPC
    • Searcher
      • Authentication
      • Subscribe Bundle
      • Send Bundle
  • 📄声明
    • 隱私聲明
Powered by GitBook
On this page
  • 介紹
  • 流控說明
  • 請求參數
  • 請求示例
  • Proto
  • 返回示例
  1. Solana
  2. APIs

getTransactionFee

介紹

getTransactionFee 用於聚合獲取Solana交易的priority fee和tip,支持gRPC協議,端點域名:grpc.solana-fee.blockrazor.xyz:443

流控說明

Tier 4
Tier 3
Tier 2
Tier 1
Tier 0

TPS

1

5

10

50

100

請求參數

字段
必選
格式
示例
備注

accounts

否

string[]

["DH4xma……HFtNYJ"]

不指定account則統計指定slot區間內全部交易的priority fee和tip

percentile

是

int

50

獲取指定分位的priority fee和tip,枚舉值:25、50、75、95、99

slotRange

是

int

150

統計最近N個confirmed slot中交易的priorityFee和tip,N取值範圍1-150

請求示例

package main

import (
	"context"
	"crypto/tls"
	"log"

	// directory of the generated code using the provided proto file
	pb "fee-test/feepb"

	"google.golang.org/grpc"
	"google.golang.org/grpc/credentials"
)

const (
	gRPCEndpoint = "grpc.solana-fee.blockrazor.xyz:443" // endpoint address
	auth         = "your auth" // auth to be verified
	testAccount1 = "DH4xmaWDnTzKXehVaPSNy9tMKJxnYL5Mo5U3oTHFtNYJ" // query priority fee and tip of transactions involving a specified account 
	testAccount2 = "CAPhoEse9xEH95XmdnJjYrZdNCA8xfUWdy3aWymHa1Vj" 
)

func main() {
	// open gRPC connection to endpoint
	conn, err := grpc.Dial(
		gRPCEndpoint,
		grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{})),
		grpc.WithPerRPCCredentials(&Authentication{auth}),
	)
	if err != nil {
		panic(err)
	}
	defer conn.Close()

	// use the gRPC client
	client := pb.NewServerClient(conn)

	req := &pb.TransactionFee{
		Accounts:   []string{}, //do not set accounts
		Percentile: 75,
		SlotRange:  150,
	}
  
  // send gRPC request1
	resp, err := client.GetTransactionFee(context.Background(), req)
	if err != nil {
		panic(err)
	}
	log.Printf("Response PriorityFee Percentile: %+v", resp.PriorityFee.Percentile)
	log.Printf("Response PriorityFee Value: %+v", resp.PriorityFee.Value)
	log.Printf("Response Tip Percentile: %+v", resp.Tip.Percentile)
	log.Printf("Response Tip Value: %+v", resp.Tip.Value)
	
	req2 := &pb.TransactionFee{
		Accounts:   []string{testAccount1, testAccount2}, //set specified accounts
		Percentile: 75,
		SlotRange:  150,
	}
	
	// send gRPC request2
	resp2, err := client.GetTransactionFee(context.Background(), req2)
	if err != nil {
		panic(err)
	}
	log.Printf("Response2 PriorityFee Percentile: %+v", resp2.PriorityFee.Percentile)
	log.Printf("Response2 PriorityFee Value: %+v", resp2.PriorityFee.Value)
	log.Printf("Response2 Tip Percentile: %+v", resp2.Tip.Percentile)
	log.Printf("Response2 Tip Value: %+v", resp2.Tip.Value)
}

type Authentication struct {
	auth string
}

func (a *Authentication) GetRequestMetadata(context.Context, ...string) (map[string]string, error) {
	return map[string]string{"apiKey": a.auth}, nil
}

func (a *Authentication) RequireTransportSecurity() bool {
	return false
}

Proto

syntax = "proto3";

package feepb;

option go_package = "./pb/feepb";

service Server {
    rpc GetTransactionFee(TransactionFee) returns(TransactionFeeResponse) {};
}

message TransactionFee {
    repeated string accounts = 1;
    int32 percentile = 2;
    int32 slotRange = 3;
}

message TransactionFeeResponse {
    FeeValue priorityFee = 1;
    FeeValue tip = 2;
}

message FeeValue {
    int32 percentile = 1;
    double value = 2;
}

返回示例

Response PriorityFee Percentile: 75
Response PriorityFee Value: 10000 // 對應分位的priority fee,單位為micro-lamports
Response Tip Percentile: 75 
Response Tip Value: 0.0001 // 對應分位的tip,單位為Sol
Response2 PriorityFee Percentile: 75
Response2 PriorityFee Value: 432313.2435833086
Response2 Tip Percentile: 75
Response2 Tip Value: 0.0001

PrevioussendTransactionNextSandwich Detector

Last updated 1 month ago

💸