Hardhat
Last updated
Was this helpful?
Was this helpful?
git clone https://github.com/PharosNetwork/examples
cd examples/transaction/ethersjs
npm installconst { ethers } = require("ethers");
// Connect to Pharos Testnet
const provider = new ethers.providers.JsonRpcProvider("<PHAROS_RPC_URL>");
// Note: Your wallet private key (for testnet only, never expose this in production)
const privateKey = "YOUR_PRIVATE_KEY";
const wallet = new ethers.Wallet(privateKey, provider);
// Transaction details
const tx = {
to: "RECIPIENT_ADDRESS", // Note: Replace with the recipient's address
value: ethers.utils.parseEther("0.1"), // Amount to send (0.1 PHAR)
};
// Send the transaction
wallet.sendTransaction(tx)
.then((transaction) => {
console.log("Transaction sent:", transaction.hash);
})
.catch((error) => {
console.error("Error sending transaction:", error);
});node index.js