Reputation: 168
I want user to be able to execute some functions of my Ethereum smart contract using ONLY my website via MetaMask. There should be no way to execute functions not using my website. How can I achieve this?
Upvotes: 1
Views: 139
Reputation: 3950
At first sight, it would look like this: user from your website sends request via Metamask to your backend, which encrypts a user's request via a secret key (lets name it "hash") and send it with the body request to your smart-contract (so sendToContract({hash, body})
). After that, the smart-contract encrypts the body via the secret key (lets name it "hash2") and compares "hash2" with "hash"
So, smart-contracts needs to store a secret key, but it's impossible to store secret data in a smart contract.
Yeah, you can try to hide this secret key, but eventually, you cannot have a 100% guarantee that only your backend and smart-contract know the secret key.
Upvotes: 1