0

I'm trying to write a code to get the latest outgoing transaction of an Ethereum address data. For that I reached to Infura and tried to get it using something like this:

const INFURA_URL = 'https://mainnet.infura.io/v3/INFURA_PROJECT_ID'
const address = "some ethereum address"
const handleReq = async(event) =>{
 event.preventDefault();
 try{
  const response = await axios.get('${INFURA_URL}/eth/v1/address/${address}');
  const transaction = response.data.data;
 } catch(error){ console.error(error);}

but the code gives me the 404 error that 'response' variable is not valid. I wanted to ask if you have experience with infura and help me if the way I try to address the account is valid and correct. Thanks

1 Answer 1

1

usually I don't use RPC node services like Infura as it is a bit cumbersome now that there are several API services out there that makes it easy to index these data with a few lines of code.

One service that I recommend is Moralis, and for getting latest outgoing transaction of an address, you have two options from Moralis, Web3 API (for non real-time) and Streams API (for real-time).

With Web3 API, if you don't need to get real-time data, then you can fetch the latest transaction of an address using Moralis getWalletTransactions API and will just need to provide a valid address input to the API.

On the other hand, if you need to get real-time data, such as getting transaction notification, then you can setup Streams with Moralis that will monitor any transaction of an address real-time and send those data to your webhooks.

To get to know more about Streams API, check here on how to setup one.

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.