simulateTransaction

How to use it

// Import required libraries and modules from Tatum SDK
import { TatumSDK, AlgorandAlgod, Network } from '@tatumio/tatum';

// Initialize the Tatum SDK for Algorand
const tatum = await TatumSDK.init<AlgorandAlgod>({ network: Network.ALGORAND_ALGOD });

// Define the input parameters in a single object
const params = {
    format: 'json',  // Optional: Configures whether the response object is JSON or MessagePack encoded. If not provided, defaults to JSON.
};

// Define the request body object
const requestBody = {
    // Specify the transactions to simulate, along with any other inputs.
    // Please refer to the Tatum SDK documentation for detailed information about the request body schema.
};

// Simulate the transaction or transaction group on the Algorand network
const simulationResult = await tatum.rpc.simulateTransaction(params, requestBody);

// Log the simulation result
console.log('Algorand Transaction Simulation Result:', simulationResult);

// Always destroy the Tatum SDK instance when done to stop any background processes
await tatum.destroy();

Overview

The simulateTransaction method allows you to simulate a raw transaction or transaction group as it would be evaluated on the Algorand network. The simulation will use blockchain state from the latest committed round.

Example Use Cases

  1. Transaction Simulation: Developers can use this method to test the validity and outcome of a transaction or transaction group before actually submitting it to the Algorand network. This can help avoid failed transactions and wasted resources.

Request Parameters

The simulateTransaction method requires the following parameters:

  • format (enum: json, msgpack, optional): Configures whether the response object is JSON or MessagePack encoded. If not provided, defaults to JSON.

Request Body

The simulateTransaction method requires a request body object. Please refer to the Tatum SDK documentation for detailed information about the request body schema.

Return Object

The method returns an object representing the result of the simulated transaction or transaction group. Please note that the structure of the returned object may vary depending on the format specified in the request parameters and the Algorand RPC version.

Error Responses

  • 400: Bad Request. The request was invalid or missing required parameters.

  • 401: Invalid API Token. The API token used for authentication is invalid.

  • 500: Internal Error. An unexpected error occurred on the server.

  • 503: Service Temporarily Unavailable. The server is temporarily unable to handle the request.

Please refer to the Tatum SDK documentation for more information about error responses.

Last updated

ยฉ Tatum Technology, LLC