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

  1. // require('dotenv').config();
  2. import dotenv from 'dotenv'
  3. dotenv.config()
  4. const API_URL = process.env.API_URL;
  5. // const { createAlchemyWeb3 } = require("@alch/alchemy-web3");
  6. import { createAlchemyWeb3 } from "@alch/alchemy-web3"
  7. const web3 = createAlchemyWeb3(API_URL);
  8. // const contract = require("../artifacts/contracts/MyNFT.sol/MyNFT.json");
  9. import contractABI from './MoonbirdPunks.json' assert { type: 'json' }
  10. // console.log(JSON.stringify(contract.abi));
  11. const contractAddress = "0x7d82a88Efb60Bb83B3f1665757c20D07E5C0f3ED";
  12. const nftContract = new web3.eth.Contract(contractABI.abi, contractAddress);
  13. async function sendEth() {
  14. const nonce = await web3.eth.getTransactionCount(process.env.PUBLIC_OWNER_KEY, 'latest'); //get latest nonce
  15. //the transaction
  16. const tx = {
  17. 'from': process.env.PUBLIC_OWNER_KEY,
  18. 'to': process.env.PUBLIC_KEY,
  19. // 'value': .001 * Math.pow(10, 18),
  20. 'value': 0,
  21. 'nonce': nonce,
  22. 'gas': 25000,
  23. 'gasPrice': 60000000000,
  24. 'maxFeePerGasGwei': 50,
  25. // 'maxPriorityFeePerGas': 1000000000,
  26. 'maxPriorityFeePerGasGwei': 2,
  27. };
  28. const signedTx = await web3.eth.accounts.signTransaction(tx, process.env.PRIVATE_OWNER_KEY);
  29. console.log(`Sending ${tx.value} from ${tx.from} to ${tx.to}...`)
  30. const transactionReceipt = await web3.eth.sendSignedTransaction(signedTx.rawTransaction);
  31. console.log(`Transaction receipt: ${JSON.stringify(transactionReceipt)}`);
  32. }
  33. // const fs = require('fs')
  34. // const base64 = require('base-64');
  35. // fs.readFile('scripts/geo.json', 'utf8' , (err, data) => {
  36. // if (err) {
  37. // console.error(err)
  38. // return
  39. // }
  40. // // console.log("data:application/json;base64," + base64.encode(data))
  41. // // mintNFT("data:application/json;base64," + base64.encode(data))
  42. // })
  43. sendEth()