Explore Courses Blog Tutorials Interview Questions
0 votes
in Blockchain by (4.1k points)

I am studying blockchain with Ethereum, and I want to use past transaction data in the Smart contract using Solidity. If I use Web3.js module in the program written in javascript, I can get these data easily. But I can't get these data in the Smart contract using Solidity.

Reference of Solidity says that we can get current block number, blockhash, etc., by using "block.number" and "block.blockhash(uint blockNumber)" functions, but doesn't mention getting transaction data. (

enter image description here

please help me.

1 Answer

0 votes
by (14.4k points)
edited by

No, you cannot access transaction information recorded in the preceding block using Solidity. The most you can do is access the hashes of the last 256 blocks. 

Otherwise, you can leverage Oraclize. It enables the reading of off-chain data on the ledger itself. So, you may be able to read data using Etherscan Web API. But the question that comes up here is how Oraclize works. So, Oraclize works as: 

  • A request is sent to Oraclize Smart Contract regarding the type of data which is to be fetched from the internet. 
  • The Oraclize off-chain server detects the on-chain request. 
  • Required data is looked up (through URLs).
  • Once the response is received, transactional data is sent back to the contract that requested it. 

But you need to ensure that both Oraclize and EthereScan are up and running. 

There is another way to extract transactional data that are related to smart contracts. Data can be stored on-chain and extracted when required. 

Know Blockchain better with Blockchain Training by Intellipaat.

Browse Categories