Compare commits

...

2 Commits

Author SHA1 Message Date
lzx 4636ecd866 update 2025-08-07 19:04:53 +08:00
lzx 0f3716c9d2 symbol eth payment checked 2025-08-07 18:54:53 +08:00
11 changed files with 5906 additions and 7 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
node_modules
src/config.json

View File

@ -1,7 +1,4 @@
# wallet
Blockchain wallet, support list:
ETH
ERC20
TRON
TRC20
# start
```
npm run start --${port} // default: 12345
```

35
app.js Normal file
View File

@ -0,0 +1,35 @@
const express = require("express")
const ETH = require("./src/chain/eth")
const eth = new ETH()
const app = express()
const port = process.argv[2] || 12345
app.get("/", (req, res) =>{
res.send("connect success")
})
app.post("/checkPayment/eth", async(req, res) =>{
const {coin, address, amount, ts} = req.body
let result
switch (coin) {
case "eth":
// 校验eth
break
case "usdt":
result = await eth.checkUSDTPaymentStatus(address, amount, ts)
break
case "usdc":
result = await eth.checkUSDCPaymentStatus(address, amount, ts)
break
default:
result = {code:-2, result:false, data:[]}
break
}
res.send(JSON.stringify(result))
})
app.listen(port, () =>{
console.log(`Balance Server Start At http://127.0.0.1:${port}`);
})

3871
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

23
package.json Normal file
View File

@ -0,0 +1,23 @@
{
"name": "payment",
"version": "1.0.0",
"description": "Blockchain wallet, support list:\r ETH \r ERC20 \r TRON \r TRC20",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node app"
},
"repository": {
"type": "git",
"url": "http://47.129.22.53:22345/lizixuan/wallet.git"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"abi-decoder": "^2.4.0",
"axios": "^1.11.0",
"express": "^5.1.0",
"web3": "^4.16.0"
}
}

948
src/abi/erc20usdc.json Normal file
View File

@ -0,0 +1,948 @@
[{
"anonymous": false,
"inputs": [{
"indexed": true,
"internalType": "address",
"name": "owner",
"type": "address"
}, {
"indexed": true,
"internalType": "address",
"name": "spender",
"type": "address"
}, {
"indexed": false,
"internalType": "uint256",
"name": "value",
"type": "uint256"
}],
"name": "Approval",
"type": "event"
}, {
"anonymous": false,
"inputs": [{
"indexed": true,
"internalType": "address",
"name": "authorizer",
"type": "address"
}, {
"indexed": true,
"internalType": "bytes32",
"name": "nonce",
"type": "bytes32"
}],
"name": "AuthorizationCanceled",
"type": "event"
}, {
"anonymous": false,
"inputs": [{
"indexed": true,
"internalType": "address",
"name": "authorizer",
"type": "address"
}, {
"indexed": true,
"internalType": "bytes32",
"name": "nonce",
"type": "bytes32"
}],
"name": "AuthorizationUsed",
"type": "event"
}, {
"anonymous": false,
"inputs": [{
"indexed": true,
"internalType": "address",
"name": "_account",
"type": "address"
}],
"name": "Blacklisted",
"type": "event"
}, {
"anonymous": false,
"inputs": [{
"indexed": true,
"internalType": "address",
"name": "newBlacklister",
"type": "address"
}],
"name": "BlacklisterChanged",
"type": "event"
}, {
"anonymous": false,
"inputs": [{
"indexed": true,
"internalType": "address",
"name": "burner",
"type": "address"
}, {
"indexed": false,
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}],
"name": "Burn",
"type": "event"
}, {
"anonymous": false,
"inputs": [{
"indexed": true,
"internalType": "address",
"name": "newMasterMinter",
"type": "address"
}],
"name": "MasterMinterChanged",
"type": "event"
}, {
"anonymous": false,
"inputs": [{
"indexed": true,
"internalType": "address",
"name": "minter",
"type": "address"
}, {
"indexed": true,
"internalType": "address",
"name": "to",
"type": "address"
}, {
"indexed": false,
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}],
"name": "Mint",
"type": "event"
}, {
"anonymous": false,
"inputs": [{
"indexed": true,
"internalType": "address",
"name": "minter",
"type": "address"
}, {
"indexed": false,
"internalType": "uint256",
"name": "minterAllowedAmount",
"type": "uint256"
}],
"name": "MinterConfigured",
"type": "event"
}, {
"anonymous": false,
"inputs": [{
"indexed": true,
"internalType": "address",
"name": "oldMinter",
"type": "address"
}],
"name": "MinterRemoved",
"type": "event"
}, {
"anonymous": false,
"inputs": [{
"indexed": false,
"internalType": "address",
"name": "previousOwner",
"type": "address"
}, {
"indexed": false,
"internalType": "address",
"name": "newOwner",
"type": "address"
}],
"name": "OwnershipTransferred",
"type": "event"
}, {
"anonymous": false,
"inputs": [],
"name": "Pause",
"type": "event"
}, {
"anonymous": false,
"inputs": [{
"indexed": true,
"internalType": "address",
"name": "newAddress",
"type": "address"
}],
"name": "PauserChanged",
"type": "event"
}, {
"anonymous": false,
"inputs": [{
"indexed": true,
"internalType": "address",
"name": "newRescuer",
"type": "address"
}],
"name": "RescuerChanged",
"type": "event"
}, {
"anonymous": false,
"inputs": [{
"indexed": true,
"internalType": "address",
"name": "from",
"type": "address"
}, {
"indexed": true,
"internalType": "address",
"name": "to",
"type": "address"
}, {
"indexed": false,
"internalType": "uint256",
"name": "value",
"type": "uint256"
}],
"name": "Transfer",
"type": "event"
}, {
"anonymous": false,
"inputs": [{
"indexed": true,
"internalType": "address",
"name": "_account",
"type": "address"
}],
"name": "UnBlacklisted",
"type": "event"
}, {
"anonymous": false,
"inputs": [],
"name": "Unpause",
"type": "event"
}, {
"inputs": [],
"name": "CANCEL_AUTHORIZATION_TYPEHASH",
"outputs": [{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}],
"stateMutability": "view",
"type": "function"
}, {
"inputs": [],
"name": "DOMAIN_SEPARATOR",
"outputs": [{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}],
"stateMutability": "view",
"type": "function"
}, {
"inputs": [],
"name": "PERMIT_TYPEHASH",
"outputs": [{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}],
"stateMutability": "view",
"type": "function"
}, {
"inputs": [],
"name": "RECEIVE_WITH_AUTHORIZATION_TYPEHASH",
"outputs": [{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}],
"stateMutability": "view",
"type": "function"
}, {
"inputs": [],
"name": "TRANSFER_WITH_AUTHORIZATION_TYPEHASH",
"outputs": [{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}],
"stateMutability": "view",
"type": "function"
}, {
"inputs": [{
"internalType": "address",
"name": "owner",
"type": "address"
}, {
"internalType": "address",
"name": "spender",
"type": "address"
}],
"name": "allowance",
"outputs": [{
"internalType": "uint256",
"name": "",
"type": "uint256"
}],
"stateMutability": "view",
"type": "function"
}, {
"inputs": [{
"internalType": "address",
"name": "spender",
"type": "address"
}, {
"internalType": "uint256",
"name": "value",
"type": "uint256"
}],
"name": "approve",
"outputs": [{
"internalType": "bool",
"name": "",
"type": "bool"
}],
"stateMutability": "nonpayable",
"type": "function"
}, {
"inputs": [{
"internalType": "address",
"name": "authorizer",
"type": "address"
}, {
"internalType": "bytes32",
"name": "nonce",
"type": "bytes32"
}],
"name": "authorizationState",
"outputs": [{
"internalType": "bool",
"name": "",
"type": "bool"
}],
"stateMutability": "view",
"type": "function"
}, {
"inputs": [{
"internalType": "address",
"name": "account",
"type": "address"
}],
"name": "balanceOf",
"outputs": [{
"internalType": "uint256",
"name": "",
"type": "uint256"
}],
"stateMutability": "view",
"type": "function"
}, {
"inputs": [{
"internalType": "address",
"name": "_account",
"type": "address"
}],
"name": "blacklist",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}, {
"inputs": [],
"name": "blacklister",
"outputs": [{
"internalType": "address",
"name": "",
"type": "address"
}],
"stateMutability": "view",
"type": "function"
}, {
"inputs": [{
"internalType": "uint256",
"name": "_amount",
"type": "uint256"
}],
"name": "burn",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}, {
"inputs": [{
"internalType": "address",
"name": "authorizer",
"type": "address"
}, {
"internalType": "bytes32",
"name": "nonce",
"type": "bytes32"
}, {
"internalType": "uint8",
"name": "v",
"type": "uint8"
}, {
"internalType": "bytes32",
"name": "r",
"type": "bytes32"
}, {
"internalType": "bytes32",
"name": "s",
"type": "bytes32"
}],
"name": "cancelAuthorization",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}, {
"inputs": [{
"internalType": "address",
"name": "minter",
"type": "address"
}, {
"internalType": "uint256",
"name": "minterAllowedAmount",
"type": "uint256"
}],
"name": "configureMinter",
"outputs": [{
"internalType": "bool",
"name": "",
"type": "bool"
}],
"stateMutability": "nonpayable",
"type": "function"
}, {
"inputs": [],
"name": "currency",
"outputs": [{
"internalType": "string",
"name": "",
"type": "string"
}],
"stateMutability": "view",
"type": "function"
}, {
"inputs": [],
"name": "decimals",
"outputs": [{
"internalType": "uint8",
"name": "",
"type": "uint8"
}],
"stateMutability": "view",
"type": "function"
}, {
"inputs": [{
"internalType": "address",
"name": "spender",
"type": "address"
}, {
"internalType": "uint256",
"name": "decrement",
"type": "uint256"
}],
"name": "decreaseAllowance",
"outputs": [{
"internalType": "bool",
"name": "",
"type": "bool"
}],
"stateMutability": "nonpayable",
"type": "function"
}, {
"inputs": [{
"internalType": "address",
"name": "spender",
"type": "address"
}, {
"internalType": "uint256",
"name": "increment",
"type": "uint256"
}],
"name": "increaseAllowance",
"outputs": [{
"internalType": "bool",
"name": "",
"type": "bool"
}],
"stateMutability": "nonpayable",
"type": "function"
}, {
"inputs": [{
"internalType": "string",
"name": "tokenName",
"type": "string"
}, {
"internalType": "string",
"name": "tokenSymbol",
"type": "string"
}, {
"internalType": "string",
"name": "tokenCurrency",
"type": "string"
}, {
"internalType": "uint8",
"name": "tokenDecimals",
"type": "uint8"
}, {
"internalType": "address",
"name": "newMasterMinter",
"type": "address"
}, {
"internalType": "address",
"name": "newPauser",
"type": "address"
}, {
"internalType": "address",
"name": "newBlacklister",
"type": "address"
}, {
"internalType": "address",
"name": "newOwner",
"type": "address"
}],
"name": "initialize",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}, {
"inputs": [{
"internalType": "string",
"name": "newName",
"type": "string"
}],
"name": "initializeV2",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}, {
"inputs": [{
"internalType": "address",
"name": "lostAndFound",
"type": "address"
}],
"name": "initializeV2_1",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}, {
"inputs": [{
"internalType": "address",
"name": "_account",
"type": "address"
}],
"name": "isBlacklisted",
"outputs": [{
"internalType": "bool",
"name": "",
"type": "bool"
}],
"stateMutability": "view",
"type": "function"
}, {
"inputs": [{
"internalType": "address",
"name": "account",
"type": "address"
}],
"name": "isMinter",
"outputs": [{
"internalType": "bool",
"name": "",
"type": "bool"
}],
"stateMutability": "view",
"type": "function"
}, {
"inputs": [],
"name": "masterMinter",
"outputs": [{
"internalType": "address",
"name": "",
"type": "address"
}],
"stateMutability": "view",
"type": "function"
}, {
"inputs": [{
"internalType": "address",
"name": "_to",
"type": "address"
}, {
"internalType": "uint256",
"name": "_amount",
"type": "uint256"
}],
"name": "mint",
"outputs": [{
"internalType": "bool",
"name": "",
"type": "bool"
}],
"stateMutability": "nonpayable",
"type": "function"
}, {
"inputs": [{
"internalType": "address",
"name": "minter",
"type": "address"
}],
"name": "minterAllowance",
"outputs": [{
"internalType": "uint256",
"name": "",
"type": "uint256"
}],
"stateMutability": "view",
"type": "function"
}, {
"inputs": [],
"name": "name",
"outputs": [{
"internalType": "string",
"name": "",
"type": "string"
}],
"stateMutability": "view",
"type": "function"
}, {
"inputs": [{
"internalType": "address",
"name": "owner",
"type": "address"
}],
"name": "nonces",
"outputs": [{
"internalType": "uint256",
"name": "",
"type": "uint256"
}],
"stateMutability": "view",
"type": "function"
}, {
"inputs": [],
"name": "owner",
"outputs": [{
"internalType": "address",
"name": "",
"type": "address"
}],
"stateMutability": "view",
"type": "function"
}, {
"inputs": [],
"name": "pause",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}, {
"inputs": [],
"name": "paused",
"outputs": [{
"internalType": "bool",
"name": "",
"type": "bool"
}],
"stateMutability": "view",
"type": "function"
}, {
"inputs": [],
"name": "pauser",
"outputs": [{
"internalType": "address",
"name": "",
"type": "address"
}],
"stateMutability": "view",
"type": "function"
}, {
"inputs": [{
"internalType": "address",
"name": "owner",
"type": "address"
}, {
"internalType": "address",
"name": "spender",
"type": "address"
}, {
"internalType": "uint256",
"name": "value",
"type": "uint256"
}, {
"internalType": "uint256",
"name": "deadline",
"type": "uint256"
}, {
"internalType": "uint8",
"name": "v",
"type": "uint8"
}, {
"internalType": "bytes32",
"name": "r",
"type": "bytes32"
}, {
"internalType": "bytes32",
"name": "s",
"type": "bytes32"
}],
"name": "permit",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}, {
"inputs": [{
"internalType": "address",
"name": "from",
"type": "address"
}, {
"internalType": "address",
"name": "to",
"type": "address"
}, {
"internalType": "uint256",
"name": "value",
"type": "uint256"
}, {
"internalType": "uint256",
"name": "validAfter",
"type": "uint256"
}, {
"internalType": "uint256",
"name": "validBefore",
"type": "uint256"
}, {
"internalType": "bytes32",
"name": "nonce",
"type": "bytes32"
}, {
"internalType": "uint8",
"name": "v",
"type": "uint8"
}, {
"internalType": "bytes32",
"name": "r",
"type": "bytes32"
}, {
"internalType": "bytes32",
"name": "s",
"type": "bytes32"
}],
"name": "receiveWithAuthorization",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}, {
"inputs": [{
"internalType": "address",
"name": "minter",
"type": "address"
}],
"name": "removeMinter",
"outputs": [{
"internalType": "bool",
"name": "",
"type": "bool"
}],
"stateMutability": "nonpayable",
"type": "function"
}, {
"inputs": [{
"internalType": "contract IERC20",
"name": "tokenContract",
"type": "address"
}, {
"internalType": "address",
"name": "to",
"type": "address"
}, {
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}],
"name": "rescueERC20",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}, {
"inputs": [],
"name": "rescuer",
"outputs": [{
"internalType": "address",
"name": "",
"type": "address"
}],
"stateMutability": "view",
"type": "function"
}, {
"inputs": [],
"name": "symbol",
"outputs": [{
"internalType": "string",
"name": "",
"type": "string"
}],
"stateMutability": "view",
"type": "function"
}, {
"inputs": [],
"name": "totalSupply",
"outputs": [{
"internalType": "uint256",
"name": "",
"type": "uint256"
}],
"stateMutability": "view",
"type": "function"
}, {
"inputs": [{
"internalType": "address",
"name": "to",
"type": "address"
}, {
"internalType": "uint256",
"name": "value",
"type": "uint256"
}],
"name": "transfer",
"outputs": [{
"internalType": "bool",
"name": "",
"type": "bool"
}],
"stateMutability": "nonpayable",
"type": "function"
}, {
"inputs": [{
"internalType": "address",
"name": "from",
"type": "address"
}, {
"internalType": "address",
"name": "to",
"type": "address"
}, {
"internalType": "uint256",
"name": "value",
"type": "uint256"
}],
"name": "transferFrom",
"outputs": [{
"internalType": "bool",
"name": "",
"type": "bool"
}],
"stateMutability": "nonpayable",
"type": "function"
}, {
"inputs": [{
"internalType": "address",
"name": "newOwner",
"type": "address"
}],
"name": "transferOwnership",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}, {
"inputs": [{
"internalType": "address",
"name": "from",
"type": "address"
}, {
"internalType": "address",
"name": "to",
"type": "address"
}, {
"internalType": "uint256",
"name": "value",
"type": "uint256"
}, {
"internalType": "uint256",
"name": "validAfter",
"type": "uint256"
}, {
"internalType": "uint256",
"name": "validBefore",
"type": "uint256"
}, {
"internalType": "bytes32",
"name": "nonce",
"type": "bytes32"
}, {
"internalType": "uint8",
"name": "v",
"type": "uint8"
}, {
"internalType": "bytes32",
"name": "r",
"type": "bytes32"
}, {
"internalType": "bytes32",
"name": "s",
"type": "bytes32"
}],
"name": "transferWithAuthorization",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}, {
"inputs": [{
"internalType": "address",
"name": "_account",
"type": "address"
}],
"name": "unBlacklist",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}, {
"inputs": [],
"name": "unpause",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}, {
"inputs": [{
"internalType": "address",
"name": "_newBlacklister",
"type": "address"
}],
"name": "updateBlacklister",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}, {
"inputs": [{
"internalType": "address",
"name": "_newMasterMinter",
"type": "address"
}],
"name": "updateMasterMinter",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}, {
"inputs": [{
"internalType": "address",
"name": "_newPauser",
"type": "address"
}],
"name": "updatePauser",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}, {
"inputs": [{
"internalType": "address",
"name": "newRescuer",
"type": "address"
}],
"name": "updateRescuer",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}, {
"inputs": [],
"name": "version",
"outputs": [{
"internalType": "string",
"name": "",
"type": "string"
}],
"stateMutability": "view",
"type": "function"
}]

390
src/abi/erc20usdt.json Normal file
View File

@ -0,0 +1,390 @@
[
{
"constant": true,
"inputs": [],
"name": "name",
"outputs": [{ "name": "", "type": "string" }],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [{ "name": "_upgradedAddress", "type": "address" }],
"name": "deprecate",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [
{ "name": "_spender", "type": "address" },
{ "name": "_value", "type": "uint256" }
],
"name": "approve",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "deprecated",
"outputs": [{ "name": "", "type": "bool" }],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [{ "name": "_evilUser", "type": "address" }],
"name": "addBlackList",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "totalSupply",
"outputs": [{ "name": "", "type": "uint256" }],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [
{ "name": "_from", "type": "address" },
{ "name": "_to", "type": "address" },
{ "name": "_value", "type": "uint256" }
],
"name": "transferFrom",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "upgradedAddress",
"outputs": [{ "name": "", "type": "address" }],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [{ "name": "", "type": "address" }],
"name": "balances",
"outputs": [{ "name": "", "type": "uint256" }],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "decimals",
"outputs": [{ "name": "", "type": "uint256" }],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "maximumFee",
"outputs": [{ "name": "", "type": "uint256" }],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "_totalSupply",
"outputs": [{ "name": "", "type": "uint256" }],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [],
"name": "unpause",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [{ "name": "_maker", "type": "address" }],
"name": "getBlackListStatus",
"outputs": [{ "name": "", "type": "bool" }],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{ "name": "", "type": "address" },
{ "name": "", "type": "address" }
],
"name": "allowed",
"outputs": [{ "name": "", "type": "uint256" }],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "paused",
"outputs": [{ "name": "", "type": "bool" }],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [{ "name": "who", "type": "address" }],
"name": "balanceOf",
"outputs": [{ "name": "", "type": "uint256" }],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [],
"name": "pause",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "getOwner",
"outputs": [{ "name": "", "type": "address" }],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "owner",
"outputs": [{ "name": "", "type": "address" }],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "symbol",
"outputs": [{ "name": "", "type": "string" }],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [
{ "name": "_to", "type": "address" },
{ "name": "_value", "type": "uint256" }
],
"name": "transfer",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [
{ "name": "newBasisPoints", "type": "uint256" },
{ "name": "newMaxFee", "type": "uint256" }
],
"name": "setParams",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [{ "name": "amount", "type": "uint256" }],
"name": "issue",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [{ "name": "amount", "type": "uint256" }],
"name": "redeem",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [
{ "name": "_owner", "type": "address" },
{ "name": "_spender", "type": "address" }
],
"name": "allowance",
"outputs": [{ "name": "remaining", "type": "uint256" }],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "basisPointsRate",
"outputs": [{ "name": "", "type": "uint256" }],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [{ "name": "", "type": "address" }],
"name": "isBlackListed",
"outputs": [{ "name": "", "type": "bool" }],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [{ "name": "_clearedUser", "type": "address" }],
"name": "removeBlackList",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "MAX_UINT",
"outputs": [{ "name": "", "type": "uint256" }],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [{ "name": "newOwner", "type": "address" }],
"name": "transferOwnership",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [{ "name": "_blackListedUser", "type": "address" }],
"name": "destroyBlackFunds",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{ "name": "_initialSupply", "type": "uint256" },
{ "name": "_name", "type": "string" },
{ "name": "_symbol", "type": "string" },
{ "name": "_decimals", "type": "uint256" }
],
"payable": false,
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"anonymous": false,
"inputs": [{ "indexed": false, "name": "amount", "type": "uint256" }],
"name": "Issue",
"type": "event"
},
{
"anonymous": false,
"inputs": [{ "indexed": false, "name": "amount", "type": "uint256" }],
"name": "Redeem",
"type": "event"
},
{
"anonymous": false,
"inputs": [{ "indexed": false, "name": "newAddress", "type": "address" }],
"name": "Deprecate",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{ "indexed": false, "name": "feeBasisPoints", "type": "uint256" },
{ "indexed": false, "name": "maxFee", "type": "uint256" }
],
"name": "Params",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{ "indexed": false, "name": "_blackListedUser", "type": "address" },
{ "indexed": false, "name": "_balance", "type": "uint256" }
],
"name": "DestroyedBlackFunds",
"type": "event"
},
{
"anonymous": false,
"inputs": [{ "indexed": false, "name": "_user", "type": "address" }],
"name": "AddedBlackList",
"type": "event"
},
{
"anonymous": false,
"inputs": [{ "indexed": false, "name": "_user", "type": "address" }],
"name": "RemovedBlackList",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{ "indexed": true, "name": "owner", "type": "address" },
{ "indexed": true, "name": "spender", "type": "address" },
{ "indexed": false, "name": "value", "type": "uint256" }
],
"name": "Approval",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{ "indexed": true, "name": "from", "type": "address" },
{ "indexed": true, "name": "to", "type": "address" },
{ "indexed": false, "name": "value", "type": "uint256" }
],
"name": "Transfer",
"type": "event"
},
{ "anonymous": false, "inputs": [], "name": "Pause", "type": "event" },
{ "anonymous": false, "inputs": [], "name": "Unpause", "type": "event" }
]

412
src/abi/trc20usdt.json Normal file
View File

@ -0,0 +1,412 @@
[
{
"constant": true,
"inputs": [],
"name": "name",
"outputs": [{ "name": "", "type": "string" }],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [{ "name": "_upgradedAddress", "type": "address" }],
"name": "deprecate",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [
{ "name": "_spender", "type": "address" },
{ "name": "_value", "type": "uint256" }
],
"name": "approve",
"outputs": [{ "name": "", "type": "bool" }],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "deprecated",
"outputs": [{ "name": "", "type": "bool" }],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [{ "name": "_evilUser", "type": "address" }],
"name": "addBlackList",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "totalSupply",
"outputs": [{ "name": "", "type": "uint256" }],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [
{ "name": "_from", "type": "address" },
{ "name": "_to", "type": "address" },
{ "name": "_value", "type": "uint256" }
],
"name": "transferFrom",
"outputs": [{ "name": "", "type": "bool" }],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "upgradedAddress",
"outputs": [{ "name": "", "type": "address" }],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "decimals",
"outputs": [{ "name": "", "type": "uint8" }],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "maximumFee",
"outputs": [{ "name": "", "type": "uint256" }],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "_totalSupply",
"outputs": [{ "name": "", "type": "uint256" }],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [],
"name": "unpause",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [{ "name": "_maker", "type": "address" }],
"name": "getBlackListStatus",
"outputs": [{ "name": "", "type": "bool" }],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "paused",
"outputs": [{ "name": "", "type": "bool" }],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [
{ "name": "_spender", "type": "address" },
{ "name": "_subtractedValue", "type": "uint256" }
],
"name": "decreaseApproval",
"outputs": [{ "name": "", "type": "bool" }],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [{ "name": "who", "type": "address" }],
"name": "balanceOf",
"outputs": [{ "name": "", "type": "uint256" }],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [{ "name": "_value", "type": "uint256" }],
"name": "calcFee",
"outputs": [{ "name": "", "type": "uint256" }],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [],
"name": "pause",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "owner",
"outputs": [{ "name": "", "type": "address" }],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "symbol",
"outputs": [{ "name": "", "type": "string" }],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [
{ "name": "_to", "type": "address" },
{ "name": "_value", "type": "uint256" }
],
"name": "transfer",
"outputs": [{ "name": "", "type": "bool" }],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [{ "name": "who", "type": "address" }],
"name": "oldBalanceOf",
"outputs": [{ "name": "", "type": "uint256" }],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [
{ "name": "newBasisPoints", "type": "uint256" },
{ "name": "newMaxFee", "type": "uint256" }
],
"name": "setParams",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [{ "name": "amount", "type": "uint256" }],
"name": "issue",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [
{ "name": "_spender", "type": "address" },
{ "name": "_addedValue", "type": "uint256" }
],
"name": "increaseApproval",
"outputs": [{ "name": "", "type": "bool" }],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [{ "name": "amount", "type": "uint256" }],
"name": "redeem",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [
{ "name": "_owner", "type": "address" },
{ "name": "_spender", "type": "address" }
],
"name": "allowance",
"outputs": [{ "name": "remaining", "type": "uint256" }],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "basisPointsRate",
"outputs": [{ "name": "", "type": "uint256" }],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [{ "name": "", "type": "address" }],
"name": "isBlackListed",
"outputs": [{ "name": "", "type": "bool" }],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [{ "name": "_clearedUser", "type": "address" }],
"name": "removeBlackList",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "MAX_UINT",
"outputs": [{ "name": "", "type": "uint256" }],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [{ "name": "newOwner", "type": "address" }],
"name": "transferOwnership",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [{ "name": "_blackListedUser", "type": "address" }],
"name": "destroyBlackFunds",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{ "name": "_initialSupply", "type": "uint256" },
{ "name": "_name", "type": "string" },
{ "name": "_symbol", "type": "string" },
{ "name": "_decimals", "type": "uint8" }
],
"payable": false,
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"anonymous": false,
"inputs": [
{ "indexed": true, "name": "_blackListedUser", "type": "address" },
{ "indexed": false, "name": "_balance", "type": "uint256" }
],
"name": "DestroyedBlackFunds",
"type": "event"
},
{
"anonymous": false,
"inputs": [{ "indexed": false, "name": "amount", "type": "uint256" }],
"name": "Issue",
"type": "event"
},
{
"anonymous": false,
"inputs": [{ "indexed": false, "name": "amount", "type": "uint256" }],
"name": "Redeem",
"type": "event"
},
{
"anonymous": false,
"inputs": [{ "indexed": false, "name": "newAddress", "type": "address" }],
"name": "Deprecate",
"type": "event"
},
{
"anonymous": false,
"inputs": [{ "indexed": true, "name": "_user", "type": "address" }],
"name": "AddedBlackList",
"type": "event"
},
{
"anonymous": false,
"inputs": [{ "indexed": true, "name": "_user", "type": "address" }],
"name": "RemovedBlackList",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{ "indexed": false, "name": "feeBasisPoints", "type": "uint256" },
{ "indexed": false, "name": "maxFee", "type": "uint256" }
],
"name": "Params",
"type": "event"
},
{ "anonymous": false, "inputs": [], "name": "Pause", "type": "event" },
{ "anonymous": false, "inputs": [], "name": "Unpause", "type": "event" },
{
"anonymous": false,
"inputs": [
{ "indexed": true, "name": "previousOwner", "type": "address" },
{ "indexed": true, "name": "newOwner", "type": "address" }
],
"name": "OwnershipTransferred",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{ "indexed": true, "name": "owner", "type": "address" },
{ "indexed": true, "name": "spender", "type": "address" },
{ "indexed": false, "name": "value", "type": "uint256" }
],
"name": "Approval",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{ "indexed": true, "name": "from", "type": "address" },
{ "indexed": true, "name": "to", "type": "address" },
{ "indexed": false, "name": "value", "type": "uint256" }
],
"name": "Transfer",
"type": "event"
}
]

33
src/app.js Normal file
View File

@ -0,0 +1,33 @@
const fs = require("fs")
function loadConfig() {
const configPath = "./config.json";
if (!fs.existsSync(configPath)) {
throw new Error("Configuration file not found: " + configPath);
}
const configContent = fs.readFileSync(configPath, "utf-8");
if (!configContent) {
throw new Error("Configuration file is empty: " + configPath);
}
try {
return JSON.parse(configContent);
} catch (error) {
throw new Error("Error parsing configuration file: " + error.message);
}
}
class App {
constructor(){
const config = loadConfig();
this.ethNodeUrl = config.nodesUrl.ETH.url
this.ETH_API_KEY = config.nodesUrl.ETH.key
const usdterc20_abi = JSON.parse(fs.readFileSync(config.abiPath.usdt_erc20_abi, "utf-8"));
const usdcerc20_abi = JSON.parse(fs.readFileSync(config.abiPath.usdc_erc20_abi, "utf-8"));
const usdttrc20_abi = JSON.parse(fs.readFileSync(config.abiPath.usdt_trc20_abi, "utf-8"));
this.abis = {usdcerc20_abi, usdterc20_abi, usdttrc20_abi};
}
}
const app = new App();
module.exports = app;

175
src/chain/eth.js Normal file
View File

@ -0,0 +1,175 @@
const app = require("../app");
const abiDecoder = require("abi-decoder");
const Web3 = require("web3");
const axios = require("axios");
class ETH {
#key = ""
constructor(){
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));
abiDecoder.addABI(usdt_abi);
abiDecoder.addABI(usdc_abi);
this.decoder = abiDecoder;
this.#key = app.ETH_API_KEY
}
decodeInput(input){
try{
return this.decoder.decodeMethod(input);
} catch (error) {
console.error("Error decoding input data:", 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;
}
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}
?chainid=1
&module=account
&action=tokentx
&contractaddress=0xdAC17F958D2ee523a2206206994597C13D831ec7
&address=${address}
&page=1
&offset=100
&startblock=0
&endblock=27025780
&sort=asc
&apikey=${this.#key}`
try {
const response = await axios.get(url);
const transactions = response.data.result;
if (!Array.isArray(transactions) || transactions.length === 0) {
return { code: -1, result: false, data: [] };
}
// 筛选时间戳 >= ts 的交易
const afterTimestampTxs = transactions.filter(tx => parseInt(tx.timeStamp) >= ts);
if (afterTimestampTxs.length === 0) {
return { code: -1, result: false, data: [] };
}
// 筛选出金额等于指定值的交易USDT 最小单位是 6 位)
const matchedTxs = afterTimestampTxs.filter(tx => parseFloat(tx.value) / 1_000_000 === amount && tx.functionName === "transfer(address _to, uint256 _value)");
if (matchedTxs.length === 0) {
return { code: -1, result: false, data: [] };
}
return {
code: 0,
result: true,
data: matchedTxs.length === 1 ? matchedTxs[0] : matchedTxs,
};
} catch (error) {
console.error("Error fetching transactions:", error);
return {code:-1, result: false, data:[]};
}
}
async checkUSDCPaymentStatus(address, amount, ts) {
const url = `${app.ethNodeUrl}
?chainid=1
&module=account
&action=tokentx
&contractaddress=0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48
&address=${address}
&page=1
&offset=100
&startblock=0
&endblock=27025780
&sort=asc
&apikey=${this.#key}`
try{
const response = await axios.get(url);
const transactions = response.data.result;
if (!Array.isArray(transactions) || transactions.length === 0) {
return { code: -1, result: false, data: [] };
}
// 筛选时间戳 >= ts 的交易
const afterTimestampTxs = transactions.filter(tx => parseInt(tx.timeStamp) >= ts);
if (afterTimestampTxs.length === 0) {
return { code: -1, result: false, data: [] };
}
// 筛选出金额等于指定值的交易USDT 最小单位是 6 位)
const matchedTxs = afterTimestampTxs.filter(tx => parseFloat(tx.value) / 1_000_000 === amount && tx.functionName === "transfer(address _to, uint256 _value)");
if (matchedTxs.length === 0) {
return { code: -1, result: false, data: [] };
}
return {
code: 0,
result: true,
data: matchedTxs.length === 1 ? matchedTxs[0] : matchedTxs,
};
} catch (error) {
console.error("Error fetching transactions:", error);
return {code:-1, result: false, data:[]};
}
}
}
module.exports = ETH

13
src/config.json Normal file
View File

@ -0,0 +1,13 @@
{
"nodesUrl": {
"ETH": {
"url":"https://api.etherscan.io/v2/api",
"key":"2KKTKZ8MSG6DNUPQ4K9JVWPQ4H33DSUQA3"
}
},
"abiPath": {
"usdt_erc20_abi": "./abi/erc20usdt.json",
"usdc_erc20_abi": "./abi/erc20usdc.json",
"usdt_trc20_abi": "./abi/trc20usdt.json"
}
}