Class: GenericEvmAdapter
GenericEvmAdapter provides wallet adapter functionality for EVM wallets like MetaMask via ethers.js or direct EIP-1193 providers.
Defined in: packages/bitbadgesjs-sdk/src/signing/adapters/GenericEvmAdapter.ts:94
GenericEvmAdapter provides wallet adapter functionality for EVM wallets like MetaMask via ethers.js or direct EIP-1193 providers.
EVM transactions are sent through precompile contracts on the BitBadges chain.
Example
// With ethers.js v6
import { BrowserProvider } from 'ethers';
const provider = new BrowserProvider(window.ethereum);
const signer = await provider.getSigner();
const adapter = await GenericEvmAdapter.fromSigner(signer);
const client = new BitBadgesSigningClient({ adapter });
// Direct from window.ethereum
const adapter = await GenericEvmAdapter.fromProvider(window.ethereum);Extends
Implements
Properties
address
readonlyaddress:string
Defined in: packages/bitbadgesjs-sdk/src/signing/adapters/GenericEvmAdapter.ts:96
The address managed by this adapter (BitBadges bb-prefixed for Cosmos, 0x for EVM)
Implementation of
Overrides
chainType
readonlychainType:"evm"
Defined in: packages/bitbadgesjs-sdk/src/signing/adapters/GenericEvmAdapter.ts:95
The chain type this adapter supports
Implementation of
Overrides
Methods
estimateEvmGas()
estimateEvmGas(
tx):Promise<bigint>
Defined in: packages/bitbadgesjs-sdk/src/signing/adapters/GenericEvmAdapter.ts:372
Estimate gas for an EVM transaction via the connected provider.
Parameters
tx
The EVM transaction to estimate
Returns
Promise<bigint>
Estimated gas as bigint
Implementation of
Overrides
BaseWalletAdapter.estimateEvmGas
getPublicKey()
getPublicKey():
Promise<string>
Defined in: packages/bitbadgesjs-sdk/src/signing/adapters/GenericEvmAdapter.ts:275
Get the public key. Note: EVM wallets don't directly expose public keys for Cosmos signing.
Returns
Promise<string>
Implementation of
Overrides
BaseWalletAdapter.getPublicKey
sendEvmTransaction()
sendEvmTransaction(
tx):Promise<string>
Defined in: packages/bitbadgesjs-sdk/src/signing/adapters/GenericEvmAdapter.ts:334
Send an EVM transaction to a precompile contract.
Parameters
tx
The EVM transaction to send
Returns
Promise<string>
The transaction hash
Implementation of
WalletAdapter.sendEvmTransaction
Overrides
BaseWalletAdapter.sendEvmTransaction
signDirect()?
optionalsignDirect(payload,accountNumber):Promise<SigningResult>
Defined in: packages/bitbadgesjs-sdk/src/signing/adapters/WalletAdapter.ts:88
Sign a transaction using Cosmos SignDirect format. Only implemented by Cosmos wallet adapters.
Parameters
payload
The transaction payload containing signBytes
accountNumber
string | number | bigint
The account number on the blockchain. Post-v34 accounts get hash-derived numbers above 2^53 — pass the chain's string value or a bigint; never Number() it.
Returns
Promise<SigningResult>
The signature and public key
Implementation of
Inherited from
signTypedData()
signTypedData(
typed):Promise<string>
Defined in: packages/bitbadgesjs-sdk/src/signing/adapters/GenericEvmAdapter.ts:296
Sign EIP-712 typed-data with the connected EVM wallet.
The output is a 0x...-prefixed 65-byte hex signature (r || s || v).
Pair with recoverEvmPublicKey() from @/eip712 to derive the
pubkey used in the Cosmos AuthInfo, or strip the trailing recovery
byte to feed the chain's ethsecp256k1 verifier directly.
Routes through the wallet's eth_signTypedData_v4 (EIP-1193) when
available, otherwise through ethers' Signer.signTypedData. Native
MetaMask / Privy / Coinbase Smart Wallet take the canonical Cosmos
EVM domain (verifyingContract: "cosmos", salt: "0") without
complaint; ethers v6 hard-rejects it, so prefer the EIP-1193 path
when both are wired.
Parameters
typed
Returns
Promise<string>
Implementation of
Overrides
BaseWalletAdapter.signTypedData
supportsEvmTransaction()
supportsEvmTransaction():
boolean
Defined in: packages/bitbadgesjs-sdk/src/signing/adapters/GenericEvmAdapter.ts:416
Check if the adapter supports EVM transactions
Returns
boolean
Implementation of
WalletAdapter.supportsEvmTransaction
Overrides
BaseWalletAdapter.supportsEvmTransaction
supportsSignAmino()
supportsSignAmino():
boolean
Defined in: packages/bitbadgesjs-sdk/src/signing/adapters/GenericEvmAdapter.ts:412
Check if the adapter supports Amino signing (legacy)
Returns
boolean
Implementation of
WalletAdapter.supportsSignAmino
Overrides
BaseWalletAdapter.supportsSignAmino
supportsSignDirect()
supportsSignDirect():
boolean
Defined in: packages/bitbadgesjs-sdk/src/signing/adapters/GenericEvmAdapter.ts:408
Check if the adapter supports SignDirect signing
Returns
boolean
Implementation of
WalletAdapter.supportsSignDirect
Overrides
BaseWalletAdapter.supportsSignDirect
supportsSignTypedData()
supportsSignTypedData():
boolean
Defined in: packages/bitbadgesjs-sdk/src/signing/adapters/GenericEvmAdapter.ts:420
Check if the adapter supports EIP-712 typed-data signing
Returns
boolean
Implementation of
WalletAdapter.supportsSignTypedData
Overrides
BaseWalletAdapter.supportsSignTypedData
fromBrowserWallet()
staticfromBrowserWallet(options?):Promise<GenericEvmAdapter>
Defined in: packages/bitbadgesjs-sdk/src/signing/adapters/GenericEvmAdapter.ts:264
Create an adapter from window.ethereum (MetaMask, etc.).
Parameters
options?
Optional configuration including expected chain ID
Returns
Promise<GenericEvmAdapter>
A new GenericEvmAdapter connected to the browser wallet
Throws
Error if expectedChainId is provided and wallet is on wrong network
fromMnemonic()
staticfromMnemonic(mnemonic,evmRpcUrl,options?):Promise<GenericEvmAdapter>
Defined in: packages/bitbadgesjs-sdk/src/signing/adapters/GenericEvmAdapter.ts:206
Create an adapter from a mnemonic phrase for server-side EVM signing.
Uses ETH HD path (m/44'/60'/0'/0/0) and connects to an EVM JSON-RPC provider.
Security Note: Only use in secure server-side environments.
Parameters
mnemonic
string
The BIP-39 mnemonic phrase (12 or 24 words)
evmRpcUrl
string
The EVM JSON-RPC endpoint URL
options?
Optional configuration including expected chain ID
Returns
Promise<GenericEvmAdapter>
A new GenericEvmAdapter for server-side signing
Example
const adapter = await GenericEvmAdapter.fromMnemonic(
'word1 word2 ...',
'https://evm-rpc-testnet.bitbadges.io'
);
const client = new BitBadgesSigningClient({ adapter, network: 'testnet' });fromPrivateKey()
staticfromPrivateKey(privateKey,evmRpcUrl,options?):Promise<GenericEvmAdapter>
Defined in: packages/bitbadgesjs-sdk/src/signing/adapters/GenericEvmAdapter.ts:237
Create an adapter from a private key for server-side EVM signing.
Connects to an EVM JSON-RPC provider for transaction broadcasting.
Security Note: Only use in secure server-side environments.
Parameters
privateKey
string
The private key (hex string, with or without 0x prefix)
evmRpcUrl
string
The EVM JSON-RPC endpoint URL
options?
Optional configuration including expected chain ID
Returns
Promise<GenericEvmAdapter>
A new GenericEvmAdapter for server-side signing
fromProvider()
staticfromProvider(provider,options?):Promise<GenericEvmAdapter>
Defined in: packages/bitbadgesjs-sdk/src/signing/adapters/GenericEvmAdapter.ts:169
Create an adapter from an EIP-1193 provider (like window.ethereum).
Parameters
provider
EIP1193Provider
An EIP-1193 compliant provider
options?
Optional configuration including expected chain ID
Returns
Promise<GenericEvmAdapter>
A new GenericEvmAdapter connected to the provider
Throws
Error if expectedChainId is provided and wallet is on wrong network
fromSigner()
staticfromSigner(signer,options?):Promise<GenericEvmAdapter>
Defined in: packages/bitbadgesjs-sdk/src/signing/adapters/GenericEvmAdapter.ts:144
Create an adapter from an ethers.js Signer (v6).
Parameters
signer
EthersSigner
An ethers.js Signer instance
options?
Optional configuration including expected chain ID
Returns
Promise<GenericEvmAdapter>
A new GenericEvmAdapter connected to the signer
Throws
Error if expectedChainId is provided and wallet is on wrong network