Standard Wallet Methods
| Method | Parameters | Returns | Description |
|---|---|---|---|
enable | None | Promise<Array> | Connects wallet and returns account addresses |
isConnected | None | boolean | Checks wallet connection status |
addCurrency | None | Promise | Adds token to wallet tracking |
switchChain | (method, data) | Promise | Switches blockchain networks |
disconnect | None | Promise | Terminates wallet connection |
signPersonalMessage | (data) | Promise<string> | Signs arbitrary messages |
signTypedMessage | (data) | Promise<string> | Signs EIP-712 structured data |
request | (payload, callback) | Promise | Handles generic Ethereum RPC calls |
Provider Initialization
const provider = window.bitkeep.ethereum;Connection Workflow
enable()
Requests account access from user's Ethereum wallet.
Usage:
/**
* @returns {string[]} Array of connected addresses
*/
const accounts = await provider.enable();isConnected()
Verifies active wallet-dApp connection.
Usage:
const connected = await provider.isConnected(); // Returns booleanMessage Signing
SignPersonalMessage()
Implements personal_sign for message authentication.
interface PersonalSignMessage {
method: 'personal_sign';
params: {
msgHex: string; // Hex-encoded message
from: string; // Signing address
};
}
const signature = await provider.signPersonalMessage(message);👉 Learn advanced signing techniques
Network Management
wallet_switchEthereumChain
Changes active blockchain network.
Usage:
const params = {
method: 'wallet_switchEthereumChain',
params: [{ chainId: '0xA4B1' }] // Arbitrum chainID
};
await provider.request(params);wallet_addEthereumChain
Programmatically adds new networks.
const params = {
method: 'wallet_addEthereumChain',
params: [{
chainId: '0xA4B1',
chainName: 'Arbitrum One',
nativeCurrency: {
name: 'ETH',
symbol: 'ETH',
decimals: 18
},
rpcUrls: ['https://arb1.arbitrum.io/rpc']
}]
};
await provider.request(params);Structured Data Signing (EIP-712)
SignTypedDataV4()
Implements EIP-712 standard for complex data signing.
const typedData = {
types: {
EIP712Domain: [
{ name: 'name', type: 'string' },
{ name: 'version', type: 'string' }
],
Message: [
{ name: 'content', type: 'string' }
]
},
domain: {
name: 'Example App',
version: '1'
},
primaryType: 'Message',
message: {
content: 'Hello, EIP-712!'
}
};
const signature = await provider.request({
method: 'eth_signTypedData_v4',
params: [account, JSON.stringify(typedData)]
});Token Management
wallet_watchAsset()
Tracks new tokens per EIP-747.
await provider.request({
method: 'wallet_watchAsset',
params: {
type: 'ERC20',
options: {
address: '0xContractAddress',
symbol: 'TKN',
decimals: 18,
image: 'https://example.com/token.png'
}
}
});Transaction Processing
eth_sendTransaction()
Handles standard ETH transfers.
const txHash = await provider.request({
method: 'eth_sendTransaction',
params: [{
from: accounts[0],
to: '0xRecipientAddress',
value: '0xde0b6b3a7640000' // 1 ETH
}]
});👉 Master transaction optimization
FAQ Section
Q: How do I handle different Ethereum chains?
A: Use wallet_switchEthereumChain for existing networks and wallet_addEthereumChain for new networks. Always include complete chain metadata.
Q: What's the difference between personal_sign and signTypedData?
A: personal_sign handles raw messages, while signTypedData follows EIP-712 for structured data with type information.
Q: How can I improve transaction success rates?
A: 1) Estimate gas properly 2) Use appropriate gas prices 3) Handle nonce management carefully 4) Consider using EIP-1559 parameters.
Q: Why would wallet_watchAsset fail?
A: Common reasons include incorrect token metadata, unsupported token standards, or user rejection.
Best Practices Checklist
- Always verify chain ID before transactions
- Implement proper error handling for RPC calls
- Use EIP-1193 provider standards for compatibility
- Include user-friendly error messages
- Consider implementing session management for persistent connections
For more advanced integration scenarios, consult our developer resources.