Javascript
Initiate Withdrawal
const NodeRSA = require('node-rsa');
const axios = require('axios');
function rsa_encrypt(text) {
const privateKey = '-----BEGIN PRIVATE KEY-----\nYOUR_PRIVATE_KEY_HERE\n-----END PRIVATE KEY-----'; // Replace with your RSA private key
const key = new NodeRSA(privateKey);
// Convert the text to a Buffer
const buf = Buffer.from(text, 'utf8');
// Encrypt the buffer and convert it to a Base64 string
const encrypted = key.sign(buf);
return encrypted.toString('base64');
}
function makeid(length) {
const characters = 'abcdefghijklmnopqrstuvwxyz0123456789';
const charactersLength = characters.length;
let result = '';
for (let i = 0; i < length; i++) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
}
return result;
}
async function initiate_withdrawal() {
const data = {
chain: 'tron',
symbol: 'trx',
address: 'TJCBzku1S8TPTgyyk3Ja4kepk1BFDQAVq1',
amount: 1,
nonce: makeid(10),
timestamp: Math.floor(Date.now() / 1000),
};
const hash = rsa_encrypt(JSON.stringify(data));
axios.post('https://payment.hyperhashing.com/v1/token/withdraw', {
merchant_id: 'xxxx-xxxx-xxxx-xxxx', // Replace with your actual merchant ID
hash: hash,
data: data,
})
.then(function (response) {
console.log(response.config.data);
console.log(response.data);
})
.catch(function (error) {
console.log(error);
});
}
initiate_withdrawal();
Check Withdrawal Status
const NodeRSA = require('node-rsa');
const axios = require('axios');
function rsa_encrypt(text) {
const privateKey = '-----BEGIN PRIVATE KEY-----\nYOUR_PRIVATE_KEY_HERE\n-----END PRIVATE KEY-----'; // Replace with your RSA private key
const key = new NodeRSA(privateKey);
// Convert the text to a Buffer
const buf = Buffer.from(text, 'utf8');
// Encrypt the buffer and convert it to a Base64 string
const encrypted = key.sign(buf);
return encrypted.toString('base64');
}
function makeid(length) {
const characters = 'abcdefghijklmnopqrstuvwxyz0123456789';
const charactersLength = characters.length;
let result = '';
for (let i = 0; i < length; i++) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
}
return result;
}
async function check_withdrawal_status() {
const data = {
order_id: '17188041436139639757',
nonce: makeid(10),
timestamp: Math.floor(Date.now() / 1000),
};
const hash = rsa_encrypt(JSON.stringify(data));
axios.post('https://payment.hyperhashing.com/v1/token/withdraw_status', {
merchant_id: 'xxxx-xxxx-xxxx-xxxx', // Replace with your actual merchant ID
hash: hash,
data: data,
})
.then(function (response) {
console.log(response.config.data);
console.log(response.data);
})
.catch(function (error) {
console.log(error);
});
}
check_withdrawal_status();
Last updated