0

I'm a JavaScript developer with limited knowledge of Solidity, and I need to retrieve information about the latest locked token from the Ethereum blockchain. I want to accomplish this task using JavaScript, and I'm looking for guidance on how to do it without having to write Solidity smart contracts.

Specifically, I'd like to know:

  1. Is it possible to interact with the Ethereum blockchain to retrieve information about locked tokens using JavaScript without writing Solidity contracts?
  2. What JavaScript libraries or tools should I use to interact with Ethereum and fetch data about locked tokens? What Ethereum APIs or services can provide information about token locks and how can I access them programmatically?
  3. Are there any code examples or tutorials that demonstrate how to retrieve data about locked tokens using JavaScript?

Since I don't have experience with Solidity, I'm hoping to find a solution that doesn't require me to write custom smart contracts. Any advice or resources you can provide would be greatly appreciated. Thank you!

1
  • What do you mean by "locked tokens"? Try limiting to only one issue per question. I think the more popular choices are web3js and ethersjs.
    – Ismael
    Commented Sep 8, 2023 at 6:39

1 Answer 1

0
  1. Create an Infura Account:

    • You need an Infura account to access Ethereum nodes.
  2. Use the subscribe Method:

    • Subscribe to new pending transactions (newPendingTransactions) using Infura.
  3. Retrieve Transaction Details:

    • When you receive a notification about a new transaction, obtain the transaction hash (txhash) from the notification.
  4. Query eth_getTransactionByHash:

    • Use the eth_getTransactionByHash method to retrieve the full details of the transaction, including the to address.
  5. Use to Address for Etherscan API:

    • Take the to address from the transaction details and use it as a parameter for an Etherscan API query. This query is meant to fetch the contract ABI associated with the to address.

const apiUrl = https://api.etherscan.io/api?module=contract&action=getabi&address=${contractAddress}&apikey=E5CUQXUW93HD1ZWDAYZR2IF6ZD91BYIPAJ

  1. Decode Input Data with ABI:
    • Once you have the ABI, you can decode the input data of the transaction. The ABI provides the necessary information to decode the input data and understand the function calls and parameters, including details about locked tokens (e.g., lpLocker and duration).

abiDecoder.addABI(abi); const contract = abiDecoder.decodeMethod( transactionData.input );

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.