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.

50 lines
1.7 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': .01 * Math.pow(10, 18),
  20. 'nonce': nonce,
  21. 'gas': 25000,
  22. 'maxFeePerGasGwei': 30,
  23. // 'maxPriorityFeePerGas': 1000000000,
  24. 'maxPriorityFeePerGasGwei': 1,
  25. };
  26. const signedTx = await web3.eth.accounts.signTransaction(tx, process.env.PRIVATE_OWNER_KEY);
  27. console.log(`Sending ${tx.value} from ${tx.from} to ${tx.to}...`)
  28. const transactionReceipt = await web3.eth.sendSignedTransaction(signedTx.rawTransaction);
  29. console.log(`Transaction receipt: ${JSON.stringify(transactionReceipt)}`);
  30. }
  31. // const fs = require('fs')
  32. // const base64 = require('base-64');
  33. // fs.readFile('scripts/geo.json', 'utf8' , (err, data) => {
  34. // if (err) {
  35. // console.error(err)
  36. // return
  37. // }
  38. // // console.log("data:application/json;base64," + base64.encode(data))
  39. // // mintNFT("data:application/json;base64," + base64.encode(data))
  40. // })
  41. sendEth()