Recently, I've developed an Dapp using pure vanilla js and it's contract is currently deployed on etherscan.When someone buys a token, it should increment..Everything's working fine but in the trust wallet(A mobile dapp browser) doesn't seem to call events.. My Dapp is heavily rely on events..
window.addEventListener('load', async() => {
if (window.ethereum) {
const web3 = new Web3(window.ethereum);
try {
const result = await window.ethereum.enable();
if (result) {
return web3;
}
} catch (error) {
er(error)
}
} else if (window.web3) {
const web3 = window.web3;
return web3;
} else {
er(
"Non-Ethereum browser detected. You should consider trying MetaMask!"
);
}
});
var buy_events = contract.Buy({ buyer: web3.eth.coinbase }, function(error, log) {
if (!error) {
$.ajax({
type: 'POST',
url: 'referral',
data: {
buyer: log.args.buyer,
token: log.args.tokenToTransfer.c[0],
tokentra: log.args.tokensTransfered.c[0],
hash: log.transactionHash,
ref_bal: log.args.referralBal.c[0],
events_be: log.event,
}
});
}
});
buy_events.stopWatching();
Solidity
event Buy(
address indexed buyer,
uint256 tokensTransfered,
uint256 tokenToTransfer,
uint256 referralBal
);
Ps: I'm using injected web3 by metamask