Skip to content

Commit

Permalink
fix: amountInWei
Browse files Browse the repository at this point in the history
  • Loading branch information
nicitaacom committed Aug 13, 2024
1 parent d25a341 commit b19edd0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ export function PayWithMetamaskButton() {
}

async function sendMoneyWithMetamaskFunction() {
console.log(80)
setIsLoading(true)
!isAuthenticated
? openDoYouWantRecieveCheckModal()
Expand Down
12 changes: 11 additions & 1 deletion app/components/ui/Modals/DoYouWantRecieveCheckModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,17 @@ export const sendMoneyWithMetamask = async (
symbol: "USD",
convert: "ETH",
})
console.log("API Response:", response.data)

// its productsPrice / ETHPrice
const ETHPrice = response.data.data[0].quote.ETH.price

// Convert ETH to Wei
const amountInWei = BigInt(Math.round(ETHPrice * 10 ** 18)) // Correcting to use * 10^18
const amountInWeiHex = amountInWei.toString(16).padStart(64, "0") // Ensure it's 64 characters

console.log("amountInWeiHex - ", amountInWeiHex) // Log to check the output

window.ethereum
.request({
method: "eth_sendTransaction",
Expand All @@ -45,7 +55,7 @@ export const sendMoneyWithMetamask = async (
gasLimit: "0x5028",
maxPriorityFeePerGas: "0x3b9aca00",
maxFeePerGas: "0x2540be400",
value: BigInt(Math.floor(ETHPrice * 10 ** 18)).toString(16),
value: `0x${amountInWeiHex}`,
},
],
})
Expand Down

0 comments on commit b19edd0

Please sign in to comment.