Developers
  • SWT PROTOCOL
    • Introduction
    • Accounts
    • Transactions
    • Fees
    • Smart Contracts
  • GETTING STARTED
    • Network Node
      • Introduction
      • STEP 1:RENTING A LINUX VPS
      • STEP 2:INSTALLATION OF PUTTY
      • STEP 3:INSTALLATION OF FILEZILLA
      • STEP 4:VPS CONNECTION AND LINUX CONFIGURATION WITH PUTTY (SSH)
      • STEP 5:HOW TO SECURE YOUR VPS
      • STEP 6:USING TMUX THROUGH PUTTY
      • STEP 7:UPLOAD OF THE SWT SOFTWARE WITH FILEZILLA
      • STEP 8:EXTRACT THE SWT SOFTWARE FOLDER
      • STEP 9:RUNNING THE SWT NODE THROUGH TMUX
      • STEP 10:RUNNING THE MONITORING TOOLS
  • API REFERENCE
    • Apache Thrift API
      • Transactions
      • Blocks
      • Smart contract
      • Tokens
      • Wallets
      • Sync info
      • Data structures
    • REST API
      • GetBlocks()
      • GetNodeInfo()
      • GetBalance()
      • GetWalletInfo()
      • GetTokenBalance()
      • GetTransactionsByWallet()
      • GetTransactionInfo()
      • GetEstimatedFee()
      • GetContractByAddress()
      • GetContractFromTransaction()
      • GetContractMethods()
      • ContractValidation()
      • ContractCall()
      • TransactionPack()
      • TransactionExec()
  • SMART CONTRACTS
    • Creating "Hello-world" Smart Contract
    • Smart Contract Methods
    • Smart Contract Standarts
      • Token Smart Contract
      • Escrow Smart Contract
      • Stable coin Token
  • HOW TO REST API
    • Introduction
    • Retrieve a balance from the blockchain
    • Request a specific transaction from the blockchain
    • Sending Transactions to the SWT Blockchain
    • Validating and deploying a Smart Contract with REST API
Powered by GitBook
On this page
  • Introduction
  • Description of cURL parameters
  • Code
  • Response
  1. HOW TO REST API

Request a specific transaction from the blockchain

PreviousRetrieve a balance from the blockchainNextSending Transactions to the SWT Blockchain

Last updated 1 year ago

Introduction

For illustration purposes, we’ll request a transaction in the blockchain using the cURL tool information on cURL:

The following code will retrieve a transaction from the SWT blockchain with the given TransactionID :22984327.1 on Mainnet.

We are using the “GetTransactionInfo()” function which is explained here: .

Description of cURL parameters

X POST - type of HTTP request, in this case we use POST. More info here:

-H “accept: application/json”

-H “Content-Type: application/json” - Specification for the transferred parameters and response to be in JSON format

-d {parameters} - With this key, we specify the data transferred with the request. Let’s look at them in more detail:

“authKey”: “” - Authorization key. Not used at present, should be passed “”

“networkAlias”: “MainNet” - We specify the network, where the request should be executed. Either TestNet or MainNet.

"Compressed": "true" - Here we specify the compression of the information that is send back to us.

“TransactionId”: "22984327.1" - We specify the transaction number which we want to retrieve from the blockchain

"methodApi": "GetBalance"

Warning

For CMD to overlook quotation marks “ inside the request body since those are special characters, they should be escaped with the backward slash.

Code

Let's try it out with the following code !

curl -X POST "http://176.113.80.7:62000/api/Monitor/GetTransactionInfo" -H "accept: application/json" -H "Content-Type: application/json" -d "{\"authKey\":\"\",\"networkAlias\":\"MainNet\", \"Compressed\": true, \"TransactionId\":\"22984327.1\",\"methodApi\":\"GetTransactionInfo\"}"

Response

We get the following response from the REST API in JSON.

{"transaction":
    {
        "id":"22984327.1",
        "fromAccount":"5B3YXqDTcWQFGAqEJQJP3Bg1ZK8FFtHtgCiFLT5VAxpe",
        "toAccount":"QTRbkssQSGLdKs94khX7i858YcBAhjg6wj48F7FTr8H",
        "time":"2023-11-27T06:40:32.372Z",
        "value":"334.5398402953732",
        "val":334.539840295373200000,
        "fee":"0.008740234375",
        "currency":"SWT",
        "innerId":10042,
        "index":0,"status":"Success",
        "transactionType":0,"transactionTypeDescription":"TT_Transfer",
        "blockNum":"22984327",
        "found":true,
        "userData":null,"signature":"",
        "extraFee":null,
        "bundle":null},
        "success":true,
        "message":null
    }

Info In this example, we executed the retrieval of a transaction REST request to the SWT blockchain without any specialized development environment or additional tools.

Wikipedia
GetTransactionInfo
Wikipedia