Last active
June 19, 2023 15:37
-
-
Save M4cs/34db27279520547cb5b759598e362b08 to your computer and use it in GitHub Desktop.
Create an ETHScription
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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