Hi,
I am building a site which enables users to move usdc from 1 wallet to another.
My implementation works well if I try in a Computer but it does not work when I try to use it from mobile using the metamask Dapp browser.
For some reason the send transaction button does’t recognize anything.
I am using pure javascript and html as well.
Can you put the code that you used here please?
any help will be appreciated.
TIA
code attached below:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Moralis SDK code -->
<script src="https://cdn.jsdelivr.net/npm/web3@latest/dist/web3.min.js"></script>
<script src="https://unpkg.com/[email protected]/dist/moralis.js"></script>
<title>ETH Test</title>
</head>
<body>
<button class="enableEthereumButton btn">Enable Ethereum</button>
<button class="sendEthButton btn">Send Eth</button>
<button class="cancelBuy btn" onclick="cancelBuy();">Cancel</button>
<script>
const serverUrl = "seerverurl-----------";
const appId = "appid--------";
Moralis.start({ serverUrl, appId });
Moralis.authenticate().then(function (user) {
console.log(user.get('ethAddress'))
})
const sendEthButton = document.querySelector('.sendEthButton');
let accounts = [];
//Sending Ethereum to an address
sendEthButton.addEventListener('click', () => {
sendETH();
});
async function sendETH() {
// sending 0.5 ETH
const options = {
type: "erc20",
amount: Moralis.Units.Token("1", "6"),
receiver: "0x-------------",
contractAddress: "0x------------------",
};
const transaction = await Moralis.transfer(options);
const result = await transaction.wait();
}
</script>
</body>
</html>