1

There are three types of transactions:

  1. Ether transfer from one EOA to another
  2. Contract creation
  3. Contract call

2 can be easily identified since it's "to" field is empty. How to differentiate 1 & 3? This post separates 2 from 3.

sinoTrinity
  • 377
  • 2
  • 8

1 Answers1

3

In order to differentiate between 1 and 3, you can check if there is any code at the to address.

if(web3.eth.getCode("0xa5Acc472597C1e1651270da9081Cc5a0b38258E3").length > 2){
  console.log("Sent to contract")
}
else{
  console.log("Sent to a externally owned address")
}
Ayushya
  • 1,698
  • 9
  • 24