Skip to main content

Function: eip1193ProviderFromEthers()

GalaChain core SDK 1.0.0-rc.8


GalaChain core SDK 1.0.0-rc.8 / index / eip1193ProviderFromEthers

Function: eip1193ProviderFromEthers()

eip1193ProviderFromEthers(provider, options?): BrowserWalletProvider

Defined in: packages/gala-core-sdk/dist/index.d.ts:2012

An EIP-1193 provider over an ethers v6 provider, for BrowserWalletSigner: apps whose wallet connection is an ethers BrowserProvider sign through the very ethers calls they always made, with no hand-written shim.

  • eth_chainId is provider.send('eth_chainId', []): the wallet's LIVE chain. Never provider.getNetwork(), which ethers caches and does not invalidate on chainChanged, so a user who switches networks after connecting would sign against a stale chainId.
  • eth_signTypedData_v4 parses the [account, JSON] params and calls signer.signTypedData(domain, types, message) with EIP712Domain removed from types.
  • personal_sign is options.personalSign(message) when given, else signer.signMessage.
  • Anything else is UNSUPPORTED_WALLET_METHOD; a malformed request is MALFORMED_WALLET_REQUEST; a missing provider is WALLET_UNAVAILABLE.

provider may be null/undefined (nothing connected): a request that needs it then fails with WALLET_UNAVAILABLE rather than at construction, so a signer can be built before the connection state is known.

Parameters​

provider​

EthersLikeProvider | null | undefined

options?​

EthersEip1193Options

Returns​

BrowserWalletProvider

Example​

const signer = new BrowserWalletSigner(eip1193ProviderFromEthers(browserProvider), account, {
scheme: 'eip712',
});