I am in the testing phase so i am using the ropsten test network to send Eth
the code below gives a receipt
to: addr,
value: ethers.utils.parseEther(stringEther)
});
console.log("tx: ", tx);
setTxs([tx]);
console.log("tx: ", tx) basically logs a receipt
though from this how can I tell if the user has sent my wallet real ethereum and not the fake testing ethereum
so i can log it in my database, as I want to return from the function if the Ethereum was the fake etheruem , and only write to the database if it was real Ethereum
also how can a get an actual receipt in react js when the real ethereum is fully mined and in my account?
Hey @benpalmer661, welcome to the MetaMask community!
Ethereum mainnet and Ropsten are both different networks, using different tokens. If the Ethereum was sent on Ropsten, then it is just test ETH. It was sent on Ethereum mainnet, then it is real ETH.
Smart contracts/dapps are deployed separately on Ethereum and on Ropsten, so the two networks do not share any data.
Thanks, though my problem is differentiating the two in react js
as right now on my website someone could pay with Ropsten and it would update my database saying the have paid and I would send them a product even though they paid with Ropsten , so my question is: In React Js code how do I tell if someone has made a payment with Ropsten or Ethereum Mainnet ? so I am not sending someone who hasn’t paid Product unless they have paid with Ethereum Mainnet? and to further explain, I do not want to manually go and check if someone has paid myself ,
Is your React frontend talking to a smart contract on your backend? Are they paying through their MetaMask wallet?
If the smart contract is deployed on Ropsten, then only payments on Ropsten can be received. If the smart contract is deployed on Ethereum mainnet then only payments on Ethereum can be received.
My react front end is running the metamask code , and yes they are paying through their metamask wallet
Right now I am testing my app, I can change to ropsten on metamask , click purchase
and will my code it logs into the my database saying that I have paid? and once deployed I don’t see how this will change ?
is there any way with my code below to do something like;
let ethType = tx.EthType
if ( ethType === ropsten) {
alert("sorry please make paymet with Ethereum Mainnet not Ropsten)
return
}
my code is below,
const makePurchase = async () => {
try {
if (!window.ethereum)
throw new Error("No crypto wallet found. Please install it.");
await window.ethereum.request({ method: 'eth_requestAccounts' });
const provider = new ethers.providers.Web3Provider(window.ethereum);
const signer = provider.getSigner();
var addr = “0x5E43C15D965a7a132401b9c1DCFd21a14037497D”
ethers.utils.getAddress(addr);
var stringEther = String(amountInEth)
const tx = await signer.sendTransaction({
to: addr,
value: ethers.utils.parseEther(stringEther)
});
console.log("tx: ", tx);
So i can’t just do something like if tx.network !== “mainnet”. {. deny transaction- no real funds paid? }. and i have to do some sort of api request to eth scan? is that correct ? and answer from a real programmer who uses react js would be nice