Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
let Web3 = require("web3");
// Replace value of rpc with https://rpc-mumbai.matic.today for Mumbai
let rpc = "https://rpc-mainnet.matic.network";
const provider = new Web3.providers.HttpProvider(rpc);
const web3 = new Web3(provider);
// Add your private key
web3.eth.accounts.wallet.add("pvt-key");
// Send 10 MATIC
web3.eth
.sendTransaction({
from: "your address",
to: "to address",
value: web3.utils.toWei("10", "ether"),
gas: 8000000,
})
.then(function (receipt) {
console.log(receipt);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment