Bitkeep JS 钱包相关 APIs
bitkeep.js
是 Bitget Wallet 对外提供的一项钱包 Bridge API 。安装 BGW 钱包后你可以使用此API与钱包交互。
判断 Bitget Wallet 身份
js
// check the UserAgent include "BitKeep"
var isBitKeep = navigator.userAgent.indexOf('BitKeep') > 0;
// check the var
var isBitKeep = window.isBitKeep;
// check the UserAgent include "BitKeep"
var isBitKeep = navigator.userAgent.indexOf('BitKeep') > 0;
// check the var
var isBitKeep = window.isBitKeep;
获取钱包身份
参数:
callback
- function: (error, data) => {}
js
const callback = (err, data) => {
if (err){
//err catch
}
//todo ..
}
BitKeepInvoke.getIdentity(callback);
const callback = (err, data) => {
if (err){
//err catch
}
//todo ..
}
BitKeepInvoke.getIdentity(callback);
获取钱包地址
参数:
callback
- function: (error, data) => {}
js
const callback = (err, data) => {
if (err){
//err catch
}
//todo ..
}
BitKeepInvoke.getAddress(callback);
const callback = (err, data) => {
if (err){
//err catch
}
//todo ..
}
BitKeepInvoke.getAddress(callback);
选择主币
参数:
callback
- function: (error, data) => {}
js
const callback = (err, data) => {
if (err){
//err catch
}
//todo ..
}
BitKeepInvoke.selectCoin(callback);
const callback = (err, data) => {
if (err){
//err catch
}
//todo ..
}
BitKeepInvoke.selectCoin(callback);
交易
javascript
BitKeepInvoke.pay(ChainCoin, Params,Callback);
//Chain Coin Transfer
BitKeepInvoke.pay("eth", {
"coin": "eth",
"to": "0x.....",
"amount": "0.1",
"gas": "400000"
}, function(err, reply){
if (err){
//err catch
}
//...
});
//Token Transfer
BitKeepInvoke.pay("eth", {
"coin": "uni",
"contract": "token contract",
"to": "0x.....",
"amount": "0.1",
"gas": "400000"
}, function(err, reply){
if (err){
//err catch
}
//...
});
//Call Contract
BitKeepInvoke.pay("eth", {
"coin": "uni",
"to": "token contract",
"data": "abi data",
"amount": "0.1",
"gas": "400000"
}, function(err, reply){
if (err){
//err catch
}
//...
});
BitKeepInvoke.pay(ChainCoin, Params,Callback);
//Chain Coin Transfer
BitKeepInvoke.pay("eth", {
"coin": "eth",
"to": "0x.....",
"amount": "0.1",
"gas": "400000"
}, function(err, reply){
if (err){
//err catch
}
//...
});
//Token Transfer
BitKeepInvoke.pay("eth", {
"coin": "uni",
"contract": "token contract",
"to": "0x.....",
"amount": "0.1",
"gas": "400000"
}, function(err, reply){
if (err){
//err catch
}
//...
});
//Call Contract
BitKeepInvoke.pay("eth", {
"coin": "uni",
"to": "token contract",
"data": "abi data",
"amount": "0.1",
"gas": "400000"
}, function(err, reply){
if (err){
//err catch
}
//...
});