BatchGetTransactions gRPC Method
参数
digests
数组
必填
正在加载...
read_mask
对象
正在加载...
paths
数组
正在加载...
退货
交易
数组
正在加载...
digest
字符串
正在加载...
交易
对象
正在加载...
bcs
对象
正在加载...
名称
字符串
正在加载...
值
字符串
正在加载...
digest
字符串
正在加载...
版本
整数
正在加载...
kind
对象
正在加载...
programmableTransaction
对象
正在加载...
inputs
数组
正在加载...
kind
字符串
正在加载...
objectId
字符串
正在加载...
mutable
布尔型
正在加载...
pure
字符串
正在加载...
版本
字符串
正在加载...
digest
字符串
正在加载...
commands
数组
正在加载...
moveCall
对象
正在加载...
package
字符串
正在加载...
module
字符串
正在加载...
函数
字符串
正在加载...
typeArguments
数组
正在加载...
arguments
数组
正在加载...
kind
字符串
正在加载...
输入
整数
正在加载...
结果
整数
正在加载...
sender
字符串
正在加载...
gasPayment
对象
正在加载...
objects
数组
正在加载...
objectId
字符串
正在加载...
版本
字符串
正在加载...
digest
字符串
正在加载...
owner
字符串
正在加载...
价格
字符串
正在加载...
budget
字符串
正在加载...
到期
对象
正在加载...
kind
字符串
正在加载...
effects
对象
正在加载...
bcs
对象
正在加载...
名称
字符串
正在加载...
值
字符串
正在加载...
digest
字符串
正在加载...
版本
整数
正在加载...
状态
对象
正在加载...
success
布尔型
正在加载...
时代
字符串
正在加载...
gasUsed
对象
正在加载...
computationCost
字符串
正在加载...
storageCost
字符串
正在加载...
storageRebate
字符串
正在加载...
nonRefundableStorageFee
字符串
正在加载...
transactionDigest
字符串
正在加载...
gasObject
对象
正在加载...
objectId
字符串
正在加载...
inputState
字符串
正在加载...
inputVersion
字符串
正在加载...
inputDigest
字符串
正在加载...
inputOwner
对象
正在加载...
kind
字符串
正在加载...
地址
字符串
正在加载...
outputState
字符串
正在加载...
outputVersion
字符串
正在加载...
outputDigest
字符串
正在加载...
outputOwner
对象
正在加载...
kind
字符串
正在加载...
地址
字符串
正在加载...
idOperation
字符串
正在加载...
eventsDigest
字符串
正在加载...
dependencies
数组
正在加载...
lamportVersion
字符串
正在加载...
changedObjects
数组
正在加载...
objectId
字符串
正在加载...
inputState
字符串
正在加载...
inputVersion
字符串
正在加载...
inputDigest
字符串
正在加载...
inputOwner
对象
正在加载...
kind
字符串
正在加载...
地址
字符串
正在加载...
outputState
字符串
正在加载...
outputVersion
字符串
正在加载...
outputDigest
字符串
正在加载...
outputOwner
对象
正在加载...
kind
字符串
正在加载...
地址
字符串
正在加载...
idOperation
字符串
正在加载...
objectType
字符串
正在加载...
unchangedConsensusObjects
数组
正在加载...
kind
字符串
正在加载...
objectId
字符串
正在加载...
版本
字符串
正在加载...
digest
字符串
正在加载...
活动
对象
正在加载...
bcs
对象
正在加载...
名称
字符串
正在加载...
值
字符串
正在加载...
digest
字符串
正在加载...
活动
数组
正在加载...
packageId
字符串
正在加载...
module
字符串
正在加载...
sender
字符串
正在加载...
eventType
字符串
正在加载...
contents
对象
正在加载...
名称
字符串
正在加载...
值
字符串
正在加载...
json
对象
正在加载...
balanceManagerId
字符串
正在加载...
baseAssetQuantityCanceled
字符串
正在加载...
clientOrderId
字符串
正在加载...
isBid
布尔型
正在加载...
订单编号
字符串
正在加载...
originalQuantity
字符串
正在加载...
poolId
字符串
正在加载...
价格
字符串
正在加载...
时间戳
字符串
正在加载...
trader
字符串
正在加载...
请求
1grpcurl \2-import-path . \3-proto sui/rpc/v2/ledger_service.proto \4-H "x-token: YOUR_TOKEN_VALUE" \5-d '{6"digests": [7"HjuLoCGjS4wBC5KfqmExUa7GcF3yzaWRN1YoYpgxQC6G"8],9"read_mask": {10"paths": [11"digest",12"transaction",13"effects",14"events"15]16}17}' \18docs-demo.sui-mainnet.quiknode.pro:9000 \19sui.rpc.v2.LedgerService/BatchGetTransactions
1grpcurl \2-import-path . \3-proto sui/rpc/v2/ledger_service.proto \4-H "x-token: YOUR_TOKEN_VALUE" \5-d '{6"digests": [7"HjuLoCGjS4wBC5KfqmExUa7GcF3yzaWRN1YoYpgxQC6G"8],9"read_mask": {10"paths": [11"digest",12"transaction",13"effects",14"events"15]16}17}' \18docs-demo.sui-mainnet.quiknode.pro:9000 \19sui.rpc.v2.LedgerService/BatchGetTransactions
1包 main23导入 (4"上下文"5"crypto/tls"6"encoding/json"7"fmt"8"日志"9"time"1011"google.golang.org/grpc"12"google.golang.org/grpc/credentials"13"google.golang.org/protobuf/encoding/protojson"14"google.golang.org/protobuf/types/known/fieldmaskpb"1516pb "sui-grpc/sui/rpc/v2" // Your Generated .pb.go files path17)1819// Quicknode endpoints consist of two crucial components: the endpoint name and the corresponding token20// For eg: QN Endpoint: https://docs-demo.sui-mainnet.quiknode.pro/abcde12345678921// endpoint will be: docs-demo.sui-mainnet.quiknode.pro:9000 {9000 is the port number for Sui gRPC}22// token will be : abcde1234567892324var (25token = "YOUR_TOKEN_NUMBER"26endpoint = "YOUR_QN_ENDPOINT:9000"27)2829// Auth structure for x-token30类型 auth 结构体 {31token 字符串32}3334func (a *auth) GetRequestMetadata(ctx 上下文.上下文, uri ...字符串) (map[字符串]字符串, error) {35返回 map[字符串]字符串{36“x-token”: a.令牌,37}, nil38}3940func (a *auth) RequireTransportSecurity() bool {41return true42}4344func main() {45// TLS credentials and x-token auth46creds := credentials.NewTLS(&tls.Config{})47opts := []grpc.DialOption{48grpc.WithTransportCredentials(creds),49grpc.WithPerRPC凭据(&auth{令牌}),50}5152conn, err := grpc.Dial(endpoint, opts...)53如果 err != nil {54log.Fatalf("Failed to connect: %v", err)55}56defer conn.Close()5758client := pb.NewLedgerServiceClient(conn)5960// Digest array61digests := []string{62"HjuLoCGjS4wBC5KfqmExUa7GcF3yzaWRN1YoYpgxQC6G",63}6465// FieldMask to restrict returned fields66readMask := &fieldmaskpb.FieldMask{67Paths: []string{"digest", "transaction", "effects", "events"},68}6970req := &pb.BatchGetTransactionsRequest{71Digests: digests,72ReadMask: readMask,73}7475ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)76defer cancel()7778resp, err := client.BatchGetTransactions(ctx, req)79如果 err != nil {80log.Fatalf("BatchGetTransactions failed: %v", err)81}8283// Format response as pretty JSON84marshaler := protojson.MarshalOptions{85UseProtoNames: true,86EmitUnpopulated: true,87Indent: " ",88}8990jsonBytes, err := marshaler.Marshal(resp)91如果 err != nil {92log.Fatalf("Failed to marshal response: %v", err)93}9495var pretty map[string]interface{}96if err := json.Unmarshal(jsonBytes, &pretty); err != nil {97log.Fatalf("Failed to parse JSON: %v", err)98}99100formatted, _ := json.MarshalIndent(pretty, "", " ")101fmt.Println(string(formatted))102}103
1包 main23导入 (4"上下文"5"crypto/tls"6"encoding/json"7"fmt"8"日志"9"time"1011"google.golang.org/grpc"12"google.golang.org/grpc/credentials"13"google.golang.org/protobuf/encoding/protojson"14"google.golang.org/protobuf/types/known/fieldmaskpb"1516pb "sui-grpc/sui/rpc/v2" // Your Generated .pb.go files path17)1819// Quicknode endpoints consist of two crucial components: the endpoint name and the corresponding token20// For eg: QN Endpoint: https://docs-demo.sui-mainnet.quiknode.pro/abcde12345678921// endpoint will be: docs-demo.sui-mainnet.quiknode.pro:9000 {9000 is the port number for Sui gRPC}22// token will be : abcde1234567892324var (25token = "YOUR_TOKEN_NUMBER"26endpoint = "YOUR_QN_ENDPOINT:9000"27)2829// Auth structure for x-token30类型 auth 结构体 {31token 字符串32}3334func (a *auth) GetRequestMetadata(ctx 上下文.上下文, uri ...字符串) (map[字符串]字符串, error) {35返回 map[字符串]字符串{36“x-token”: a.令牌,37}, nil38}3940func (a *auth) RequireTransportSecurity() bool {41return true42}4344func main() {45// TLS credentials and x-token auth46creds := credentials.NewTLS(&tls.Config{})47opts := []grpc.DialOption{48grpc.WithTransportCredentials(creds),49grpc.WithPerRPC凭据(&auth{令牌}),50}5152conn, err := grpc.Dial(endpoint, opts...)53如果 err != nil {54log.Fatalf("Failed to connect: %v", err)55}56defer conn.Close()5758client := pb.NewLedgerServiceClient(conn)5960// Digest array61digests := []string{62"HjuLoCGjS4wBC5KfqmExUa7GcF3yzaWRN1YoYpgxQC6G",63}6465// FieldMask to restrict returned fields66readMask := &fieldmaskpb.FieldMask{67Paths: []string{"digest", "transaction", "effects", "events"},68}6970req := &pb.BatchGetTransactionsRequest{71Digests: digests,72ReadMask: readMask,73}7475ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)76defer cancel()7778resp, err := client.BatchGetTransactions(ctx, req)79如果 err != nil {80log.Fatalf("BatchGetTransactions failed: %v", err)81}8283// Format response as pretty JSON84marshaler := protojson.MarshalOptions{85UseProtoNames: true,86EmitUnpopulated: true,87Indent: " ",88}8990jsonBytes, err := marshaler.Marshal(resp)91如果 err != nil {92log.Fatalf("Failed to marshal response: %v", err)93}9495var pretty map[string]interface{}96if err := json.Unmarshal(jsonBytes, &pretty); err != nil {97log.Fatalf("Failed to parse JSON: %v", err)98}99100formatted, _ := json.MarshalIndent(pretty, "", " ")101fmt.Println(string(formatted))102}103
1import * as grpc from '@grpc/grpc-js';2import * as protoLoader from '@grpc/proto-loader';3import * as path from 'path';45const PROTO_PATH = path.join(__dirname, 'protos/proto/sui/rpc/v2/ledger_service.proto');67// Quicknode endpoints consist of two crucial components: the endpoint name and the corresponding token8// For eg: QN Endpoint: https://docs-demo.sui-mainnet.quiknode.pro/abcde1234567899// endpoint will be: docs-demo.sui-mainnet.quiknode.pro:9000 {9000 is the port number for Sui gRPC}10// token will be : abcde1234567891112const endpoint = 'docs-demo.sui-mainnet.quiknode.pro:9000';13const token = 'abcde123456789';1415// Load proto definition16const packageDefinition = protoLoader.loadSync(PROTO_PATH, {17keepCase: true,18longs: String,19enums: String,20defaults: true,21oneofs: true,22includeDirs: [path.join(__dirname, 'protos/proto')],23});24const proto = grpc.loadPackageDefinition(packageDefinition) as any;25const LedgerService = proto.sui.rpc.v2.LedgerService;2627// Create gRPC client with TLS28const client = new LedgerService(endpoint, grpc.credentials.createSsl());2930// Metadata for authentication31const metadata = new grpc.Metadata();32metadata.add('x-token', token);3334// Request setup35const request = {36digests: ['HjuLoCGjS4wBC5KfqmExUa7GcF3yzaWRN1YoYpgxQC6G'], // Replace with valid digests37read_mask: {38paths: ['digest', 'transaction', 'effects', 'events'], // FieldMask39},40};4142// Invoke BatchGetTransactions43client.BatchGetTransactions(request, metadata, (err: grpc.ServiceError | null, response: any) => {44if (err) {45console.error('gRPC Error:', {46code: err.code,47message: err.message,48details: err.details,49});50} else {51console.log('BatchGetTransactions Response:');52console.log(JSON.stringify(response, null, 2));53}54});55
1import * as grpc from '@grpc/grpc-js';2import * as protoLoader from '@grpc/proto-loader';3import * as path from 'path';45const PROTO_PATH = path.join(__dirname, 'protos/proto/sui/rpc/v2/ledger_service.proto');67// Quicknode endpoints consist of two crucial components: the endpoint name and the corresponding token8// For eg: QN Endpoint: https://docs-demo.sui-mainnet.quiknode.pro/abcde1234567899// endpoint will be: docs-demo.sui-mainnet.quiknode.pro:9000 {9000 is the port number for Sui gRPC}10// token will be : abcde1234567891112const endpoint = 'docs-demo.sui-mainnet.quiknode.pro:9000';13const token = 'abcde123456789';1415// Load proto definition16const packageDefinition = protoLoader.loadSync(PROTO_PATH, {17keepCase: true,18longs: String,19enums: String,20defaults: true,21oneofs: true,22includeDirs: [path.join(__dirname, 'protos/proto')],23});24const proto = grpc.loadPackageDefinition(packageDefinition) as any;25const LedgerService = proto.sui.rpc.v2.LedgerService;2627// Create gRPC client with TLS28const client = new LedgerService(endpoint, grpc.credentials.createSsl());2930// Metadata for authentication31const metadata = new grpc.Metadata();32metadata.add('x-token', token);3334// Request setup35const request = {36digests: ['HjuLoCGjS4wBC5KfqmExUa7GcF3yzaWRN1YoYpgxQC6G'], // Replace with valid digests37read_mask: {38paths: ['digest', 'transaction', 'effects', 'events'], // FieldMask39},40};4142// Invoke BatchGetTransactions43client.BatchGetTransactions(request, metadata, (err: grpc.ServiceError | null, response: any) => {44if (err) {45console.error('gRPC Error:', {46code: err.code,47message: err.message,48details: err.details,49});50} else {51console.log('BatchGetTransactions Response:');52console.log(JSON.stringify(response, null, 2));53}54});55
1import grpc2import json3from google.protobuf.field_mask_pb2 import FieldMask4from google.protobuf.json_format import MessageToDict5from sui.rpc.v2 import ledger_service_pb2, ledger_service_pb2_grpc678def get_batch_transactions():9# Quicknode endpoints consist of two crucial components: the endpoint name and the corresponding token10# For eg: QN Endpoint: https://docs-demo.sui-mainnet.quiknode.pro/abcde12345678911# endpoint will be: docs-demo.sui-mainnet.quiknode.pro:9000 {9000 is the port number for Sui gRPC}12# token will be: abcde1234567891314endpoint = 'docs-demo.sui-mainnet.quiknode.pro:9000';15token = 'abcde123456789';1617channel = grpc.secure_channel(endpoint, grpc.ssl_channel_credentials())18stub = ledger_service_pb2_grpc.LedgerServiceStub(channel)1920tx_digests = [21"HjuLoCGjS4wBC5KfqmExUa7GcF3yzaWRN1YoYpgxQC6G"22]2324read_mask = FieldMask(paths=[25"digest",26"transaction",27"effects",28"events"29])3031request = ledger_service_pb2.BatchGetTransactionsRequest(32digests=tx_digests,33read_mask=read_mask34)3536metadata = [("x-token", token)]3738return stub.BatchGetTransactions(request, metadata=metadata)394041def parse_response_to_json(response):42return json.dumps(43MessageToDict(response, preserving_proto_field_name=True),44indent=245)464748def main():49try:50response = get_batch_transactions()51print(parse_response_to_json(response))52except grpc.RpcError as e:53print(f"{e.code().name}: {e.details()}")545556if __name__ == "__main__":57main()58
1import grpc2import json3from google.protobuf.field_mask_pb2 import FieldMask4from google.protobuf.json_format import MessageToDict5from sui.rpc.v2 import ledger_service_pb2, ledger_service_pb2_grpc678def get_batch_transactions():9# Quicknode endpoints consist of two crucial components: the endpoint name and the corresponding token10# For eg: QN Endpoint: https://docs-demo.sui-mainnet.quiknode.pro/abcde12345678911# endpoint will be: docs-demo.sui-mainnet.quiknode.pro:9000 {9000 is the port number for Sui gRPC}12# token will be: abcde1234567891314endpoint = 'docs-demo.sui-mainnet.quiknode.pro:9000';15token = 'abcde123456789';1617channel = grpc.secure_channel(endpoint, grpc.ssl_channel_credentials())18stub = ledger_service_pb2_grpc.LedgerServiceStub(channel)1920tx_digests = [21"HjuLoCGjS4wBC5KfqmExUa7GcF3yzaWRN1YoYpgxQC6G"22]2324read_mask = FieldMask(paths=[25"digest",26"transaction",27"effects",28"events"29])3031request = ledger_service_pb2.BatchGetTransactionsRequest(32digests=tx_digests,33read_mask=read_mask34)3536metadata = [("x-token", token)]3738return stub.BatchGetTransactions(request, metadata=metadata)394041def parse_response_to_json(response):42return json.dumps(43MessageToDict(response, preserving_proto_field_name=True),44indent=245)464748def main():49try:50response = get_batch_transactions()51print(parse_response_to_json(response))52except grpc.RpcError as e:53print(f"{e.code().name}: {e.details()}")545556if __name__ == "__main__":57main()58