Skip to main content

index/classes/BrowserWalletSigner.md

A personal-sign signer for MetaMask and other EIP-1193 browser wallets.

The chain recovers this signature using the EIP-191 wrap applied by the wallet to personal_sign. This is the browser-wallet path used by the v2 frontend and resolves the bare eth| identity.

Implements​

Constructors​

Constructor​

new BrowserWalletSigner(provider, walletAddress, options?): BrowserWalletSigner

Creates a browser-wallet signer.

Defaults to personal_sign — unchanged from every existing integration, since it only ever resolves the bare eth| identity and changing that silently would be a real behavior break for anyone already depending on it. Pass { scheme: 'eip712' } to correctly resolve a registered client| alias instead, for RequestTrade/AddLiquidity/RemoveLiquidity/ CollectPositionFees (EIP712_CAPABLE_METHODS) — CreatePool and any other method still falls back to personal_sign even in 'eip712' mode, since its EIP-712 signing is a separate, unsolved chain-side problem.

Parameters​

ParameterType
providerBrowserWalletProvider
walletAddressstring
options?{ scheme?: "personal-sign" | "eip712"; }
options.scheme?"personal-sign" | "eip712"

Returns​

BrowserWalletSigner

Examples​

const signer = new BrowserWalletSigner(window.ethereum, '0x0123456789012345678901234567890123456789');
const signed = await signer.signObject('RequestTrade', { token0: 'GALA', token1: 'GUSDC' });
// Correctly resolves a registered client| alias instead of the bare eth| address.
const signer = new BrowserWalletSigner(window.ethereum, walletAddress, { scheme: 'eip712' });

Properties​

PropertyModifierTypeDescription
walletAddressreadonlystringThe selected 0x Ethereum account every signature is requested for.

Methods​

signObject()​

signObject<T>(methodName, dto): Promise<SignedDto<T>>

Signs the DTO with eth_signTypedData_v4 (when constructed with { scheme: 'eip712' } and methodName is in EIP712_CAPABLE_METHODS) or the EIP-1193 personal_sign method (otherwise — the default).

Type Parameters​

Type Parameter
T extends Record<string, unknown>

Parameters​

ParameterType
methodNamestring
dtoT

Returns​

Promise<SignedDto<T>>

Example​

const signed = await signer.signObject('RequestTrade', {
token0: 'GALA',
token1: 'GUSDC',
fee: 3000,
});

Implementation of​

GalaChainSigner.signObject