Skip to content

Instantly share code, notes, and snippets.

@ratul16
Created June 22, 2023 13:51
Show Gist options
  • Save ratul16/c9050c5a7830e998e1bba00022c5f699 to your computer and use it in GitHub Desktop.
Save ratul16/c9050c5a7830e998e1bba00022c5f699 to your computer and use it in GitHub Desktop.
User register function for vue
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