index/classes/BrowserWalletSigner.md
An EIP-1193 signer for MetaMask, Trust Wallet, and compatible wallets.
Example
const signer = new BrowserWalletSigner(window.ethereum, 'eth|1234');
const body = await signer.signTypedData('BuyWithNative', { amount: '1' });
console.log(body.signature);
Extends
BrowserWalletSigner
browser wallet signer
Implements
launchpad signer
Constructors
Constructor
new BrowserWalletSigner(
provider,walletAddress,options?):BrowserWalletSigner
Parameters
| Parameter | Type | Description |
|---|---|---|
provider | BrowserWalletProvider | - |
walletAddress | string | - |
options? | { scheme?: "personal-sign" | "eip712"; } | { scheme: 'eip712' } selects eth_signTypedData_v4 for the DEX methods that support it, which resolves a registered client| alias; the default personal-sign resolves the bare eth| identity. |
options.scheme? | "personal-sign" | "eip712" | - |
Returns
BrowserWalletSigner
Overrides
CoreBrowserWalletSigner.constructor
wallet address browser signer provider eth sign typed data v4 core
Properties
| Property | Modifier | Type | Description | Inherited from |
|---|---|---|---|---|
walletAddress | readonly | string | The selected 0x Ethereum account every signature is requested for. | CoreBrowserWalletSigner.walletAddress |
wallet address core browser signer
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
| Parameter | Type |
|---|---|
methodName | string |
dto | T |
Returns
Promise<SignedDto<T>>
Example
const signed = await signer.signObject('RequestTrade', {
token0: 'GALA',
token1: 'GUSDC',
fee: 3000,
});
Implementation of
Inherited from
CoreBrowserWalletSigner.signObject
sign object method name signed dto eth typed data v4 eip712 capable methods personal launchpad signer core browser wallet
signTypedData()
signTypedData(
method,rawDto):Promise<SignedTypedDataBody>
Sign typed data with the connected wallet's network domain.
Parameters
| Parameter | Type |
|---|---|
method | string |
rawDto | Record<string, unknown> |
Returns
Promise<SignedTypedDataBody>
Example
const body = await signer.signTypedData('BuyWithNative', { amount: '1' });
console.log(body.domain.chainId);
Implementation of
sign typed data raw dto signed body launchpad signer
fromEip1193()
staticfromEip1193(provider,keyAddress,options?):BrowserWalletSigner
A signer for a browser app that holds the wallet's raw EIP-1193 provider (window.ethereum,
an EIP-6963 announcement's provider) rather than an ethers provider. It builds the ethers
BrowserProvider the typed-data path reads the network and the account from, and keeps the raw
request for the DEX signatures (signObject). The bytes signed are exactly those of
new BrowserWalletSigner({ request, getNetwork, getSigner }, key) over that BrowserProvider:
domain { name: network.name, chainId: Number(network.chainId) }, signed by the account the
wallet has selected (getSigner()), refused with WALLET_ACCOUNT_CHANGED when that is not
keyAddress.
Parameters
| Parameter | Type | Description |
|---|---|---|
provider | Eip1193Provider | The wallet's EIP-1193 provider. |
keyAddress | string | The account of the KEY that signs: 0x plus 40 hex digits, or eth| plus 40 hex digits (with or without 0x). Not a client| alias: an alias names no key (it is the walletAddress the SDK declares beside this signer). |
options? | { scheme?: "personal-sign" | "eip712"; } | As the constructor's ({ scheme: 'eip712' } for the DEX methods). |
options.scheme? | "personal-sign" | "eip712" | - |
Returns
BrowserWalletSigner
Throws
GalaSDKError INVALID_WALLET_ADDRESS when keyAddress names no Ethereum account.
Since
9.0.0
Example
const signer = BrowserWalletSigner.fromEip1193(window.ethereum, '0x70997970C51812dc3A010C7d01b50e0d17dc79C8');
const sdk = new LaunchpadSDK({ signer, walletAddress: 'client|618ae395c1c653111d3315be' });
from eip1193 key address browser wallet signer provider sign object get network chain id account changed invalid