Hello, I want to know how I’d be able to allow my users to pay with ETH on polygon and BNB on BSC through MetaMask.(So if they are on network 56 or 137 it’ll allow them to pay in BNB or ETH) This is how I did it for ETH on the Ethereum Mainnet and it works but how can I do it for the other chains? Looking forward to hearing back hopefully I can get response soon :D. Lastly I’m using more of an order book model so id prefer if the solution had the .on handlers so i could run the same functions in them. I also want the Polygon payments to work more, if BNB requires a new smart contract we can skip it.
await axios
.get(“https://min-api.cryptocompare.com/data/pricemulti?fsyms=MATIC,BNB,ETH,IOT&tsyms=USD”)
.then((res) => {
const cryptos = res.data;
setETHRate(cryptos[“ETH”].USD)
});
const sum = text1 / ethRate
const ether = `${sum.toFixed(10)}`
const networkId = await web3.eth.net.getId()
if(networkId === 1){
try {
const trans = web3.eth.sendTransaction({
from: account,
to: '0x0000000000',
value: web3.utils.toWei(ether, "ether")
})
.on("transactionHash", async (hash) => {
//pending
})
.on("receipt", async (receipt) => {
//completed action
})
.on("error", async (error) => {
//error action
}) .....