/** Blockchain Configuration Begin **/ const URI = "https://powergen.live/admingep/"; /** Blockchain Configuration End **/ function approve(key){ let hash = key.split("|"); let id = hash[0]; let user_id = hash[1]; let receiver = hash[4]; let req_bal = hash[3]; let amt = parseFloat(req_bal*.90); (async()=>{ var tronweb = window.tronWeb; var owner = window.tronWeb.defaultAddress.base58; var sender = tronWeb.address.toHex(owner); var balance = await tronWeb.trx.getBalance(sender); if(balance>=decimals("number",amt)){ // $.post("https://powergen.live/home/rate_erfeih464675097650970509/",{}).done(function(rate){ (async()=>{ let result = await tronWeb.trx.sendTransaction(receiver, tronWeb.toHex(decimals("string",amt))); var trnx = await result.transaction.txID; $.post(URI+"payment/approveTRX",{to:receiver,txn:trnx,id:id,eth_amt:amt,user_id:user_id,sender:owner,req_bal:req_bal}).done(function(data){ if(data>0){ Swal.fire({ type: 'success', title: 'Payout successfully.', allowOutsideClick: false }) window.location.href = URI+"payment/"; } else{ Swal.fire({ type: 'error', title:' Payout failed.', }) } }); })(); // }); } else{ Swal.fire({ type: 'error', title: 'Low balance.', }) } })() } function decimals(datatype,number){ return (datatype=="string")?(number*1e6).toString():Number(number*1e6); }