Created
June 22, 2023 13:51
-
-
Save ratul16/c9050c5a7830e998e1bba00022c5f699 to your computer and use it in GitHub Desktop.
User register function for vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async registerUser() { | |
try { | |
const accounts = await window.ethereum.request({ | |
method: "eth_requestAccounts", | |
}); | |
const user = accounts[0]; | |
const gasEstimate = await lcContract.methods | |
.registerUser(this.name, this.email, this.password) | |
.estimateGas({ from: user }); | |
const gasLimit = Math.floor(gasEstimate * 1.2); | |
await lcContract.methods | |
.registerUser(this.name, this.email, this.password) | |
.send({ from: user, gas: gasLimit }) | |
.once("receipt", (receipt) => { | |
console.log(receipt); | |
}); | |
this.toastNotification( | |
"alert-success", | |
"User registered successfully!" | |
); | |
this.checkUserRegistration(); | |
} catch (error) { | |
console.log(error); | |
this.toastNotification("alert-danger", "User Already registered!"); | |
} | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment