Skip to content

Instantly share code, notes, and snippets.

@M4cs
Last active June 21, 2023 02:00
Show Gist options
  • Save M4cs/4c369e114e5bfcec4e996a7a8c1812ef to your computer and use it in GitHub Desktop.
Save M4cs/4c369e114e5bfcec4e996a7a8c1812ef to your computer and use it in GitHub Desktop.
Run `mkdir ethscriptoor; cd ethscriptoor; yarn init . -y; yarn add ethers;` and add this to a file
// Super basic ETHScriptions in node
const ethers = require('ethers');
const privatekey = 'YOUR_PRIVATE_KEY'
const provider = new ethers.JsonRpcProvider('YOUR_RPC_URL');
const wallet = new ethers.Wallet(privatekey, provider);
const type = ``; // Leave blank for plain text (Save gas)
const text = `CHANGE_THIS`;
const hex = ethers.hexlify(ethers.toUtf8Bytes(`data:${type},`${CHANGE_THIS}`));
let tx = {
to: wallet.address,
value: 0,
data: hex,
}
wallet.sendTransaction(tx)
.then((tx) => {
tx.wait().then(
console.log
)
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment