Skip to content

Instantly share code, notes, and snippets.

@codenamejason
Forked from rahuldamodar94/sendmatic.js
Created March 13, 2021 18:15
Show Gist options
  • Save codenamejason/dbefd7cf208d34fb1cdab1c80e239072 to your computer and use it in GitHub Desktop.
Save codenamejason/dbefd7cf208d34fb1cdab1c80e239072 to your computer and use it in GitHub Desktop.
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