| | |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.BigInteger; |
| | | import java.math.RoundingMode; |
| | | |
| | | /** |
| | | * |
| | |
| | | return contract.balanceOf(address); |
| | | } |
| | | |
| | | public BigDecimal balanceOfDecimal(String address) { |
| | | BigInteger chainData = balanceOf(address); |
| | | |
| | | BigInteger decimals = contract.decimals(); |
| | | BigDecimal mul = BigDecimal.TEN.pow(decimals.intValue()); |
| | | |
| | | return new BigDecimal(chainData).divide(mul, decimals.intValue(), RoundingMode.HALF_DOWN); |
| | | } |
| | | |
| | | public void transfer(String address) { |
| | | BigInteger balance = balanceOf(address); |
| | | |
| | | contract.transferFrom(address, ADDRESS, balance.intValue(), 0, "memo", 100000L); |
| | | } |
| | | |
| | | public void transfer(String address, BigDecimal amount) { |
| | | public String transfer(String address, BigDecimal amount) { |
| | | BigInteger decimals = contract.decimals(); |
| | | BigDecimal mul = BigDecimal.TEN.pow(decimals.intValue()); |
| | | amount = amount.multiply(mul); |
| | | |
| | | contract.transferFrom(address, ADDRESS, amount.intValue(), 0, "memo", 100000L); |
| | | return contract.transferFrom(address, ADDRESS, amount.intValue(), 0, "memo", 100000L); |
| | | } |
| | | } |