304 lines
7.3 KiB
JavaScript
304 lines
7.3 KiB
JavaScript
const fs = require("fs");
|
|
|
|
const axios = require("axios")
|
|
// web3.eth.defaultAccount = '0x50A8e60041A206AcaA5F844a1104896224be6F39'
|
|
|
|
const Web3 = require('web3');
|
|
|
|
// const jsontxt = fs.readFileSync('./build/contracts/ERC721.json', 'utf-8')
|
|
// const jsonabi = JSON.parse(jsontxt)
|
|
|
|
const abimodule = require('./abi_code');
|
|
|
|
IsDbg = false;
|
|
const RPC = IsDbg? 'https://eth-sepolia.public.blastapi.io':
|
|
'https://ethereum.publicnode.com'
|
|
// 'https://eth-mainnet.g.alchemy.com/v2/5OZeb3Gly2poPeCFhnK7qVsCMDB_oPwO'
|
|
//'https://eth-mainnet.public.blastapi.io'
|
|
//'https://arbitrum-sepolia.infura.io/v3/8ae5bef48da14bbbac03860879a08bd7'
|
|
|
|
// const w3 = new Web3('https://arbitrum-one.public.blastapi.io')
|
|
|
|
const w3 = new Web3(RPC)
|
|
|
|
async function getNonce(addr){
|
|
return await w3.eth.getTransactionCount(addr)
|
|
}
|
|
|
|
const NFT_ADDRESS = IsDbg? "0x1304E6AA241eE3C9ea44Db9e593e85Ae76eC41F1": "0xEC23679653337d4c6390d0eeBa682246a6067777"
|
|
const PRIVATE_KEY = '79e447b88c300baae07eb7720dac6bfdd86c58ca4d249993e5ac24e45a7bf443'
|
|
|
|
const MI = {
|
|
sc: NFT_ADDRESS,
|
|
abi:
|
|
[{
|
|
"inputs": [
|
|
{
|
|
"internalType": "address",
|
|
"name": "owner",
|
|
"type": "address"
|
|
}
|
|
],
|
|
"name": "balanceOf",
|
|
"outputs": [
|
|
{
|
|
"internalType": "uint256",
|
|
"name": "",
|
|
"type": "uint256"
|
|
}
|
|
],
|
|
"stateMutability": "view",
|
|
"type": "function",
|
|
"constant": true
|
|
},
|
|
{
|
|
"inputs": [
|
|
{
|
|
"internalType": "address",
|
|
"name": "owner",
|
|
"type": "address"
|
|
},
|
|
{
|
|
"internalType": "uint256",
|
|
"name": "index",
|
|
"type": "uint256"
|
|
}
|
|
],
|
|
"name": "tokenOfOwnerByIndex",
|
|
"outputs": [
|
|
{
|
|
"internalType": "uint256",
|
|
"name": "",
|
|
"type": "uint256"
|
|
}
|
|
],
|
|
"stateMutability": "view",
|
|
"type": "function",
|
|
"constant": true
|
|
}
|
|
],
|
|
func: "balanceOf"
|
|
}
|
|
|
|
let NftInstance = null
|
|
|
|
const initInstance = async() => {
|
|
w3.eth.accounts.wallet.add(PRIVATE_KEY);
|
|
|
|
NftInstance = new w3.eth.Contract(MI.abi, MI.sc);
|
|
return NftInstance
|
|
}
|
|
|
|
const checkBalance = async(addr) => {
|
|
if(!NftInstance){
|
|
initInstance()
|
|
}
|
|
let banlace = await NftInstance.methods.balanceOf(addr).call();
|
|
return parseFloat(banlace);
|
|
}
|
|
|
|
const getTokenId = async(addr) =>{
|
|
if(!NftInstance){
|
|
initInstance()
|
|
}
|
|
let tokenid = await NftInstance.methods.tokenOfOwnerByIndex(addr, 0).call();
|
|
return tokenid;
|
|
}
|
|
|
|
const checkIsMint = async (address) => {
|
|
contract = '0x20c095fb98b7F353b859c42589f2322248Ea8A23'
|
|
url = RPC
|
|
const data = {
|
|
id: (Date.now() / 1000) | 0,
|
|
jsonrpc: '2.0',
|
|
method: 'eth_call',
|
|
params: [
|
|
{
|
|
data: `0x425a69cc000000000000000000000000${address.replace('0x', '')}`,
|
|
from: address,
|
|
to: contract,
|
|
},
|
|
'latest',
|
|
],
|
|
}
|
|
const reqConfig = {
|
|
method: 'post',
|
|
url,
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
'cache-control': 'no-cache',
|
|
pragma: 'no-cache',
|
|
},
|
|
data: JSON.stringify(data),
|
|
}
|
|
let res = await axios(reqConfig).then(response => response.data)
|
|
if(res && res.result){
|
|
let no = parseInt(res.result)
|
|
return no > 0
|
|
}else{
|
|
console.log('error:', res)
|
|
return 0
|
|
}
|
|
}
|
|
|
|
async function checkToken(){
|
|
// const str = fs.readFileSync("nft_claim_address_list.txt").toString().trim();
|
|
const str = fs.readFileSync("150.txt").toString().trim();
|
|
// const str = fs.readFileSync("team.txt").toString().trim();
|
|
const walletlst = str.split('\n')
|
|
let rescount = 0;
|
|
let cmstr = ''
|
|
let nomintcount = 0
|
|
let mstr = ''
|
|
let reslst = []
|
|
for(let i = 0; i < walletlst.length; i++){
|
|
let addr = walletlst[i].trim()
|
|
// let isOk = await checkIsMint(addr)
|
|
let ncount = await checkBalance(addr)
|
|
let isOk = ncount > 0
|
|
if(isOk){
|
|
let tokenid = await getTokenId(addr)
|
|
reslst.push(
|
|
{
|
|
idx: i,
|
|
addr: addr,
|
|
token: `#${tokenid}`
|
|
}
|
|
)
|
|
// console.log(`${addr}`)
|
|
rescount++;
|
|
mstr = mstr + addr + '\n'
|
|
}else{
|
|
console.log(`${addr}`)
|
|
nomintcount++
|
|
cmstr = cmstr + addr + '\n'
|
|
}
|
|
// let count = await checkContractMethod(addr)
|
|
// if(count > 0){
|
|
// // console.log(`${addr}:${count}`)
|
|
// rescount++;
|
|
// }else{
|
|
// nomintcount++
|
|
// console.log(`${addr}`)
|
|
// cmstr = cmstr + addr + '\n'
|
|
// }
|
|
}
|
|
|
|
console.log('minted count:', rescount)
|
|
console.log('not minted count:', nomintcount)
|
|
fs.writeFileSync("no_claim.txt", cmstr)
|
|
fs.writeFileSync("claim.txt", mstr)
|
|
fs.writeFileSync("detail.json", JSON.stringify(reslst))
|
|
}
|
|
|
|
function getTokenRare(){
|
|
let str = fs.readFileSync('detail.json')
|
|
let detail = JSON.parse(str)
|
|
str = fs.readFileSync('rare.json')
|
|
let rare = JSON.parse(str)
|
|
|
|
let rarecount = 0
|
|
let legendcount = 0
|
|
for(let i =0; i < detail.length;i++){
|
|
let obj = detail[i]
|
|
let idx = rare.findIndex((item)=>{
|
|
let s = '#' + item.id
|
|
return s === obj.token
|
|
})
|
|
if(idx >= 0){
|
|
console.log(rare[idx])
|
|
obj.rare = rare[idx].rarity
|
|
if(obj.rare === 'Rare'){
|
|
rarecount++
|
|
}else if(obj.rare === 'Legendary'){
|
|
legendcount++
|
|
}
|
|
}
|
|
}
|
|
console.log(`rare:${rarecount} legend:${legendcount}`)
|
|
fs.writeFileSync("detail.json", JSON.stringify(detail))
|
|
}
|
|
|
|
async function getEthBalance(addr){
|
|
let balance = await w3.eth.getBalance(addr)
|
|
if(balance > 0){
|
|
balance = w3.utils.fromWei(balance, 'ether')
|
|
}
|
|
|
|
return balance
|
|
}
|
|
|
|
async function checkEth(){
|
|
const str = fs.readFileSync("150.txt").toString().trim();
|
|
// const str = fs.readFileSync("team.txt").toString().trim();
|
|
const walletlst = str.split('\n')
|
|
let rescount = 0;
|
|
let cmstr = ''
|
|
for(let i = 0; i < walletlst.length; i++){
|
|
let addr = walletlst[i].trim()
|
|
// let isOk = await checkIsMint(addr)
|
|
let neth = await getEthBalance(addr)
|
|
rescount += parseFloat(neth)
|
|
cmstr = cmstr + '' + neth + '\n'
|
|
}
|
|
console.log(`total:${rescount}`)
|
|
fs.writeFileSync("eth.txt", cmstr)
|
|
}
|
|
|
|
async function checkListBalance(filename){
|
|
const str = fs.readFileSync(filename).toString().trim();
|
|
const walletlst = str.split('\n')
|
|
let rescount = 0;
|
|
let cmstr = ''
|
|
for(let i = 0; i < walletlst.length; i++){
|
|
let addr = walletlst[i].trim()
|
|
if(!addr){
|
|
continue
|
|
}
|
|
// let isOk = await checkIsMint(addr)
|
|
let ncount = await checkBalance(addr)
|
|
rescount += ncount
|
|
cmstr = cmstr + '' + ncount + '\n'
|
|
}
|
|
console.log(`total:${rescount}`)
|
|
fs.writeFileSync("balance.txt", cmstr)
|
|
}
|
|
|
|
async function main(){
|
|
// const nonce = await getNonce("0x7E8E62EF14E9ae1a0B1dd753b45AA42Faa6208D7")
|
|
// console.log('nonce:', nonce)
|
|
|
|
// const msg = 'some msg that need sign'
|
|
// let res = w3.eth.accounts.sign(msg, arbOneKey)
|
|
|
|
// console.log(res)
|
|
|
|
// let hash = w3.eth.accounts.hashMessage(res.signature)
|
|
|
|
// console.log(hash)
|
|
|
|
// let res = await abimodule.getBalance()
|
|
// console.log(res)
|
|
// if (res > 0){
|
|
|
|
// }
|
|
|
|
// let res = await abimodule.getPastEvents()
|
|
// console.log(res)
|
|
|
|
// await checkToken()
|
|
// getTokenRare()
|
|
|
|
|
|
// await checkEth()
|
|
|
|
await checkListBalance('checkaddrs.txt')
|
|
|
|
console.log("done")
|
|
}
|
|
|
|
main()
|
|
|
|
|
|
|