Skip to content

Instantly share code, notes, and snippets.

@nhodges
Forked from iam4x/mint_corrupted_rose.ts
Created November 20, 2021 21:53
Show Gist options
  • Save nhodges/7026963a00aedbb9f1a520c2ee5d6281 to your computer and use it in GitHub Desktop.
Save nhodges/7026963a00aedbb9f1a520c2ee5d6281 to your computer and use it in GitHub Desktop.
import Web3 from 'web3';
import HDWalletProvider from '@truffle/hdwallet-provider';
const tokenId = 1; // YOUR TOKEN ID
const seed = 'YOUR SEEDPHRASE WITHOUT 0x';
const provider = new Web3.providers.HttpProvider('https://YOUR_ETHEREUM_RPC_NODE');
const localKeyProvider = new HDWalletProvider({
privateKeys: [seed],
providerOrUrl: provider,
})
const web3 = new Web3(localKeyProvider);
const myAccount = web3.eth.accounts.privateKeyToAccount(seed);
const abi = `[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"string","name":"ack","type":"string"}],"name":"DEVIATE___CORRUPTION_WILL_BE_LOCKED_PERMANENTLY_AND_NO_LONGER_GAIN_INSIGHT","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"count","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"drawCanvas","outputs":[{"internalType":"string[32]","name":"","type":"string[32]"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"enabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"isEnabled","type":"bool"}],"name":"setEnabled","outputs":[],"stateMutability":"nonpayable","type":"function"}]`;
const contractAddress = '0x4500f6e46d485b62ed35926052f04c04f627f637';
const contract = new web3.eth.Contract(JSON.parse(abi), contractAddress);
function sleep(ms: number) {
return new Promise(resolve => setTimeout(resolve, ms));
}
async function waitForEnabled(): Promise<boolean> {
const isEnabled = await contract.methods.enabled().call();
if (!isEnabled) {
console.log('Not enabled, waiting 10s');
await sleep(10 * 1000);
return waitForEnabled();
}
console.log(`
...............................
...............................
...............................
...............................
...............................
...............................
........#######................
......##########...............
.....#####...#########.........
....####.......#####8888.......
....####......###888888888.....
....####......8888888888888....
....####......88888888888888...
.....######...88888888888888...
....#######...88888888888888...
..###########..888888888888....
..############..88888888888....
..############...888888888.....
....###########..88888.........
....###########..88............
.......#####...................
........#####..................
.........####..................
.........####..................
..........##...................
...............................
...............................
...............................
...............................
...............................
...............................
`);
return true;
}
const ack = 'I_HAVE_READ_THE_DISCLAIMER_AND_ACKNOWLEDGE';
const method = 'DEVIATE___CORRUPTION_WILL_BE_LOCKED_PERMANENTLY_AND_NO_LONGER_GAIN_INSIGHT';
async function deviateCorruption() {
try {
const tx = contract.methods[method](tokenId, ack);
console.log('deviateCorruption - estimate gas');
const gas = await tx.estimateGas({ from: myAccount.address });
console.log({ gas });
const result = await tx.send({ gas }).on('transactionHash', (hash: string) => {
console.log(`deviateCorruption - tx send ${hash}`);
});
console.log('deviateCorruption - tx success');
console.log({ result });
} catch (error) {
console.log('deviateCorruption - error');
console.log({ error });
}
}
async function main() {
await waitForEnabled();
await deviateCorruption();
}
main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment