SimulateTransaction gRPC Method
Parameters
transaction
object
REQUIRED
Loading...
read_mask
object
Loading...
checks
string
Loading...
do_gas_selection
boolean
Loading...
Returns
transaction
object
Loading...
digest
string
Loading...
transaction
object
Loading...
effects
object
Loading...
events
object
Loading...
timestamp
string
Loading...
outputs
array
Loading...
returnValues
array
Loading...
mutatedByRef
array
Loading...
Request
1grpcurl \2-import-path . \3-proto sui/rpc/v2beta2/live_data_service.proto \4-H "x-token: abcde123456789" \5-d '{6"transaction": {7"bcs": "BASE64_TX_BYTES",8"signatures": [9{10"scheme": "ED25519",11"signature": "BASE64_SIGNATURE",12"public_key": "BASE64_PUBLIC_KEY"13}14]15},16"read_mask": { "paths": ["transaction.effects", "transaction.events"] },17"checks": "ENABLED",18"do_gas_selection": true19}' \20docs-demo.sui-mainnet.quiknode.pro:9000 \21sui.rpc.v2beta2.LiveDataService/SimulateTransaction
1grpcurl \2-import-path . \3-proto sui/rpc/v2beta2/live_data_service.proto \4-H "x-token: abcde123456789" \5-d '{6"transaction": {7"bcs": "BASE64_TX_BYTES",8"signatures": [9{10"scheme": "ED25519",11"signature": "BASE64_SIGNATURE",12"public_key": "BASE64_PUBLIC_KEY"13}14]15},16"read_mask": { "paths": ["transaction.effects", "transaction.events"] },17"checks": "ENABLED",18"do_gas_selection": true19}' \20docs-demo.sui-mainnet.quiknode.pro:9000 \21sui.rpc.v2beta2.LiveDataService/SimulateTransaction
1package main23import (4"context"5"crypto/tls"6"encoding/json"7"fmt"8"log"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/v2beta2" // 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-token30type auth struct {31token string32}3334func (a *auth) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error) {35return map[string]string{"x-token": a.token}, nil36}37func (a *auth) RequireTransportSecurity() bool {38return true39}4041func main() {42creds := credentials.NewTLS(&tls.Config{})43opts := []grpc.DialOption{44grpc.WithTransportCredentials(creds),45grpc.WithPerRPCCredentials(&auth{token}),46}4748conn, err := grpc.Dial(endpoint, opts...)49if err != nil {50log.Fatalf("Failed to connect: %v", err)51}52defer conn.Close()5354client := pb.NewLiveDataServiceClient(conn)5556req := &pb.SimulateTransactionRequest{57Transaction: &pb.Transaction{58Bcs: &pb.BcsBytes{59Bytes: []byte("YOUR_BCS_SERIALIZED_TX_BYTES"), // Replace with actual bytes60},61},62Signatures: []*pb.Signature{63{64Scheme: 0, // ED2551965Signature: []byte("YOUR_SIGNATURE_BYTES"), // Replace with actual bytes66PublicKey: []byte("YOUR_PUBLIC_KEY_BYTES"), // Replace with actual bytes67},68},69ReadMask: &fieldmaskpb.FieldMask{70Paths: []string{71"effects",72"events",73},74},75}7677ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)78defer cancel()7980resp, err := client.SimulateTransaction(ctx, req)81if err != nil {82log.Fatalf("SimulateTransaction failed: %v", err)83}8485// Pretty print the response86marshaler := protojson.MarshalOptions{87UseProtoNames: true,88EmitUnpopulated: true,89Indent: " ",90}9192jsonBytes, err := marshaler.Marshal(resp)93if err != nil {94log.Fatalf("Failed to marshal: %v", err)95}9697var pretty map[string]interface{}98if err := json.Unmarshal(jsonBytes, &pretty); err != nil {99log.Fatalf("Failed to parse JSON: %v", err)100}101102out, _ := json.MarshalIndent(pretty, "", " ")103fmt.Println(string(out))104}105
1package main23import (4"context"5"crypto/tls"6"encoding/json"7"fmt"8"log"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/v2beta2" // 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-token30type auth struct {31token string32}3334func (a *auth) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error) {35return map[string]string{"x-token": a.token}, nil36}37func (a *auth) RequireTransportSecurity() bool {38return true39}4041func main() {42creds := credentials.NewTLS(&tls.Config{})43opts := []grpc.DialOption{44grpc.WithTransportCredentials(creds),45grpc.WithPerRPCCredentials(&auth{token}),46}4748conn, err := grpc.Dial(endpoint, opts...)49if err != nil {50log.Fatalf("Failed to connect: %v", err)51}52defer conn.Close()5354client := pb.NewLiveDataServiceClient(conn)5556req := &pb.SimulateTransactionRequest{57Transaction: &pb.Transaction{58Bcs: &pb.BcsBytes{59Bytes: []byte("YOUR_BCS_SERIALIZED_TX_BYTES"), // Replace with actual bytes60},61},62Signatures: []*pb.Signature{63{64Scheme: 0, // ED2551965Signature: []byte("YOUR_SIGNATURE_BYTES"), // Replace with actual bytes66PublicKey: []byte("YOUR_PUBLIC_KEY_BYTES"), // Replace with actual bytes67},68},69ReadMask: &fieldmaskpb.FieldMask{70Paths: []string{71"effects",72"events",73},74},75}7677ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)78defer cancel()7980resp, err := client.SimulateTransaction(ctx, req)81if err != nil {82log.Fatalf("SimulateTransaction failed: %v", err)83}8485// Pretty print the response86marshaler := protojson.MarshalOptions{87UseProtoNames: true,88EmitUnpopulated: true,89Indent: " ",90}9192jsonBytes, err := marshaler.Marshal(resp)93if err != nil {94log.Fatalf("Failed to marshal: %v", err)95}9697var pretty map[string]interface{}98if err := json.Unmarshal(jsonBytes, &pretty); err != nil {99log.Fatalf("Failed to parse JSON: %v", err)100}101102out, _ := json.MarshalIndent(pretty, "", " ")103fmt.Println(string(out))104}105
1import * as grpc from '@grpc/grpc-js';2import * as protoLoader from '@grpc/proto-loader';3import * as path from 'path';45// Configuration6const PROTO_PATH = path.join(__dirname, 'protos/proto/sui/rpc/v2beta2/live_data_service.proto');78// Quicknode endpoints consist of two crucial components: the endpoint name and the corresponding token9// For eg: QN Endpoint: https://docs-demo.sui-mainnet.quiknode.pro/abcde12345678910// endpoint will be: docs-demo.sui-mainnet.quiknode.pro:9000 {9000 is the port number for Sui gRPC}11// token will be : abcde1234567891213const endpoint = 'docs-demo.sui-mainnet.quiknode.pro:9000';14const token = 'abcde123456789';1516// Load protobuf definitions17const packageDefinition = protoLoader.loadSync(PROTO_PATH, {18keepCase: true,19longs: String,20enums: String,21defaults: true,22oneofs: true,23includeDirs: [path.join(__dirname, 'protos/proto')],24});2526const proto = grpc.loadPackageDefinition(packageDefinition) as any;27const LiveDataService = proto.sui.rpc.v2beta2.LiveDataService;2829// Create secure client30const client = new LiveDataService(endpoint, grpc.credentials.createSsl());3132// Add token metadata33const metadata = new grpc.Metadata();34metadata.add('x-token', token);3536// Request payload37const request = {38transaction: {39bcs: {40bytes: Buffer.from('YOUR_BCS_SERIALIZED_TX_BYTES', 'base64') // Replace with actual bytes41}42},43signatures: [44{45scheme: 0, // Usually 0 = ED2551946signature: Buffer.from('YOUR_SIGNATURE_BYTES', 'base64'), // Replace with actual bytes47public_key: Buffer.from('YOUR_PUBLIC_KEY_BYTES', 'base64') // Replace with actual bytes48}49],50read_mask: {51paths: ['effects', 'events']52}53};5455// Perform gRPC call56client.SimulateTransaction(request, metadata, (err: grpc.ServiceError | null, response: any) => {57if (err) {58console.error('gRPC Error:', {59code: err.code,60message: err.message,61details: err.details,62});63} else {64console.log('SimulateTransaction Response:');65console.log(JSON.stringify(response, null, 2));66}67});68
1import * as grpc from '@grpc/grpc-js';2import * as protoLoader from '@grpc/proto-loader';3import * as path from 'path';45// Configuration6const PROTO_PATH = path.join(__dirname, 'protos/proto/sui/rpc/v2beta2/live_data_service.proto');78// Quicknode endpoints consist of two crucial components: the endpoint name and the corresponding token9// For eg: QN Endpoint: https://docs-demo.sui-mainnet.quiknode.pro/abcde12345678910// endpoint will be: docs-demo.sui-mainnet.quiknode.pro:9000 {9000 is the port number for Sui gRPC}11// token will be : abcde1234567891213const endpoint = 'docs-demo.sui-mainnet.quiknode.pro:9000';14const token = 'abcde123456789';1516// Load protobuf definitions17const packageDefinition = protoLoader.loadSync(PROTO_PATH, {18keepCase: true,19longs: String,20enums: String,21defaults: true,22oneofs: true,23includeDirs: [path.join(__dirname, 'protos/proto')],24});2526const proto = grpc.loadPackageDefinition(packageDefinition) as any;27const LiveDataService = proto.sui.rpc.v2beta2.LiveDataService;2829// Create secure client30const client = new LiveDataService(endpoint, grpc.credentials.createSsl());3132// Add token metadata33const metadata = new grpc.Metadata();34metadata.add('x-token', token);3536// Request payload37const request = {38transaction: {39bcs: {40bytes: Buffer.from('YOUR_BCS_SERIALIZED_TX_BYTES', 'base64') // Replace with actual bytes41}42},43signatures: [44{45scheme: 0, // Usually 0 = ED2551946signature: Buffer.from('YOUR_SIGNATURE_BYTES', 'base64'), // Replace with actual bytes47public_key: Buffer.from('YOUR_PUBLIC_KEY_BYTES', 'base64') // Replace with actual bytes48}49],50read_mask: {51paths: ['effects', 'events']52}53};5455// Perform gRPC call56client.SimulateTransaction(request, metadata, (err: grpc.ServiceError | null, response: any) => {57if (err) {58console.error('gRPC Error:', {59code: err.code,60message: err.message,61details: err.details,62});63} else {64console.log('SimulateTransaction Response:');65console.log(JSON.stringify(response, null, 2));66}67});68
1import grpc2import json3from google.protobuf.field_mask_pb2 import FieldMask4from google.protobuf.json_format import MessageToDict5from sui.rpc.v2beta2 import live_data_service_pb2, live_data_service_pb2_grpc678def simulate_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 = live_data_service_pb2_grpc.LiveDataServiceStub(channel)1920read_mask = FieldMask(paths=[21"effects",22"events"23])2425request = live_data_service_pb2.SimulateTransactionRequest(26transaction=live_data_service_pb2.Transaction(27bcs=live_data_service_pb2.BcsBytes(28bytes=b"YOUR_BCS_SERIALIZED_TX_BYTES" # Replace with actual bytes29)30),31signatures=[32live_data_service_pb2.Signature(33scheme=0, # ED2551934signature=b"YOUR_SIGNATURE_BYTES", # Replace with actual bytes35public_key=b"YOUR_PUBLIC_KEY_BYTES" # Replace with actual bytes36)37],38read_mask=read_mask39)4041metadata = [("x-token", token)]4243return stub.SimulateTransaction(request, metadata=metadata)444546def parse_response_to_json(response):47return json.dumps(48MessageToDict(response, preserving_proto_field_name=True),49indent=250)515253def main():54try:55response = simulate_transaction()56print(parse_response_to_json(response))57except grpc.RpcError as e:58print(f"{e.code().name}: {e.details()}")5960if __name__ == "__main__":61main()62
1import grpc2import json3from google.protobuf.field_mask_pb2 import FieldMask4from google.protobuf.json_format import MessageToDict5from sui.rpc.v2beta2 import live_data_service_pb2, live_data_service_pb2_grpc678def simulate_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 = live_data_service_pb2_grpc.LiveDataServiceStub(channel)1920read_mask = FieldMask(paths=[21"effects",22"events"23])2425request = live_data_service_pb2.SimulateTransactionRequest(26transaction=live_data_service_pb2.Transaction(27bcs=live_data_service_pb2.BcsBytes(28bytes=b"YOUR_BCS_SERIALIZED_TX_BYTES" # Replace with actual bytes29)30),31signatures=[32live_data_service_pb2.Signature(33scheme=0, # ED2551934signature=b"YOUR_SIGNATURE_BYTES", # Replace with actual bytes35public_key=b"YOUR_PUBLIC_KEY_BYTES" # Replace with actual bytes36)37],38read_mask=read_mask39)4041metadata = [("x-token", token)]4243return stub.SimulateTransaction(request, metadata=metadata)444546def parse_response_to_json(response):47return json.dumps(48MessageToDict(response, preserving_proto_field_name=True),49indent=250)515253def main():54try:55response = simulate_transaction()56print(parse_response_to_json(response))57except grpc.RpcError as e:58print(f"{e.code().name}: {e.details()}")5960if __name__ == "__main__":61main()62
Don't have an account yet?
Create your Quicknode endpoint in seconds and start building
Get started for free