ExecuteTransaction gRPC Method
参数
交易
对象
必填
正在加载...
签名
数组
正在加载...
read_mask
对象
正在加载...
退货
最终性
对象
正在加载...
certified
对象
正在加载...
checkpointed
字符串
正在加载...
quorumExecuted
对象
正在加载...
交易
对象
正在加载...
摘要
字符串
正在加载...
交易
对象
正在加载...
签名
数组
正在加载...
效果
对象
正在加载...
活动
对象
正在加载...
checkpoint
字符串
正在加载...
时间戳
字符串
正在加载...
balanceChanges
数组
正在加载...
inputObjects
数组
正在加载...
outputObjects
数组
正在加载...
请求
1grpcurl \2-import-path . \3-proto sui/rpc/v2/transaction_execution_service.proto \4-H "x-token: YOUR_TOKEN_VALUE" \5-d '{6"transaction": {7"bcs": "BASE64_ENCODED_TX"8},9"options": {10"show_input": true,11"show_effects": true,12"show_events": true,13"show_object_changes": true,14"show_balance_changes": true15}16}' \17docs-demo.mainnet.quiknode.pro:9000 \18sui.rpc.v2.TransactionExecutionService/ExecuteTransaction19
1grpcurl \2-import-path . \3-proto sui/rpc/v2/transaction_execution_service.proto \4-H "x-token: YOUR_TOKEN_VALUE" \5-d '{6"transaction": {7"bcs": "BASE64_ENCODED_TX"8},9"options": {10"show_input": true,11"show_effects": true,12"show_events": true,13"show_object_changes": true,14"show_balance_changes": true15}16}' \17docs-demo.mainnet.quiknode.pro:9000 \18sui.rpc.v2.TransactionExecutionService/ExecuteTransaction19
1包 main23import (4"上下文"5"crypto/tls"6"encoding/json"7"fmt"8“日志”9“时间”1011"google.golang.grpc"12"google.golang.grpc"13"google.golang.org/protobuf/encoding/protojson"14"google.golang.org/protobuf/types/known/fieldmaskpb"1516pb "sui" // 您生成的 .pb.go 文件路径17)1819var (20token = "您的令牌编号"21endpoint = "您的QN端点:9000"22)2324// x-token Auth implementation25类型 auth 结构体 {26token 字符串27}2829func (a *auth) GetRequestMetadata(ctx 上下文.Context, uri ...字符串) (map[字符串]字符串, error) {30return map[string]string{"x-token": a.token}, nil31}32func (a *auth) RequireTransportSecurity() bool {33返回 true34}3536func main() {37creds := credentials.NewTLS(&tls.Config{})38opts := []grpc.DialOption{39grpc.WithTransportCredentials(creds),40grpc.WithPerRPCCredentials(&auth{令牌}),41}4243conn, err := grpc.Dial(endpoint, opts...)44如果 err != nil {45log.Fatalf("连接失败:%v", err)46}47推迟 conn.关闭()4849client := pb.NewTransactionExecutionServiceClient(conn)5051bcsTx := []byte("YOUR_BCS_SERIALIZED_TX_BYTES")5253sig := &pb.UserSignature{54Scheme: pb.SignatureScheme_ED25519,55Signature: []byte("YOUR_SIGNATURE_BYTES"),56PublicKey: []byte("YOUR_PUBLIC_KEY_BYTES"),57}5859// ReadMask specifies what response fields to return60readMask := &fieldmaskpb.FieldMask{61Paths: []string{"transaction", "finality"},62}6364// Build request65req := &pb.ExecuteTransactionRequest{66Transaction: &pb.Transaction{67Bcs: &pb.Bcs{68Bytes: bcsTx,69},70},71Signatures: []*pb.UserSignature{sig},72ReadMask: readMask,73}7475// Context with timeout76ctx, 取消 := context.带超时(context.Background(), 10*时间.第二次)77推迟 取消()7879resp, err := client.ExecuteTransaction(ctx, req)80如果 err != nil {81log.Fatalf("ExecuteTransaction failed: %v", err)82}8384// Marshal response to pretty JSON85marshaler := protojson.MarshalOptions{86UseProtoNames: true,87EmitUnpopulated: true,88缩进: " ",89}90jsonBytes, err := marshaler.Marshal(resp)91如果 err != nil {92log.Fatalf("Failed to marshal response: %v", err)93}9495// Print result96var pretty map[字符串]接口{}97if err := json.Unmarshal(jsonBytes, &pretty); err != nil {98log.Fatalf(“无法解析 JSON:%v”, err)99}100output, _ := json.MarshalIndent(pretty, "", " ")101fmt.Println(string(output))102}103
1包 main23import (4"上下文"5"crypto/tls"6"encoding/json"7"fmt"8“日志”9“时间”1011"google.golang.grpc"12"google.golang.grpc"13"google.golang.org/protobuf/encoding/protojson"14"google.golang.org/protobuf/types/known/fieldmaskpb"1516pb "sui" // 您生成的 .pb.go 文件路径17)1819var (20token = "您的令牌编号"21endpoint = "您的QN端点:9000"22)2324// x-token Auth implementation25类型 auth 结构体 {26token 字符串27}2829func (a *auth) GetRequestMetadata(ctx 上下文.Context, uri ...字符串) (map[字符串]字符串, error) {30return map[string]string{"x-token": a.token}, nil31}32func (a *auth) RequireTransportSecurity() bool {33返回 true34}3536func main() {37creds := credentials.NewTLS(&tls.Config{})38opts := []grpc.DialOption{39grpc.WithTransportCredentials(creds),40grpc.WithPerRPCCredentials(&auth{令牌}),41}4243conn, err := grpc.Dial(endpoint, opts...)44如果 err != nil {45log.Fatalf("连接失败:%v", err)46}47推迟 conn.关闭()4849client := pb.NewTransactionExecutionServiceClient(conn)5051bcsTx := []byte("YOUR_BCS_SERIALIZED_TX_BYTES")5253sig := &pb.UserSignature{54Scheme: pb.SignatureScheme_ED25519,55Signature: []byte("YOUR_SIGNATURE_BYTES"),56PublicKey: []byte("YOUR_PUBLIC_KEY_BYTES"),57}5859// ReadMask specifies what response fields to return60readMask := &fieldmaskpb.FieldMask{61Paths: []string{"transaction", "finality"},62}6364// Build request65req := &pb.ExecuteTransactionRequest{66Transaction: &pb.Transaction{67Bcs: &pb.Bcs{68Bytes: bcsTx,69},70},71Signatures: []*pb.UserSignature{sig},72ReadMask: readMask,73}7475// Context with timeout76ctx, 取消 := context.带超时(context.Background(), 10*时间.第二次)77推迟 取消()7879resp, err := client.ExecuteTransaction(ctx, req)80如果 err != nil {81log.Fatalf("ExecuteTransaction failed: %v", err)82}8384// Marshal response to pretty JSON85marshaler := protojson.MarshalOptions{86UseProtoNames: true,87EmitUnpopulated: true,88缩进: " ",89}90jsonBytes, err := marshaler.Marshal(resp)91如果 err != nil {92log.Fatalf("Failed to marshal response: %v", err)93}9495// Print result96var pretty map[字符串]接口{}97if err := json.Unmarshal(jsonBytes, &pretty); err != nil {98log.Fatalf(“无法解析 JSON:%v”, err)99}100output, _ := json.MarshalIndent(pretty, "", " ")101fmt.Println(string(output))102}103
1import * 作为 grpc from grpc;2import * 作为 protoLoader from grpc;3import * 作为 路径 from '路径';45// Quicknode endpoints consist of two crucial components: the endpoint name and the corresponding token6// For eg: QN Endpoint: https://docs-demo.sui-mainnet.quiknode.pro/abcde1234567897// endpoint will be: docs-demo.sui-mainnet.quiknode.pro:9000 {9000 is the port number for Sui gRPC}8// token will be : abcde123456789910const endpoint = 'docs-demo.mainnet.quiknode.pro:9000';11const 令牌 = 'abcde123456789';1213const PROTO_PATH = path.join(__dirname, 'protos/proto/sui/rpc/v2/transaction_execution_service.proto');1415// Load protobuf definitions16const 包定义 = protoLoader.loadSync(PROTO_PATH, {17keepCase: true,18多头: 字符串,19枚举: 字符串,20默认值: true,21oneofs: true,22includeDirs: [路径.join(__dirname, 'protos/proto')],23});2425const proto = grpc.loadPackageDefinition(packageDefinition) 作为 any;26const TransactionExecutionService = proto.sui.rpc.v2.TransactionExecutionService;2728// Create secure client29const client = new TransactionExecutionService(endpoint, grpc.credentials.createSsl());3031// Prepare metadata32const 元数据 = new grpc.元数据();33元数据.添加('x-token', token);3435// Placeholder request36const 请求 = {37transaction: {38bcs: {39字节: 缓冲区.来自('YOUR_BCS_SERIALIZED_TX_BYTES', 'base64') // 替换为实际的字节数40}41},42签名: [43{44方案: 0, // 通常 0 = ED2551945签名: 缓冲区.来源('YOUR_SIGNATURE_BYTES', 'base64'), // 替换为实际字节46公钥: 缓冲区.来自('YOUR_PUBLIC_KEY_BYTES', 'base64') // 替换为实际的字节数组47}48],49read_mask: {50paths: ['transaction', 'finality']51}52};5354// Call ExecuteTransaction55client.ExecuteTransaction(request, metadata, (err: grpc.ServiceError | null, response: any) => {56如果 (err) {57console.error('gRPC Error:', err.message);58console.error('Details:', err.details);59} else {60console.log('Response:', JSON.stringify(response, null, 2));61}62});63
1import * 作为 grpc from grpc;2import * 作为 protoLoader from grpc;3import * 作为 路径 from '路径';45// Quicknode endpoints consist of two crucial components: the endpoint name and the corresponding token6// For eg: QN Endpoint: https://docs-demo.sui-mainnet.quiknode.pro/abcde1234567897// endpoint will be: docs-demo.sui-mainnet.quiknode.pro:9000 {9000 is the port number for Sui gRPC}8// token will be : abcde123456789910const endpoint = 'docs-demo.mainnet.quiknode.pro:9000';11const 令牌 = 'abcde123456789';1213const PROTO_PATH = path.join(__dirname, 'protos/proto/sui/rpc/v2/transaction_execution_service.proto');1415// Load protobuf definitions16const 包定义 = protoLoader.loadSync(PROTO_PATH, {17keepCase: true,18多头: 字符串,19枚举: 字符串,20默认值: true,21oneofs: true,22includeDirs: [路径.join(__dirname, 'protos/proto')],23});2425const proto = grpc.loadPackageDefinition(packageDefinition) 作为 any;26const TransactionExecutionService = proto.sui.rpc.v2.TransactionExecutionService;2728// Create secure client29const client = new TransactionExecutionService(endpoint, grpc.credentials.createSsl());3031// Prepare metadata32const 元数据 = new grpc.元数据();33元数据.添加('x-token', token);3435// Placeholder request36const 请求 = {37transaction: {38bcs: {39字节: 缓冲区.来自('YOUR_BCS_SERIALIZED_TX_BYTES', 'base64') // 替换为实际的字节数40}41},42签名: [43{44方案: 0, // 通常 0 = ED2551945签名: 缓冲区.来源('YOUR_SIGNATURE_BYTES', 'base64'), // 替换为实际字节46公钥: 缓冲区.来自('YOUR_PUBLIC_KEY_BYTES', 'base64') // 替换为实际的字节数组47}48],49read_mask: {50paths: ['transaction', 'finality']51}52};5354// Call ExecuteTransaction55client.ExecuteTransaction(request, metadata, (err: grpc.ServiceError | null, response: any) => {56如果 (err) {57console.error('gRPC Error:', err.message);58console.error('Details:', err.details);59} else {60console.log('Response:', JSON.stringify(response, null, 2));61}62});63
1import grpc2导入 json3来源 谷歌.protobuf.field_mask_pb2 导入 FieldMask4来源 谷歌.protobuf.json_format import MessageToDict5from sui.rpc.v2 import (6transaction_execution_service_pb2,7transaction_execution_service_pb2_grpc,8transaction_pb2,9signature_pb2,10bcs_pb211)1213#Quicknode 由两个关键组成部分构成:endpoint 和相应的令牌14# 例如:QNEndpoint:mainnet15# endpoint will be: docs-demo.sui-mainnet.quiknode.pro:9000 {9000 is the port number for Sui gRPC}16# 令牌将为:abcde1234567891718endpoint = 'docs-demo.sui-mainnet.quiknode.pro:9000';19token = 'abcde123456789';2021def execute_transaction():22频道 = grpc.secure_channel(endpoint, grpc.ssl_channel_credentials())23stub = transaction_execution_service_pb2_grpc.TransactionExecutionServiceStub(channel)2425# === PLACEHOLDER: BCS-serialized transaction ===26transaction = transaction_pb2.Transaction(27bcs=bcs_pb2.Bcs(28bytes=b"YOUR_BCS_SERIALIZED_TX_BYTES"29)30)3132signature = signature_pb2.UserSignature(33scheme=0, # e.g., 0 = ED2551934signature=b"YOUR_SIGNATURE_BYTES",35public_key=b"YOUR_PUBLIC_KEY_BYTES"36)3738read_mask = FieldMask(paths=["transaction", "finality"])3940request = transaction_execution_service_pb2.ExecuteTransactionRequest(41transaction=transaction,42signatures=[signature],43read_mask=read_mask44)4546元数据 = [("x-token", token)]4748试一试:49response = stub.ExecuteTransaction(request, metadata=metadata)50return MessageToDict(response, preserving_proto_field_name=True)51除了 grpc。RpcError 作为 e:52return {53"error": e.code().name,54"details": e.details()55}565758def main():59result = execute_transaction()60print(json.dumps(result, indent=2))616263如果 __name__ == "__main__":64主()65
1import grpc2导入 json3来源 谷歌.protobuf.field_mask_pb2 导入 FieldMask4来源 谷歌.protobuf.json_format import MessageToDict5from sui.rpc.v2 import (6transaction_execution_service_pb2,7transaction_execution_service_pb2_grpc,8transaction_pb2,9signature_pb2,10bcs_pb211)1213#Quicknode 由两个关键组成部分构成:endpoint 和相应的令牌14# 例如:QNEndpoint:mainnet15# endpoint will be: docs-demo.sui-mainnet.quiknode.pro:9000 {9000 is the port number for Sui gRPC}16# 令牌将为:abcde1234567891718endpoint = 'docs-demo.sui-mainnet.quiknode.pro:9000';19token = 'abcde123456789';2021def execute_transaction():22频道 = grpc.secure_channel(endpoint, grpc.ssl_channel_credentials())23stub = transaction_execution_service_pb2_grpc.TransactionExecutionServiceStub(channel)2425# === PLACEHOLDER: BCS-serialized transaction ===26transaction = transaction_pb2.Transaction(27bcs=bcs_pb2.Bcs(28bytes=b"YOUR_BCS_SERIALIZED_TX_BYTES"29)30)3132signature = signature_pb2.UserSignature(33scheme=0, # e.g., 0 = ED2551934signature=b"YOUR_SIGNATURE_BYTES",35public_key=b"YOUR_PUBLIC_KEY_BYTES"36)3738read_mask = FieldMask(paths=["transaction", "finality"])3940request = transaction_execution_service_pb2.ExecuteTransactionRequest(41transaction=transaction,42signatures=[signature],43read_mask=read_mask44)4546元数据 = [("x-token", token)]4748试一试:49response = stub.ExecuteTransaction(request, metadata=metadata)50return MessageToDict(response, preserving_proto_field_name=True)51除了 grpc。RpcError 作为 e:52return {53"error": e.code().name,54"details": e.details()55}565758def main():59result = execute_transaction()60print(json.dumps(result, indent=2))616263如果 __name__ == "__main__":64主()65