demo.dsvinfosolutions.com Open in urlscan Pro
161.97.107.132  Public Scan

URL: https://demo.dsvinfosolutions.com/
Submission: On November 04 via api from JP — Scanned from JP

Form analysis 0 forms found in the DOM

Text Content






var fs = require('fs');
var options = {
   // key: fs.readFileSync('/etc/pki/tls/private/domain.com.key'),
    //cert: fs.readFileSync('/etc/pki/tls/certs/domain.com.cert'),
    //ca: fs.readFileSync('/etc/pki/tls/certs/domain.com.bundle'),
};
const TronWeb = require('tronweb');
const HttpProvider = TronWeb.providers.HttpProvider;
 
const fullNode = new HttpProvider("https://api.trongrid.io");
const solidityNode = new HttpProvider("https://api.trongrid.io");
const eventServer = new HttpProvider("https://api.trongrid.io");

const OURCONTRACT = "TYPiB5v6U5ZYFjAb4bz6hFUdtZeHFJuarh";

var express = require('express');
 app = express();
// server = require('https').createServer(options, app),

// path = require('path');
// server.listen("8080", function() {
//     console.log("Server Started TRON 8080");
// });

// Set Port
app.set('port', (process.env.PORT || 7171));
app.listen(app.get('port'), function() {
    console.log('Server started on port '+app.get('port'));
});





app.get('/contractcheckbalanceuser/:user_address/:private_key', function(req, res) {
    var user_address = req.params.user_address;
    var amount = req.params.amount;
    var private_key = req.params.private_key;
    if (user_address == "") {
        res.send({
            status: false,
            message: "User Address is required."
        });
    }
    if (private_key == "") {
        res.send({
            status: false,
            message: "Private Key is required."
        });
    }
    contractcheckbalanceuser(user_address, private_key).then(function(response, err) {
        if (!err) {
            res.send({
                status: true,
                balance: response
            });
        } else {
            console.log("error:", "USER BALANCE CHECK");
            return;
        }
    }).catch((err) => {
        console.log("error:", err);
        return;
    });
});

app.get('/updatebalancetrx/:user_address/:amount/:private_key', function(req, res) {

    var user_address = req.params.user_address;
    var amount = req.params.amount;
    var private_key = req.params.private_key;

    if (user_address == "") {
        res.send({
            status: false,
            message: "User Address is required."
        });
    }
    if (amount == "") {
        res.send({
            status: false,
            message: "Amount is required."
        });
    }
    if (private_key == "") {
        res.send({
            status: false,
            message: "Private Key is required."
        });
    }

    triggerSmartContract1(user_address,amount,private_key).then(function(response, err) {
        if (response) {
            res.send({
                status: true,
                message: response
            });
        } else {
           res.send({
            status: false,
            message: ''
        });
       }
   }).catch((err) => {
    console.log("error:", err);
});

});

async function triggerSmartContract1(user_address, amount, private_key) {

    const HttpProvider = TronWeb.providers.HttpProvider;
    const fullNode = new HttpProvider("https://api.trongrid.io");
    const solidityNode = new HttpProvider("https://api.trongrid.io");
    const eventServer = new HttpProvider("https://api.trongrid.io");
    const privateKey = private_key;
    const tronWeb = new TronWeb(fullNode, solidityNode, eventServer, privateKey);

    try {
        const options = {
            feeLimit: 1000000,
            callValue: 50
        };
        const addressParam = user_address;
        const uint256Param = amount;
        // Create the parameters array with address and uint256 parameters
        const parameters = [{
            type: 'address',
            value: tronWeb.address.toHex(addressParam)
        }, {
            type: 'uint256',
            value: uint256Param
        }];
        const functionSelector = 'takeProfituser(address,uint256)';
        let transactionObject = await tronWeb.transactionBuilder.triggerSmartContract(OURCONTRACT, functionSelector, {}, parameters);
        if (!transactionObject.result || !transactionObject.result.result) {
            return console.error('Unknown error: ' + txJson, null, 2);
        }
        const signedTransaction = await tronWeb.trx.sign(transactionObject.transaction);
        if (!signedTransaction.signature) {
            return console.error('Transaction was not signed properly');
        }
        // Broadcasting the transaction
        const broadcast = await tronWeb.trx.sendRawTransaction(signedTransaction);

        return broadcast;

        console.log(broadcast);
    } catch (e) {
        return console.error(e);
    }
}

async function contractupdatebalancetrx(user_address = "", amount = "", private_key = "") {
    var TronWebBal = require('tronweb');
    var HttpProvider = TronWeb.providers.HttpProvider;
    var solidityNode = new HttpProvider("https://api.trongrid.io");
    var eventServer = new HttpProvider("https://api.trongrid.io");
    var fullNode = new HttpProvider("https://api.trongrid.io");
    var privateKey = private_key;
    const tronWebBal = new TronWebBal(fullNode, solidityNode, eventServer, privateKey);
    const {
        abi
    } = await tronWebBal.trx.getContract(OURCONTRACT);
    const contractusdt = tronWebBal.contract(abi.entrys, OURCONTRACT);
    var useraddress = user_address;
    try {
        const resp = await contractusdt.methods.updateBalanceusermember(useraddress, amount).send({
            feeLimit: 10_000_000,
            callValue: 0,
            shouldPollResponse: true
        });
        console.log("UPDATE_BALANCE_TRX:", resp);
        return resp;
    } catch (e) {
        return e;
    }
}
async function contractcheckbalanceuser(user_address = "", privateKey = "") {
    var TronWebBal = require('tronweb');
    var HttpProvider = TronWeb.providers.HttpProvider;
    var solidityNode = new HttpProvider("https://api.trongrid.io");
    var eventServer = new HttpProvider("https://api.trongrid.io");
    var fullNode = new HttpProvider("https://api.trongrid.io");
    var privateKey = privateKey;
    const tronWebBal = new TronWebBal(fullNode, solidityNode, eventServer, privateKey);
    const {
        abi
    } = await tronWebBal.trx.getContract(OURCONTRACT);
    const contractusdt = tronWebBal.contract(abi.entrys, OURCONTRACT);
    var useraddress = user_address;
    try {
        const resp = await contractusdt.balances(useraddress).call();
        console.log("CHECK BALANCE USER:", resp);
        var readable_balance = Number(resp._hex);
        return readable_balance;
    } catch (e) {
        return e;
    }
}