GetTransaction gRPC Method
参数
digest
字符串
必填
正在加载...
read_mask
对象
正在加载...
paths
array<string>
正在加载...
退货
交易
对象
正在加载...
digest
字符串
正在加载...
交易
对象
正在加载...
bcs
对象
正在加载...
名称
字符串
正在加载...
值
字符串
正在加载...
digest
字符串
正在加载...
版本
整数
正在加载...
kind
对象
正在加载...
programmableTransaction
对象
正在加载...
inputs
数组
正在加载...
kind
字符串
正在加载...
objectId
字符串
正在加载...
版本
字符串
正在加载...
mutable
布尔型
正在加载...
pure
字符串
正在加载...
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
对象
正在加载...
eventsDigest
字符串
正在加载...
dependencies
数组
正在加载...
digest
字符串
正在加载...
lamportVersion
字符串
正在加载...
changedObjects
数组
正在加载...
unchangedConsensusObjects
数组
正在加载...
unchangedSharedObjects
数组
正在加载...
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"digest": "HjuLoCGjS4wBC5KfqmExUa7GcF3yzaWRN1YoYpgxQC6G",7"read_mask": {8"paths": [9"digest",10"transaction",11"effects",12"events"13]14}15}' \16docs-demo.sui-mainnet.quiknode.pro:9000 \17sui.rpc.v2.LedgerService/GetTransaction
1grpcurl \2-import-path . \3-proto sui/rpc/v2/ledger_service.proto \4-H "x-token: YOUR_TOKEN_VALUE" \5-d '{6"digest": "HjuLoCGjS4wBC5KfqmExUa7GcF3yzaWRN1YoYpgxQC6G",7"read_mask": {8"paths": [9"digest",10"transaction",11"effects",12"events"13]14}15}' \16docs-demo.sui-mainnet.quiknode.pro:9000 \17sui.rpc.v2.LedgerService/GetTransaction
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 credentials46creds := 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)5960txDigest := "HjuLoCGjS4wBC5KfqmExUa7GcF3yzaWRN1YoYpgxQC6G"6162fieldMask := &fieldmaskpb.FieldMask{63Paths: []string{"events", "effects"},64}6566req := &pb.GetTransactionRequest{67Digest: &txDigest,68ReadMask: fieldMask,69}7071ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)72defer cancel()7374resp, err := client.GetTransaction(ctx, req)75如果 err != nil {76log.Fatalf("GetTransaction failed: %v", err)77}7879marshaler := protojson.MarshalOptions{80UseProtoNames: true,81EmitUnpopulated: true,82Indent: " ",83}8485jsonBytes, err := marshaler.Marshal(resp)86如果 err != nil {87log.Fatalf("Failed to marshal response to JSON: %v", err)88}8990var prettyJSON map[string]interface{}91if err := json.Unmarshal(jsonBytes, &prettyJSON); err != nil {92log.Fatalf("Failed to unmarshal JSON: %v", err)93}9495prettyJSONBytes, err := json.MarshalIndent(prettyJSON, "", " ")96如果 err != nil {97log.Fatalf("Failed to format JSON: %v", err)98}99100fmt.Println(string(prettyJSONBytes))101}102
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 credentials46creds := 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)5960txDigest := "HjuLoCGjS4wBC5KfqmExUa7GcF3yzaWRN1YoYpgxQC6G"6162fieldMask := &fieldmaskpb.FieldMask{63Paths: []string{"events", "effects"},64}6566req := &pb.GetTransactionRequest{67Digest: &txDigest,68ReadMask: fieldMask,69}7071ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)72defer cancel()7374resp, err := client.GetTransaction(ctx, req)75如果 err != nil {76log.Fatalf("GetTransaction failed: %v", err)77}7879marshaler := protojson.MarshalOptions{80UseProtoNames: true,81EmitUnpopulated: true,82Indent: " ",83}8485jsonBytes, err := marshaler.Marshal(resp)86如果 err != nil {87log.Fatalf("Failed to marshal response to JSON: %v", err)88}8990var prettyJSON map[string]interface{}91if err := json.Unmarshal(jsonBytes, &prettyJSON); err != nil {92log.Fatalf("Failed to unmarshal JSON: %v", err)93}9495prettyJSONBytes, err := json.MarshalIndent(prettyJSON, "", " ")96如果 err != nil {97log.Fatalf("Failed to format JSON: %v", err)98}99100fmt.Println(string(prettyJSONBytes))101}102
1import * as grpc from '@grpc/grpc-js';2import * as protoLoader from '@grpc/proto-loader';3import * as path from 'path';45// Path to the proto file6const PROTO_PATH = path.join(__dirname, 'protos/proto/sui/rpc/v2/ledger_service.proto');78// Load the proto definition9const packageDefinition = protoLoader.loadSync(PROTO_PATH, {10keepCase: true,11longs: String,12enums: String,13defaults: true,14oneofs: true,15includeDirs: [path.join(__dirname, 'protos/proto')],16});1718const proto = grpc.loadPackageDefinition(packageDefinition) as any;19const LedgerService = proto.sui.rpc.v2.LedgerService;2021// Quicknode endpoints consist of two crucial components: the endpoint name and the corresponding token22// For eg: QN Endpoint: https://docs-demo.sui-mainnet.quiknode.pro/abcde12345678923// endpoint will be: docs-demo.sui-mainnet.quiknode.pro:9000 {9000 is the port number for Sui gRPC}24// token will be : abcde1234567892526const endpoint = 'docs-demo.sui-mainnet.quiknode.pro:9000';27const token = 'abcde123456789';2829// Create client with TLS30const client = new LedgerService(endpoint, grpc.credentials.createSsl());3132// Prepare metadata33const metadata = new grpc.Metadata();34metadata.add('x-token', token);3536// Replace this with your actual transaction digest37const txDigest = 'HjuLoCGjS4wBC5KfqmExUa7GcF3yzaWRN1YoYpgxQC6G';3839// Prepare request40const request = {41digest: txDigest,42read_mask: {43paths: ['digest', 'transaction', 'effects', 'events', 'timestamp'],44},45};4647// Make the call48client.GetTransaction(request, metadata, (err: any, response: any) => {49if (err) {50console.error('Error:', err);51} else {52console.log('Response:', 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';45// Path to the proto file6const PROTO_PATH = path.join(__dirname, 'protos/proto/sui/rpc/v2/ledger_service.proto');78// Load the proto definition9const packageDefinition = protoLoader.loadSync(PROTO_PATH, {10keepCase: true,11longs: String,12enums: String,13defaults: true,14oneofs: true,15includeDirs: [path.join(__dirname, 'protos/proto')],16});1718const proto = grpc.loadPackageDefinition(packageDefinition) as any;19const LedgerService = proto.sui.rpc.v2.LedgerService;2021// Quicknode endpoints consist of two crucial components: the endpoint name and the corresponding token22// For eg: QN Endpoint: https://docs-demo.sui-mainnet.quiknode.pro/abcde12345678923// endpoint will be: docs-demo.sui-mainnet.quiknode.pro:9000 {9000 is the port number for Sui gRPC}24// token will be : abcde1234567892526const endpoint = 'docs-demo.sui-mainnet.quiknode.pro:9000';27const token = 'abcde123456789';2829// Create client with TLS30const client = new LedgerService(endpoint, grpc.credentials.createSsl());3132// Prepare metadata33const metadata = new grpc.Metadata();34metadata.add('x-token', token);3536// Replace this with your actual transaction digest37const txDigest = 'HjuLoCGjS4wBC5KfqmExUa7GcF3yzaWRN1YoYpgxQC6G';3839// Prepare request40const request = {41digest: txDigest,42read_mask: {43paths: ['digest', 'transaction', 'effects', 'events', 'timestamp'],44},45};4647// Make the call48client.GetTransaction(request, metadata, (err: any, response: any) => {49if (err) {50console.error('Error:', err);51} else {52console.log('Response:', 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_transaction():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)1920# Specify the transaction digest you want to retrieve21# Replace with an actual Sui transaction digest22tx_digest = "HjuLoCGjS4wBC5KfqmExUa7GcF3yzaWRN1YoYpgxQC6G"2324# Create a field mask to specify which fields to include in the response25read_mask = FieldMask(paths=[26"digest",27"transaction",28"effects",29"events",30"timestamp"31])3233# Prepare the GetTransactionRequest34request = ledger_service_pb2.GetTransactionRequest(35digest=tx_digest,36read_mask=read_mask37)3839metadata = [("x-token", token)]4041return stub.GetTransaction(request, metadata=metadata)424344def parse_response_to_json(response):45return json.dumps(46MessageToDict(response, preserving_proto_field_name=True),47indent=248)495051def main():52try:53response = get_transaction()54print(parse_response_to_json(response))55except grpc.RpcError as e:56print(f"{e.code().name}: {e.details()}")575859if __name__ == "__main__":60main()61
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_transaction():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)1920# Specify the transaction digest you want to retrieve21# Replace with an actual Sui transaction digest22tx_digest = "HjuLoCGjS4wBC5KfqmExUa7GcF3yzaWRN1YoYpgxQC6G"2324# Create a field mask to specify which fields to include in the response25read_mask = FieldMask(paths=[26"digest",27"transaction",28"effects",29"events",30"timestamp"31])3233# Prepare the GetTransactionRequest34request = ledger_service_pb2.GetTransactionRequest(35digest=tx_digest,36read_mask=read_mask37)3839metadata = [("x-token", token)]4041return stub.GetTransaction(request, metadata=metadata)424344def parse_response_to_json(response):45return json.dumps(46MessageToDict(response, preserving_proto_field_name=True),47indent=248)495051def main():52try:53response = get_transaction()54print(parse_response_to_json(response))55except grpc.RpcError as e:56print(f"{e.code().name}: {e.details()}")575859if __name__ == "__main__":60main()61