const Web3 = require("web3");
// Configuring the connection to the Polygon node
const network = process.env.POLYGON_NETWORK;
new Web3.providers.HttpProvider(
`https://${network}.infura.io/v3/${process.env.INFURA_PROJECT_ID}`
// Creating a signing account from a private key
const signer = web3.eth.accounts.privateKeyToAccount(
process.env.SIGNER_PRIVATE_KEY
web3.eth.accounts.wallet.add(signer);
// Creating the transaction object
to: "0xeAD9C93b79Ae7C1591b1FB5323BD777E86e150d4",
value: web3.utils.toWei("0.001"),
// Assigning the right amount of gas
tx.gas = await web3.eth.estimateGas(tx);
// Sending the transaction to the network
const receipt = await web3.eth
.once("transactionHash", (txhash) => {
console.log(`Mining transaction ...`);
console.log(`Transaction hash: ${txhash}`);
// The transaction is now on chain!
console.log(`Mined in block ${receipt.blockNumber}`);
require("dotenv").config();