1

Is it just that it's the only toplevel transaction type that has a value > 0?

Can I do something like this and know that it is an ETHEREUM token transaction?

const p = new ethers.providers.JsonRpcProvider(...);
const t = p.getTransaction(txnHash);

if(t.value.gt(0)) {
  console.log('It is an ETH transaction.');
}

2 Answers 2

1

get the transaction data from web3 and check the transaction data,

tx.data == '0x' ==> ethereum or bsc or mainnet transaction.

tx.data != '0x' ==> token transaction.

0

No, you cannot simply rely on the value of a transaction to determine if it is a governance token transaction. The value of a transaction refers to the amount of cryptocurrency being transferred from one address to another, and does not necessarily indicate the purpose or type of the transaction.

To determine if a transaction involves a governance token, you would need to examine the transaction data or the token contract's ABI (Application Binary Interface). In many cases, governance token transactions involve calling specific functions on the token contract, such as voting or staking.

4
  • A governance token transfer doesn't have a token contract or ABI
    – synic
    Commented Mar 3, 2023 at 18:52
  • The governance tocken transaction function is define in the tocken smart contract. So you have to get the token contract ABI in order to decode the transaction input data to determine which function is called. And then check if the function is related to governance such as voting, staking Commented Mar 3, 2023 at 19:11
  • Perhaps my terminology is wrong. I am talking about MATIC or ETHEREUM
    – synic
    Commented Mar 3, 2023 at 20:11
  • Okay then check the value and input properties of the transaction object. If the input is empty and the value is greater than zero, then the transaction is a transaction of Ether. If the input is not empty and the value is zero, then the transaction is a transaction of Matic. If both the input and value are greater than zero, then the transaction is a transaction of both Ether and Matic. Commented Mar 6, 2023 at 9:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.