Facebook
From Sloppy Macaque, 1 Year ago, written in Plain Text.
This paste is a reply to Untitled from Jittery Motmot - view diff
Embed
Download Paste or View Raw
Hits: 158
  1. const fetch = require('node-fetch');
  2.  
  3. // Set up the Polygon JSON-RPC endpoint URL
  4. const rpcEndpoint = 'https://rpc-mainnet.maticvigil.com/';
  5.  
  6. // Set up the JSON-RPC request to retrieve pending transactions
  7. const requestBody = {
  8.     jsonrpc: '2.0',
  9.     method: 'eth_pendingTransactions',
  10.     params: [],
  11.     id: 1
  12. };
  13. // Send the JSON-RPC request to the endpoint
  14. fetch(rpcEndpoint, {
  15.     method: 'POST',
  16.     body: JSON.stringify(requestBody),
  17.     headers: {
  18.         'Conte
  19. .then(response => response.json())
  20. .then(data => {
  21.     // Handle the response data
  22.    
  23.    
  24.    
  25.     import axios from 'axios';
  26.  
  27. // Set up the Polygon JSON-RPC endpoint URL
  28. const rpcEndpoint = 'https://rpc-mainnet.maticvigil.com/';
  29.  
  30. // Set up the JSON-RPC request to retrieve pending transactions
  31. const requestBody = {
  32.     jsonrpc: '2.0',
  33.     method: 'eth_pendingTransactions',
  34.     params: [],
  35.     id: 1
  36. };
  37.  
  38. // Send the JSON-RPC request to the endpoint
  39. axios.post(rpcEndpoint, requestBody, {
  40.     headers: {
  41.         'Content-Type': 'application/json'
  42.     }
  43. })
  44. .then(response => {
  45.     // Handle the response data
  46.     console.log(response.data.result);
  47. })
  48. .catch(error => {
  49.     // Handle errors
  50.     console.error(error);
  51. });
  52.  
  53.    
  54.    
  55.    
  56.    
  57.    
  58.    
  59.     console.log(data.result);
  60. })
  61. .catch(error => {
  62.     // Handle errors
  63.     console.error(error);
  64. });
  65.