# How To Connect
This applies to bitkeep, which now supports blockchains, including EVM(Ethereum、BSC、Arbitrum、Polygon、Fantom...), TRON, Solana, Terra Arweave, IOST ... Logo (opens new window) Simple demo (opens new window)
# Integrate
In order to facilitate special detection, the global object is attached with the isBitKeep
attribute.

If bitkeep is not installed, we recommend that you redirect users to our website (opens new window)。
# EVM
Ethereum, Binance Smart Chain, Avalanche-C, Fantom, Polygon, Arbitrum...
chainlist (opens new window) json (opens new window)
The test network is not supported for the time being. If there is no mainnet you are looking for, please Contact us (opens new window)。 to add it.
# Introduction
We provide a Simple demo (opens new window). You can also refer to MetaMask Dapp (opens new window)MetaMask Dapp demo (opens new window). We also support it.
You can also use third-party libraries in conjunction with window.bitkeep.ethereum || window.ethereum
, web3js (opens new window) ethers (opens new window)...
#
# isInstalled
const isBitKeepInstalled = window.isBitKeep &&
(window.bitkeep.ethereum || window.ethereum)
# Provider
You can use window.ethereum || window.bitkeep.ethereum
.
function getProvider(){
const isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ? true : false;
if(!window.isBitKeep || !window.bitkeep){
// if(!isMobile){
// window.open('https://chrome.google.com/webstore/detail/bitkeep-bitcoin-crypto-wa/jiidiaalihmmhddjgbnbgdfflelocpak')
// console.log("please install BitKeep")
// }
return null
}
return window.bitkeep.ethereum || window.ethereum
}
# isCanCover
If you want to distinguish multiple wallets, the provider can use bitkeep.ethereum
and set windows bitkeep.isCanCover=true
# eth_requestAccounts(request authorization to connect)
const Provider = getProvider()
const accounts = await Provider.request({ method: 'eth_requestAccounts'});
const account = accounts[0];
//if used web3
const accounts = await Provider.request({ method: 'eth_requestAccounts'});
const web3 = new Web3(Provider)
const [address] = await web3.eth.getAccounts(); // address
const chainId = await web3.eth.getChainId(); // chainId
# connected
const Provider = getProvider()
Provider.connected
# Event listeners
used eventemitter3 (opens new window)
const Provider = getProvider()
Provider.removeAllListeners();
Provider.on("accountsChanged", ([address]) => {
alert("address changed")
});
Provider.on("chainChanged", async (chainId) => {
alert("chainid changed")
});
# sendTransaction(Transfer)
const Provider = getProvider()
const transactionParameters = {
nonce: '0x00', // ignored by Bitkeep
gasPrice: '0x09184e72a000', // customizable by user during Bitkeep confirmation.
gas: '0x2710', // customizable by user during Bitkeep confirmation.
to: '0x0000000000000000000000000000000000000000', // Required except during contract publications.
from: ethereum.selectedAddress, // must match user's active address.
value: '0x00', // Only required to send ether to the recipient from the initiating external account.
data:
'0x7f7465737432000000000000000000000000000000000000000000000000000000600057', // Optional, but used for defining smart contract creation and interaction.
chainId: '0x3', // Used to prevent transaction reuse across blockchains. Auto-filled by Bitkeep.
};
// txHash is a hex string
// As with any RPC call, it may throw an error
const txHash = await Provider.request({
method: 'eth_sendTransaction',
params: [transactionParameters],
});
// if used web3
const accounts = await Provider.request({ method: 'eth_requestAccounts'});
const web3 = new Web3(Provider);
const result = await web3.eth.sendTransaction({
from: window.bitkeep.ethereum.selectedAddress,
to:"0x0000000000000000000000000000000000000000",
value: web3.utils.toWei("1", "ether"),
});
# Using open source libraries
import Web3Modal, { connectors } from "web3modal"
this.web3Modal = new Web3Modal({
network:'mainnet' ,
cacheProvider: true,
providerOptions: {
"custom-injected": {
display: {
logo: "https://cdn.bitkeep.vip/u_b_69b66a00-a046-11ec-a3eb-f758fa002ae8.png",
name: "BitKeep",
description: "Connect with the provider in your Browser",
},
package: connectors.injected,
connector: async (ProviderPackage: any, options: any) => {
const provider = new ProviderPackage(options)
return provider
}
},
}
});
# Tron
We provide Simple demo (opens new window) and are compatible with tronlink dapp (opens new window).
# isInstalled
const isBitKeepInstalled = window.tronLink && window.isBitKeep
# eth_requestAccounts(request authorization to connect)
try{
await tronLink.request({ method: "tron_requestAccounts" });
const address = tronWeb.defaultAddress.base58;
const balance = await tronWeb.trx.getBalance(address);
}catch{
}
# connected
window.tronWeb.ready
# sendTransaction(Transfer)
var tronweb = window.tronWeb
var tx = await tronweb.transactionBuilder.sendTrx('TW8u1VSwbXY7o7H9kC8HmCNTiSXvD69Uiw', 1000000, tronWeb.defaultAddress.base58)
var signedTx = await tronweb.trx.sign(tx)
var broastTx = await tronweb.trx.sendRawTransaction(signedTx)
console.log(broastTx)
console.log(broastTx.txid)
//Token
let decimal = 18
let Contract = await tronWeb.contract().at("TLa2f6VPqDgRE67v1736s7bJ8Ray5wYjU7") //WIN
const decimalCall = Contract.decimals || Contract.DECIMALS;
if (decimalCall) {
decimal = await decimalCall().call()
}
let broastTx = await Contract.transfer(
"TW8u1VSwbXY7o7H9kC8HmCNTiSXvD69Uiw",
// "0xde0b6b3a7640000"
tronWeb.toHex(2 * Math.pow(10, decimal))
).send(
// {
// feeLimit: 10000000
// }
)
console.log(broastTx)
# solana
We provide a Simple demo (opens new window), and you can also refer to solana-web3 (opens new window)
# IsInstalled
const isBitKeepInstalled = window.isBitKeep && window.bitkeep.solana
# Provider
window.bitkeep.solana || window.solana
# connect(request authorization to connect)
try{
await window.bitkeep.solana.connect();
const publicKey = await window.bitkeep.solana.getAccount()
window.bitkeep.solana.publicKey.toString() // Once the web application is connected to Bitkeep,
}catch{
alert("connected error")
}
# connected
window.bitkeep.solana.connected
const publicKey = await window.bitkeep.solana.getAccount()
window.bitkeep.solana.publicKey.toString() // Once the web application is connected to Bitkeep
# Event listeners
used eventemitter3 (opens new window)
window.bitkeep.solana.on("connect", () => console.log("connected!"))
# sendTransaction
You can refer to the following demo : simple demo (opens new window) web3 demo (opens new window) Token demo (opens new window)
# Terra
You can refer to the following simple demo (opens new window)
# WalletConnect
# EVM(WebApp)
We also support WalletConnect (opens new window). Please refer to walletconnect documentation for details. Similarly, we provide a simple demo (opens new window)
npm install --save @walletconnect/client @walletconnect/qrcode-modal
import WalletConnect from "@walletconnect/client";
import QRCodeModal from "@walletconnect/qrcode-modal";
// Create a connector
const connector = new WalletConnect({
bridge: "https://bridge.walletconnect.org", // Required
qrcodeModal: QRCodeModal,
});
// Check if connection is already established
if (!connector.connected) {
// create new session
connector.createSession();
}
// Subscribe to connection events
connector.on("connect", (error, payload) => {
if (error) {
throw error;
}
// Get provided accounts and chainId
const { accounts, chainId } = payload.params[0];
});
connector.on("session_update", (error, payload) => {
if (error) {
throw error;
}
// Get updated accounts and chainId
const { accounts, chainId } = payload.params[0];
});
connector.on("disconnect", (error, payload) => {
if (error) {
throw error;
}
// Delete connector
});
# EVM(Native App SDK)
Please refer to the WalletConnect Doc (opens new window) and follow to find the docking documentation of your current program
# Used Open source library
for example: web3modal (opens new window)
If you use open source code and need us to support push open source code, please Contact us (opens new window)。