Skip to content

Instantly share code, notes, and snippets.

@M4cs
Last active June 19, 2023 15:37
Show Gist options
  • Save M4cs/34db27279520547cb5b759598e362b08 to your computer and use it in GitHub Desktop.
Save M4cs/34db27279520547cb5b759598e362b08 to your computer and use it in GitHub Desktop.
Create an ETHScription
const ethers = require('ethers');
const privatekey = '0X_PRIVATE_KEY';
const provider = new ethers.JsonRpcProvider('ALCHEMY_OR_INFURA_KEY');
const wallet = new ethers.Wallet(privatekey, provider);
// ETHScript an Image
const file = 'IMAGE_PATH.png';
const image = new Buffer(fs.readFileSync(file)).toString('base64');
const formatted = `data:image/png;base64,${b64}`
const hex = ethers.hexlify(ethers.toUtf8Bytes(formatted));
let tx = {
to: wallet.address,
value: 0,
data: hex
};
wallet.sendTransaction(tx)
.then((tx) => {
tx.wait().then(
console.log
)
});
// ETHScript Eon
const eonName = 'max.eon'; // Change Name
const eonFormatted = `data:,{"p": "eons", "op": "reg", "name": "${eonName}"}`
let eontx = {
to: wallet.address,
value: 0,
data: hex
};
wallet.sendTransaction(eontx)
.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