Vottun Web3 Login Tool
This project is entirely developed and owned by Vottun.
Available methods
Within this npm package, you can call the following methods:
connectMetamaskWallet()
Triggers the Metamask window in order to make the user connect its wallet.
Returns true if the user successfully connects its wallet and false otherwise.
Disclaimer: the user must be on a non-private window and must have Metamask installed in its browser
in order to complete this action.
connectMetamaskWallet()
Triggers the CoinbaseWallet window in order to make the user connect its wallet.
Returns true if the user successfully connects its wallet and false otherwise.
Disclaimer: the user must be on a non-private window and must have CoinbaseWallet installed in its browser
in order to complete this action.
getWalletInfo()
Asks for the information related to the wallet: address
, chainId
.
Returns the information if the wallet is correctly connected, and null
otherwise.
signMessage(origin, walletAddress, chainId)
Triggers the Metamask window in order to make the user sign an EIP191 message.
Expects the following arguments:
origin
: The URL of the origin page
walletAddress
: The address of the connected wallet
chainId
: The ID of the connected blockchain
Returns an object that contains the signatureHash
and the nonce
:
signatureHash
: a hash that represents the result of the signature, which will have to be validated against
the server in order to verify the operation
nonce
: a unique hash used as an operation identifier, used for security purposes
Expected steps
When using this npm package in a web application, the steps that are supposed to be followed in order to
achieve a successful Web3 login are:
- Display a button that calls the
connectWallet()
method.
- Retrieve the
walletAddress
and chainId
values
- Call the
signMessage()
method
- Validate the obtained
hash
against the server
- Manage the obtained
accessToken
as desired