ExecuteTransaction gRPC Method
Parameters
transaction
object
REQUIRED
Loading...
signatures
array
Loading...
read_mask
object
Loading...
Returns
finality
object
Loading...
certified
object
Loading...
checkpointed
string
Loading...
quorumExecuted
object
Loading...
transaction
object
Loading...
digest
string
Loading...
transaction
object
Loading...
signatures
array
Loading...
effects
object
Loading...
events
object
Loading...
checkpoint
string
Loading...
timestamp
string
Loading...
balanceChanges
array
Loading...
inputObjects
array
Loading...
outputObjects
array
Loading...
Request
grpcurl \ -import-path . \ -proto sui/rpc/v2beta2/transaction_execution_service.proto \ -H "x-token: YOUR_TOKEN_VALUE" \ -d '{ "transaction": { "bcs": "BASE64_ENCODED_TX" }, "options": { "show_input": true, "show_effects": true, "show_events": true, "show_object_changes": true, "show_balance_changes": true } }' \ docs-demo.sui-mainnet.quiknode.pro:9000 \ sui.rpc.v2beta2.TransactionExecutionService/ExecuteTransaction
package main import ( "context" "crypto/tls" "encoding/json" "fmt" "log" "time" "google.golang.org/grpc" "google.golang.org/grpc/credentials" "google.golang.org/protobuf/encoding/protojson" "google.golang.org/protobuf/types/known/fieldmaskpb" pb "sui-grpc/sui/rpc/v2beta2" // Your Generated .pb.go files path ) var ( token = "YOUR_TOKEN_NUMBER" endpoint = "YOUR_QN_ENDPOINT:9000" ) // x-token Auth implementation type auth struct { token string } func (a *auth) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error) { return map[string]string{"x-token": a.token}, nil } func (a *auth) RequireTransportSecurity() bool { return true } func main() { creds := credentials.NewTLS(&tls.Config{}) opts := []grpc.DialOption{ grpc.WithTransportCredentials(creds), grpc.WithPerRPCCredentials(&auth{token}), } conn, err := grpc.Dial(endpoint, opts...) if err != nil { log.Fatalf("Failed to connect: %v", err) } defer conn.Close() client := pb.NewTransactionExecutionServiceClient(conn) bcsTx := []byte("YOUR_BCS_SERIALIZED_TX_BYTES") sig := &pb.UserSignature{ Scheme: pb.SignatureScheme_ED25519, Signature: []byte("YOUR_SIGNATURE_BYTES"), PublicKey: []byte("YOUR_PUBLIC_KEY_BYTES"), } // ReadMask specifies what response fields to return readMask := &fieldmaskpb.FieldMask{ Paths: []string{"transaction", "finality"}, } // Build request req := &pb.ExecuteTransactionRequest{ Transaction: &pb.Transaction{ Bcs: &pb.Bcs{ Bytes: bcsTx, }, }, Signatures: []*pb.UserSignature{sig}, ReadMask: readMask, } // Context with timeout ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) defer cancel() resp, err := client.ExecuteTransaction(ctx, req) if err != nil { log.Fatalf("ExecuteTransaction failed: %v", err) } // Marshal response to pretty JSON marshaler := protojson.MarshalOptions{ UseProtoNames: true, EmitUnpopulated: true, Indent: " ", } jsonBytes, err := marshaler.Marshal(resp) if err != nil { log.Fatalf("Failed to marshal response: %v", err) } // Print result var pretty map[string]interface{} if err := json.Unmarshal(jsonBytes, &pretty); err != nil { log.Fatalf("Failed to parse JSON: %v", err) } output, _ := json.MarshalIndent(pretty, "", " ") fmt.Println(string(output)) }
import * as grpc from '@grpc/grpc-js'; import * as protoLoader from '@grpc/proto-loader'; import * as path from 'path'; // QuickNode endpoints consist of two crucial components: the endpoint name and the corresponding token // For eg: QN Endpoint: https://docs-demo.sui-mainnet.quiknode.pro/abcde123456789 // endpoint will be: docs-demo.sui-mainnet.quiknode.pro:9000 {9000 is the port number for Sui gRPC} // token will be : abcde123456789 const endpoint = 'docs-demo.sui-mainnet.quiknode.pro:9000'; const token = 'abcde123456789'; const PROTO_PATH = path.join(__dirname, 'protos/proto/sui/rpc/v2beta2/transaction_execution_service.proto'); // Load protobuf definitions const packageDefinition = protoLoader.loadSync(PROTO_PATH, { keepCase: true, longs: String, enums: String, defaults: true, oneofs: true, includeDirs: [path.join(__dirname, 'protos/proto')], }); const proto = grpc.loadPackageDefinition(packageDefinition) as any; const TransactionExecutionService = proto.sui.rpc.v2beta2.TransactionExecutionService; // Create secure client const client = new TransactionExecutionService(endpoint, grpc.credentials.createSsl()); // Prepare metadata const metadata = new grpc.Metadata(); metadata.add('x-token', token); // Placeholder request const request = { transaction: { bcs: { bytes: Buffer.from('YOUR_BCS_SERIALIZED_TX_BYTES', 'base64') // Replace with actual bytes } }, signatures: [ { scheme: 0, // Usually 0 = ED25519 signature: Buffer.from('YOUR_SIGNATURE_BYTES', 'base64'), // Replace with actual bytes public_key: Buffer.from('YOUR_PUBLIC_KEY_BYTES', 'base64') // Replace with actual bytes } ], read_mask: { paths: ['transaction', 'finality'] } }; // Call ExecuteTransaction client.ExecuteTransaction(request, metadata, (err: grpc.ServiceError | null, response: any) => { if (err) { console.error('gRPC Error:', err.message); console.error('Details:', err.details); } else { console.log('Response:', JSON.stringify(response, null, 2)); } });
import grpc import json from google.protobuf.field_mask_pb2 import FieldMask from google.protobuf.json_format import MessageToDict from sui.rpc.v2beta2 import ( transaction_execution_service_pb2, transaction_execution_service_pb2_grpc, transaction_pb2, signature_pb2, bcs_pb2 ) # QuickNode endpoints consist of two crucial components: the endpoint name and the corresponding token # For eg: QN Endpoint: https://docs-demo.sui-mainnet.quiknode.pro/abcde123456789 # endpoint will be: docs-demo.sui-mainnet.quiknode.pro:9000 {9000 is the port number for Sui gRPC} # token will be: abcde123456789 endpoint = 'docs-demo.sui-mainnet.quiknode.pro:9000'; token = 'abcde123456789'; def execute_transaction(): channel = grpc.secure_channel(endpoint, grpc.ssl_channel_credentials()) stub = transaction_execution_service_pb2_grpc.TransactionExecutionServiceStub(channel) # === PLACEHOLDER: BCS-serialized transaction === transaction = transaction_pb2.Transaction( bcs=bcs_pb2.Bcs( bytes=b"YOUR_BCS_SERIALIZED_TX_BYTES" ) ) signature = signature_pb2.UserSignature( scheme=0, # e.g., 0 = ED25519 signature=b"YOUR_SIGNATURE_BYTES", public_key=b"YOUR_PUBLIC_KEY_BYTES" ) read_mask = FieldMask(paths=["transaction", "finality"]) request = transaction_execution_service_pb2.ExecuteTransactionRequest( transaction=transaction, signatures=[signature], read_mask=read_mask ) metadata = [("x-token", token)] try: response = stub.ExecuteTransaction(request, metadata=metadata) return MessageToDict(response, preserving_proto_field_name=True) except grpc.RpcError as e: return { "error": e.code().name, "details": e.details() } def main(): result = execute_transaction() print(json.dumps(result, indent=2)) if __name__ == "__main__": main()
Don't have an account yet?
Create your QuickNode endpoint in seconds and start building
Get started for free