Granting a spender allowance to the WhbarHelper contract is required for the contract to transfer the WHBAR token from the userโs wallet to the contract.
Function name: unwrapWhbar
Parameter Name
Description
uint256 wad
WHBAR token amount in its smallest unit
Copy
Ask AI
/// @notice Safely unwrap whbar to msg.sender/// @dev This contract needs an allowance from msg.sender to transfer the whbar token/// @param wad The amount to unwrapfunction unwrapWhbar(uint wad) public { require(wad > 0, "WhbarHelper: wad cannot be lt zero"); // transfer the whbar to this contract HederaTokenHelper.safeTransferFrom(whbarToken, msg.sender, address(this), wad); // approve sending the whbar to the whbar contract HederaTokenHelper.safeApprove(whbarToken, whbarContract, wad); // use withdraw(address src, address dst, uint wad) and use this contract and msg.sender to withdraw // to the contract caller IWHBAR(whbarContract).withdraw(address(this), msg.sender, wad);}