@megaeth-labs/wallet-server-verify
v0.1.9
Published
Verify messages signed by MegaETH wallets
Readme
MegaETH Wallet Server Verify
MegaETH wallets use Porto contracts as their smart wallets and passkeys to sign transactions.
This package wraps up the logic to confirm that the signing wallet has access to the account.
Usage
Create config for a SIWE message you want to verify.
import {
getMessageToSign,
type MessageConfig,
verifySignature,
} from '@megaeth-labs/wallet-server-verfy';
// Create your config
const config: MessageConfig = {
scheme: 'https',
domain: 'localhost:3000', // Your domain
statement: 'Welcome to My App', // The message to show the user
uri: 'http://localhost:3000', // URL of your app
chainId: 4326 // Mainnet
}
// In your API, get the message to sign and return to the client
const response: MessageToSign = getMessageToSign(config, walletAddress);
// Client signs the message and sends it back to your server
const signedRequest: MessageToConfirm = {
...response,
signature: '0x...'
}
// Verify the signature and access of the signing wallet to the account
await verifySignature(config, signedRequest);Errors
- INVALID_SIGNATURE: The signature of the signing wallet could not be verified
- ACCOUNT_NOT_FOUND: The account to access is not registered on the network
- ACCESS_DENIED: The account exists, but the signing wallet does not have access to it
