diff --git a/config.json b/config.json new file mode 100644 index 0000000..d0908b8 --- /dev/null +++ b/config.json @@ -0,0 +1,13 @@ +{ + "nodesUrl": { + "ETH": { + "url":"https://api.etherscan.io/v2/api", + "key":"2KKTKZ8MSG6DNUPQ4K9JVWPQ4H33DSUQA3" + } + }, + "abiPath": { + "usdt_erc20_abi": "./src/abi/erc20usdt.json", + "usdc_erc20_abi": "./src/abi/erc20usdc.json", + "usdt_trc20_abi": "./src/abi/trc20usdt.json" + } +} \ No newline at end of file diff --git a/src/chain/eth.js b/src/chain/eth.js index f25194c..40f34cf 100644 --- a/src/chain/eth.js +++ b/src/chain/eth.js @@ -1,6 +1,6 @@ const app = require("../app"); const abiDecoder = require("abi-decoder"); -const Web3 = require("web3"); +// const Web3 = require("web3"); const axios = require("axios"); class ETH { @@ -9,7 +9,7 @@ class ETH { const apiUrl = app.ethNodeUrl const usdt_abi = app.abis.usdterc20_abi; const usdc_abi = app.abis.usdcerc20_abi; - this.web3 = new Web3(new Web3.providers.HttpProvider(apiUrl)); + // this.web3 = new Web3(new Web3.providers.HttpProvider(apiUrl)); abiDecoder.addABI(usdt_abi); abiDecoder.addABI(usdc_abi); this.decoder = abiDecoder; @@ -25,59 +25,59 @@ class ETH { } } - async decodeTxInput(txHash) { - try{ - const tx = await this.web3.eth.getTransaction(txHash); - if (!tx || !tx.input) { - console.error("Transaction not found or has no input data."); - return null; - } - return this.decodeInput(tx.input); - } catch (error) { - console.error("Error decoding transaction input:", error); - return null; - } - } + // async decodeTxInput(txHash) { + // try{ + // const tx = await this.web3.eth.getTransaction(txHash); + // if (!tx || !tx.input) { + // console.error("Transaction not found or has no input data."); + // return null; + // } + // return this.decodeInput(tx.input); + // } catch (error) { + // console.error("Error decoding transaction input:", error); + // return null; + // } + // } - decodeUSDT(input){ - const decoded = this.decodeInput(input) - const result = [] - if (decoded && decoded.name === "transfer") { - for (let item of decoded.params) { - const obj = {} - if (item.name === "_to") { - obj.toAddress = item.value; - } - if (item.name === "_value") { - obj.amount = this.web3.utils.fromWei(item.value, "ether"); - } - if (Object.keys(obj).length > 0) { - result.push(obj); - } - } - } - return result; - } + // decodeUSDT(input){ + // const decoded = this.decodeInput(input) + // const result = [] + // if (decoded && decoded.name === "transfer") { + // for (let item of decoded.params) { + // const obj = {} + // if (item.name === "_to") { + // obj.toAddress = item.value; + // } + // if (item.name === "_value") { + // obj.amount = this.web3.utils.fromWei(item.value, "ether"); + // } + // if (Object.keys(obj).length > 0) { + // result.push(obj); + // } + // } + // } + // return result; + // } - decodeUSDC(input){ - const decoded = this.decodeInput(input) - const result = [] - if (decoded && decoded.name === "transfer") { - for (let item of decoded.params) { - const obj = {} - if (item.name === "to") { - obj.toAddress = item.value; - } - if (item.name === "value") { - obj.amount = this.web3.utils.fromWei(item.value, "mwei"); - } - if (Object.keys(obj).length > 0) { - result.push(obj); - } - } - } - return result; - } + // decodeUSDC(input){ + // const decoded = this.decodeInput(input) + // const result = [] + // if (decoded && decoded.name === "transfer") { + // for (let item of decoded.params) { + // const obj = {} + // if (item.name === "to") { + // obj.toAddress = item.value; + // } + // if (item.name === "value") { + // obj.amount = this.web3.utils.fromWei(item.value, "mwei"); + // } + // if (Object.keys(obj).length > 0) { + // result.push(obj); + // } + // } + // } + // return result; + // } async checkUSDTPaymentStatus(address, amount, ts){ const url = `${app.ethNodeUrl}