數(shù)字貨幣去中心化交易所系統(tǒng)開發(fā)(方案項目)/案例詳情/源碼功能/成熟技術(shù)
區(qū)塊鏈數(shù)據(jù)層包括底層數(shù)據(jù)區(qū)塊、基礎(chǔ)數(shù)據(jù)、算法等內(nèi)容,數(shù)據(jù)層的創(chuàng)新改變數(shù)據(jù)結(jié)構(gòu),提升存儲效率,降低存儲空間。
數(shù)字貨幣交易所開發(fā)技術(shù)是一種去中心化的共識機制,來維護一個完整的、分布式的、不可篡改的賬本數(shù)據(jù)庫的技術(shù)。It can enable participants in the blockchain to achieve a unified ledger system without establishing trust relationships.
如果區(qū)塊鏈是數(shù)據(jù)庫,則智能合約是使區(qū)塊鏈技術(shù)能夠應(yīng)用于現(xiàn)實世界的應(yīng)用層。智能合約是在區(qū)塊鏈數(shù)據(jù)庫上運行的計算機程序,在滿足其源代碼中寫入的條件時可以自己執(zhí)行。
let buyAction=async()=>{
if(initialLiquidityDetected===true){
console.log('not buy cause already buy');
return null;
}
console.log('ready to buy');
try{
initialLiquidityDetected=true;
let amountOutMin=0.;
//We buy x amount of the new token for our wbnb
const amountIn=ethers.utils.parseUnits(`${data.AMOUNT_OF_WBNB}`,'ether');
//if(parseInt(data.Slippage)!==0){
//const amounts=await router.getAmountsOut(amountIn,[tokenIn,tokenOut]);
//Our execution price will be a bit different,we need some flexbility
//amountOutMin=amounts[1].sub(amounts[1].div(`${data.Slippage}`));
//}
console.log(
chalk.green.inverse(`Start to buyn`)
+
`Buying Token
=================
tokenIn:${(amountIn*1e-18).toString()}${tokenIn}(BNB)
tokenOut:${(amountOutMin/1e-18).toString()}${tokenOut}
`);
console.log('Processing Transaction.....');
console.log(chalk.yellow(`amountIn:${(amountIn*1e-18)}${tokenIn}(BNB)`));
console.log(chalk.yellow(`amountOutMin:${amountOutMin/1e-18}`));
console.log(chalk.yellow(`tokenIn:${tokenIn}`));
console.log(chalk.yellow(`tokenOut:${tokenOut}`));
console.log(chalk.yellow(`data.recipient:${data.recipient}`));
console.log(chalk.yellow(`data.gasLimit:${data.gasLimit}`));
console.log(chalk.yellow(`data.gasPrice:${data.gasPrice}`));
const tx=await router.swapExactTokensForTokensSupportingFeeOnTransferTokens(//uncomment this if you want to buy deflationary token
//const tx=await router.swapExactTokensForTokens(//uncomment here if you want to buy token
amountIn,
amountOutMin,
[tokenIn,tokenOut],
data.recipient,
Date.now()+1000*60*5,//5 minutes
{
'gasLimit':data.gasLimit,
'gasPrice':data.gasPrice,
'nonce':null//set you want buy at where position in blocks
});
const receipt=await tx.wait();
console.log(`Transaction receipt:https://www.bscscan.com/tx/${receipt.logs[1].transactionHash}`);
setTimeout(()=>{process.exit()},4000);
}catch(err){
let error=JSON.parse(JSON.stringify(err));
console.log(`Error caused by:
{
reason:${error.reason},
transactionHash:${error.transactionHash}
message:Please check your BNB/WBNB balance,maybe its due because insufficient balance or approve your token manually on pancakeSwap
}`);
console.log(error);
inquirer.prompt([
{
type:'confirm',
name:'runAgain',
message:'Do you want to run again thi bot?',
},
])
.then(answers=>{
if(answers.runAgain===true){
console.log
console.log('Run again');
console.log
initialLiquidityDetected=false;
run();
}else{
process.exit();
}
});
}
}
run();
const PORT=5001;
app.listen(PORT,console.log(chalk.yellow(`Listening for Liquidity Addition to token${data.to_PURCHASE}`)));