I forked Moralis achive node of Polygon mainnet using Hardhat and tried sending eth_sendRawTransaction but I received āinvalid JSON-RPC responseā error from Hardhat. I know that everything is fine with the transaction itself because it worked when I connected to another archive node provider. Here are steps to reproduce:
- Create a new Hardhat project and set up config file as attached below.
- Fork archive node by running
npx hardhat node --fork https://speedy-nodes-nyc.moralis.io/YOUR_KEY_HERE/polygon/mainnet/archive --fork-block-number 15740991
- Try to send eth_sendRawTransaction transaction. I am using Web3 Python library for this. Bytecode of signed transaction is attached below but it doesnāt have to be this particular transaction. No transactions worked for me.
// hardhat.config.js
require("@nomiclabs/hardhat-waffle");
// This is a sample Hardhat task. To learn how to create your own go to
// https://hardhat.org/guides/create-task.html
task("accounts", "Prints the list of accounts", async (taskArgs, hre) => {
const accounts = await hre.ethers.getSigners();
for (const account of accounts) {
console.log(account.address);
}
});
// You need to export an object to set up your config
// Go to https://hardhat.org/config/ to learn more
/**
* @type import('hardhat/config').HardhatUserConfig
*/
module.exports = {
solidity: "0.8.4",
networks: {
hardhat: {
chainId: 137,
timeout: 120000,
blockGasLimit: 20000000,
mining: {
auto: false,
interval: 0
}
},
localhost: {
url: "http://localhost:8545",
chainId: 137
}
}
};
Signed transaction
f9016d4b8502cb417800830322ee94a5e0829caced8ffdd4de3c43696c57f7d7a678ff80b90104e8e33700000000000000000000000000d86b5923f3ad7b585ed81b448170ae026c65ae9a0000000000000000000000002791bca1f2de4661ed88a30c99a7a9449aa841740000000000000000000000000000000000000000000001df5d05bd8da4b766320000000000000000000000000000000000000000000000000000000212004ccc0000000000000000000000000000000000000000000001dcf76ff3a5415533c3000000000000000000000000000000000000000000000000000000020f59e60300000000000000000000000017c26aabec62b91cb2a76402ee3a6cae1f79c13c0000000000000000000000000000000000000000000000000000000060c881a7820136a08ec4a9d2a61c6c7f36828a065fa7a2613f6e50399e008a155b18237687da12eba0693f6db047d5bb6e37bd7b6785e2490e788bc16232cf14b9c90f83b7c8c4e8c9