feat: 添加区块链工具

This commit is contained in:
chaosBreaking
2019-09-04 22:58:09 +08:00
parent a1e584078c
commit b2e51a9502
4 changed files with 129 additions and 0 deletions

19
src/common/rootWallet.js Normal file
View File

@@ -0,0 +1,19 @@
'use strict';
// 该脚本只用于系统账户对用户进行提现转账
const { ERC20 } = require('../utils/erc20');
const { inject } = require('./Provider');
const USDTAddr = '0xdac17f958d2ee523a2206206994597c13d831ec7';
const RootAccount = inject(function (SysConfig) {
const { ROOTSECWORD } = SysConfig;
return ERC20.fromMnemonic(ROOTSECWORD, USDTAddr);
});
module.exports = {
async sendUSDT2User (toAddress, amount, option = {}) {
return await RootAccount.transfer(toAddress, amount, option);
},
async sendVIC2User (toAddress, amount, option = {}) {
return await RootAccount.transfer(toAddress, amount, Object.assign(option, { decimals: 18 }));
}
};