update
This commit is contained in:
13
config.json
Normal file
13
config.json
Normal file
@@ -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"
|
||||
}
|
||||
}
|
||||
106
src/chain/eth.js
106
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}
|
||||
|
||||
Reference in New Issue
Block a user