You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

52 lines
1.8 KiB

// require('dotenv').config();
import dotenv from 'dotenv'
dotenv.config()
const API_URL = process.env.API_URL;
// const { createAlchemyWeb3 } = require("@alch/alchemy-web3");
import { createAlchemyWeb3 } from "@alch/alchemy-web3"
const web3 = createAlchemyWeb3(API_URL);
// const contract = require("../artifacts/contracts/MyNFT.sol/MyNFT.json");
import contractABI from './MoonbirdPunks.json' assert { type: 'json' }
// console.log(JSON.stringify(contract.abi));
const contractAddress = "0x7d82a88Efb60Bb83B3f1665757c20D07E5C0f3ED";
const nftContract = new web3.eth.Contract(contractABI.abi, contractAddress);
async function sendEth() {
const nonce = await web3.eth.getTransactionCount(process.env.PUBLIC_OWNER_KEY, 'latest'); //get latest nonce
//the transaction
const tx = {
'from': process.env.PUBLIC_OWNER_KEY,
'to': process.env.PUBLIC_KEY,
// 'value': .001 * Math.pow(10, 18),
'value': 0,
'nonce': nonce,
'gas': 25000,
'gasPrice': 60000000000,
'maxFeePerGasGwei': 50,
// 'maxPriorityFeePerGas': 1000000000,
'maxPriorityFeePerGasGwei': 2,
};
const signedTx = await web3.eth.accounts.signTransaction(tx, process.env.PRIVATE_OWNER_KEY);
console.log(`Sending ${tx.value} from ${tx.from} to ${tx.to}...`)
const transactionReceipt = await web3.eth.sendSignedTransaction(signedTx.rawTransaction);
console.log(`Transaction receipt: ${JSON.stringify(transactionReceipt)}`);
}
// const fs = require('fs')
// const base64 = require('base-64');
// fs.readFile('scripts/geo.json', 'utf8' , (err, data) => {
// if (err) {
// console.error(err)
// return
// }
// // console.log("data:application/json;base64," + base64.encode(data))
// // mintNFT("data:application/json;base64," + base64.encode(data))
// })
sendEth()