ExecuteTransaction gRPC Method
參數
transaction
物件
必填
載入中...
簽名
陣列
載入中...
read_mask
物件
載入中...
退貨
finality
物件
載入中...
certified
物件
載入中...
checkpointed
字串
載入中...
quorumExecuted
物件
載入中...
transaction
物件
載入中...
digest
字串
載入中...
transaction
物件
載入中...
簽名
陣列
載入中...
effects
物件
載入中...
events
物件
載入中...
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.sui-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.sui-mainnet.quiknode.pro:9000 \18sui.rpc.v2.TransactionExecutionService/ExecuteTransaction19
1套件 主函式23匯入 (4"上下文"5"crypto/tls"6"encoding/json"7"fmt"8"log"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-grpc/sui/rpc/v2" // Your Generated .pb.go files path17)1819var (20token = "YOUR_TOKEN_NUMBER"21endpoint = "YOUR_QN_ENDPOINT:9000"22)2324// x-token Auth implementation25類型 auth 結構體 {26代幣 字串27}2829func (a *auth) GetRequestMetadata(ctx 上下文.Context, uri ...字串) (map[字串]字串, 錯誤) {30return map[string]string{"x-token": a.token}, nil31}32func (a *auth) RequireTransportSecurity() bool {33return true34}3536func main() {37creds := credentials.NewTLS(&tls.Config{})38opts := []grpc.DialOption{39grpc.WithTransportCredentials(creds),40grpc.WithPerRPC憑證(&auth{token}),41}4243conn, err := grpc.撥號(endpoint, opts...)44如果 err != nil {45log.Fatalf("Failed to connect: %v", err)46}47延後 延遲連接.關閉()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.WithTimeout(context.背景(), 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,88Indent: " ",89}90jsonBytes, err := marshaler.Marshal(resp)91如果 err != nil {92log.Fatalf("Failed to marshal response: %v", err)93}9495// Print result96var pretty map[string]interface{}97if err := json.Unmarshal(jsonBytes, &pretty); err != nil {98log.Fatalf("Failed to parse JSON: %v", err)99}100output, _ := json.MarshalIndent(pretty, "", " ")101fmt.Println(string(output))102}103
1套件 主函式23匯入 (4"上下文"5"crypto/tls"6"encoding/json"7"fmt"8"log"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-grpc/sui/rpc/v2" // Your Generated .pb.go files path17)1819var (20token = "YOUR_TOKEN_NUMBER"21endpoint = "YOUR_QN_ENDPOINT:9000"22)2324// x-token Auth implementation25類型 auth 結構體 {26代幣 字串27}2829func (a *auth) GetRequestMetadata(ctx 上下文.Context, uri ...字串) (map[字串]字串, 錯誤) {30return map[string]string{"x-token": a.token}, nil31}32func (a *auth) RequireTransportSecurity() bool {33return true34}3536func main() {37creds := credentials.NewTLS(&tls.Config{})38opts := []grpc.DialOption{39grpc.WithTransportCredentials(creds),40grpc.WithPerRPC憑證(&auth{token}),41}4243conn, err := grpc.撥號(endpoint, opts...)44如果 err != nil {45log.Fatalf("Failed to connect: %v", err)46}47延後 延遲連接.關閉()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.WithTimeout(context.背景(), 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,88Indent: " ",89}90jsonBytes, err := marshaler.Marshal(resp)91如果 err != nil {92log.Fatalf("Failed to marshal response: %v", err)93}9495// Print result96var pretty map[string]interface{}97if err := json.Unmarshal(jsonBytes, &pretty); err != nil {98log.Fatalf("Failed to parse JSON: %v", err)99}100output, _ := json.MarshalIndent(pretty, "", " ")101fmt.Println(string(output))102}103
1import * as grpc from '@grpc/grpc-js';2import * as protoLoader from '@grpc/proto-loader';3import * as path from 'path';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.sui-mainnet.quiknode.pro:9000';11const token = 'abcde123456789';1213const PROTO_PATH = path.join(__dirname, 'protos/proto/sui/rpc/v2/transaction_execution_service.proto');1415// Load protobuf definitions16const packageDefinition = protoLoader.loadSync(PROTO_PATH, {17keepCase: true,18longs: String,19enums: String,20defaults: true,21oneofs: true,22includeDirs: [path.join(__dirname, 'protos/proto')],23});2425const proto = grpc.loadPackageDefinition(packageDefinition) as any;26const TransactionExecutionService = proto.sui.rpc.v2.TransactionExecutionService;2728// Create secure client29const client = new TransactionExecutionService(endpoint, grpc.credentials.createSsl());3031// Prepare metadata32const metadata = new grpc.Metadata();33metadata.add('x-token', token);3435// Placeholder request36const request = {37transaction: {38bcs: {39bytes: Buffer.from('YOUR_BCS_SERIALIZED_TX_BYTES', 'base64') // Replace with actual bytes40}41},42signatures: [43{44scheme: 0, // Usually 0 = ED2551945signature: Buffer.from('YOUR_SIGNATURE_BYTES', 'base64'), // Replace with actual bytes46public_key: Buffer.from('YOUR_PUBLIC_KEY_BYTES', 'base64') // Replace with actual bytes47}48],49read_mask: {50paths: ['transaction', 'finality']51}52};5354// Call ExecuteTransaction55client.ExecuteTransaction(request, metadata, (err: grpc.ServiceError | null, response: any) => {56if (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 * as grpc from '@grpc/grpc-js';2import * as protoLoader from '@grpc/proto-loader';3import * as path from 'path';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.sui-mainnet.quiknode.pro:9000';11const token = 'abcde123456789';1213const PROTO_PATH = path.join(__dirname, 'protos/proto/sui/rpc/v2/transaction_execution_service.proto');1415// Load protobuf definitions16const packageDefinition = protoLoader.loadSync(PROTO_PATH, {17keepCase: true,18longs: String,19enums: String,20defaults: true,21oneofs: true,22includeDirs: [path.join(__dirname, 'protos/proto')],23});2425const proto = grpc.loadPackageDefinition(packageDefinition) as any;26const TransactionExecutionService = proto.sui.rpc.v2.TransactionExecutionService;2728// Create secure client29const client = new TransactionExecutionService(endpoint, grpc.credentials.createSsl());3031// Prepare metadata32const metadata = new grpc.Metadata();33metadata.add('x-token', token);3435// Placeholder request36const request = {37transaction: {38bcs: {39bytes: Buffer.from('YOUR_BCS_SERIALIZED_TX_BYTES', 'base64') // Replace with actual bytes40}41},42signatures: [43{44scheme: 0, // Usually 0 = ED2551945signature: Buffer.from('YOUR_SIGNATURE_BYTES', 'base64'), // Replace with actual bytes46public_key: Buffer.from('YOUR_PUBLIC_KEY_BYTES', 'base64') // Replace with actual bytes47}48],49read_mask: {50paths: ['transaction', 'finality']51}52};5354// Call ExecuteTransaction55client.ExecuteTransaction(request, metadata, (err: grpc.ServiceError | null, response: any) => {56if (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匯入 json3from google.protobuf.field_mask_pb2 import FieldMask4from google.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 endpoints consist of two crucial components: the endpoint name and the corresponding token14# For eg: QN Endpoint: https://docs-demo.sui-mainnet.quiknode.pro/abcde12345678915# endpoint will be: docs-demo.sui-mainnet.quiknode.pro:9000 {9000 is the port number for Sui gRPC}16# token will be: abcde1234567891718endpoint = 'docs-demo.sui-mainnet.quiknode.pro:9000';19token = 'abcde123456789';2021def execute_transaction():22channel = 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)4546metadata = [("x-token", token)]4748try:49response = stub.ExecuteTransaction(request, metadata=metadata)50return MessageToDict(response, preserving_proto_field_name=True)51except grpc.RpcError as e:52return {53"error": e.code().name,54"details": e.details()55}565758def main():59result = execute_transaction()60print(json.dumps(result, indent=2))616263if __name__ == "__main__":64main()65
1import grpc2匯入 json3from google.protobuf.field_mask_pb2 import FieldMask4from google.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 endpoints consist of two crucial components: the endpoint name and the corresponding token14# For eg: QN Endpoint: https://docs-demo.sui-mainnet.quiknode.pro/abcde12345678915# endpoint will be: docs-demo.sui-mainnet.quiknode.pro:9000 {9000 is the port number for Sui gRPC}16# token will be: abcde1234567891718endpoint = 'docs-demo.sui-mainnet.quiknode.pro:9000';19token = 'abcde123456789';2021def execute_transaction():22channel = 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)4546metadata = [("x-token", token)]4748try:49response = stub.ExecuteTransaction(request, metadata=metadata)50return MessageToDict(response, preserving_proto_field_name=True)51except grpc.RpcError as e:52return {53"error": e.code().name,54"details": e.details()55}565758def main():59result = execute_transaction()60print(json.dumps(result, indent=2))616263if __name__ == "__main__":64main()65