-
TokenPocket 已经兼容 Scatter(EOS)、Metamask(ETH)、TronLink(TRON)、IWallet(IOST)、Phantom(Solana) 协议。已经支持了Scatter, MetaMask, TronLink, iWallet, Phantom 插件的Dapp可以直接在钱包内使用Dapp浏览器体验,无需再使用我们这个SDK(有钱包相关的接口如全屏,旋转等需求可另外引用该sdk不冲突)。
-
这个sdk 只针对移动端 TokenPocket
-
TokenPocket is already compatible with Scatter, Metamask,TronLink, Phantom and IWallet. You can input your URL in the Dapp browser inside the TP Wallet without any additional development.
-
This sdk is only for mobile TokenPocket
-
我们还提供了 Android & iOS SDK 可以提供授权登录转账,执行action的操作
-
We also have an Android&iOS SDK for interact with TokenPocket
-
You can add vConsole https://www.npmjs.com/package/vconsole to debug in TokenPocket wallet.
npm install tp-js-sdk
请在TokenPocket中使用该SDK。 请在发现 -> DApp浏览器中 开发调试
Open your site in TokenPocket as a Dapp. Develope and test in Discover -> DappBrowser.
Npm
var tp = require('tp-js-sdk')
console.log(tp.isConnected());
Browser
<script src="./dist/tp.js"></script>
<script>
console.log(tp.isConnected());
</script>
- Javascript SDK for TokenPocket Dapp.
- Installation
- Usage
- Contents
- 1. COMMON
- 1.0 Enum Blockchains
- 1.1 tp.getAppInfo
- 1.2 tp.getWalletList (Deprecated)
- 1.3 tp.getDeviceId
- 1.4 tp.shareNewsToSNS
- 1.5 tp.invokeQRScanner
- 1.6 tp.getCurrentWallet
- 1.7 tp.getWallet
- 1.9 tp.back
- 1.10 tp.close
- 1.11 tp.fullScreen
- 1.12 tp.importWallet
- 1.13 tp.setMenubar
- [1.14 tp.startChat (Removed)](#1.14-tp.startchat-(removed))
- 1.15 tp.saveImage
- 1.16 tp.rollHorizontal
- 1.17 tp.popGestureRecognizerEnable
- 1.18 tp.forwardNavigationGesturesEnable
- 1.19 tp.getNodeUrl
- 1.20 tp.isDarkMode
- 2.EOS
- 3. ETH (EVM)
- 4.ENU
- 5.COSMOS
- 6.IOST
- 7.TRON
- 8.MOAC
- 9.Jingtum
- 10.OKExChanin
- 11.Polkadot Kusama etc.
- 12.HECO BSC OKT
- 13.solana
- 14. btc
- 15. Aptos
- 16. SUI
- 1. COMMON
eth,jingtum,moac,eos,enu,bos,iost,cosmos,binance,tron,btc,bsc,dot,
kusama,heco,okexchain,oktest,matic,hsc,oec,subgame,klaytn,avax,arb,
ftm,op,solana,gnosis,wax,moonbeam,aurora,harmony,kcc,cfxevm,planton,
bttc,gt,halo,etc,arbnova,aptos,doge,fvm,zksync,eosevm,sui,mantle,
linea,base,opbnb,polygonzkevm,core,happ,scroll,zkfair,manta,bevm,
metis,zeta,kroma,merlin,blast,bitlayer,xlayer,mint,ton
tp.getAppInfo()
Object
:
result
:Boolean
data
:Object
name
:String
system
:String
version
:String
sys_version
:String
msg
:String
tp.getAppInfo().then(console.log)
> {
result: true,
data: {
name: 'TokenPocket',
system: 'android',
version: '0.3.4',
sys_version: '26'
},
msg: 'success'
}
tp.getDeviceId()
Object
:
device_id
:String
tp.getDeviceId().then(console.log)
> {
device_id: 'dexa23333'
}
分享到各个社交媒体
Share to SNS
tp.shareNewsToSNS(params)
params
- Object
:
title
:String
desc
:String
url
:String
tp.shareNewsToSNS({
title: 'TokenPocket',
desc: 'Your Universal Wallet',
url: 'https://www.mytokenpocket.vip/'
})
扫码
Scan QRcode
tp.invokeQRScanner()
String
tp.invokeQRScanner().then(console.log)
> "abcdefg"
获取用户当前钱包信息
Get user's current wallet info
tp.getCurrentWallet()
Object
:
result
:Boolean
data
:Object
name
:String
address
:String
blockchain
:String
msg
:String
tp.getCurrentWallet().then(console.log)
> {
result: true,
data: {
name: 'itokenpocket',
address: 'EOSaaaaaaaaabbbbbbbb',
blockchain: 'eos'
},
msg: 'success'
}
获取/切换 用户钱包地址
Get / Switch User's Wallet
tp.getWallet(params)
params
- Object
:
walletTypes
:Array
['eth', 'btc'] // Enum blockchainsswitch
:Boolean
switch current wallet or not
Object
:
result
:Boolean
data
:Object
name
:String
address
:String
blockchain
:String
msg
:String
tp.getWallet({walletTypes: ['eth', 'bsc', 'dot'], switch: false}).then(console.log)
> {
result: true,
data: [
{
name: 'ethwallet11',
address: '0x40e5A542087FA4b966209707177b103d158Fd3A4',
blockchain: 'eth'
}
],
msg: 'success'
}
tp.back()
tp.back()
关闭页面
Close the page
tp.close()
tp.close()
全屏页面
Fullscreen the page.
tp.fullScreen(params)
params
- Object
:
fullScreen
:Number
1 - fullScreen, 0 - cancel
tp.fullScreen({
fullScreen: 0
})
钱包导入界面
Invoke the wallet importing window
tp.importWallet(blockchain)
blockchain
- String
: 'eos' | 'eth' | 'enu' | 'moac'
tp.importWallet('eos');
全屏时 设置dapp浏览器导航条可见性
When the fullscreen
is on, set the dapp browser's navbar visiblity
tp.setMenubar(params)
params
- Object
:
flag
:Number
1 - open, 0 - close(default)
tp.setMenubar({
flag: 1
});
跳到TP聊天 (已移除)
Open TP IM (Removed)
tp.startChat(params)
params
- Object
:
sessionType
:Number
私聊是0 群聊是1account
:String
私聊是目标用户的账号(eos,iost等)或地址(eth,moac等), 群聊是群的idblockchain
:Number
只有私聊需要填, 私聊时目标用户的底层 eth|jingtum|moac|eos|enu|bos|iost
tp.startChat({
account: 'itokenpocket',
sessionType: 0,
blockchain: 'eos'
});
保存图片
Save image
tp.saveImage(params)
params
- Object
:
url
:String
image's url
tp.saveImage({
url: 'https://dapp.mytokenpocket.vip/tokenpocket_logo.png'
});
横屏
rotate the screen horizontal
tp.rollHorizontal(params)
params
- Object
:
horizontal
:Boolean
tp.rollHorizontal({
horizontal: true
});
禁止iOS自带的左滑手势返回,对安卓无影响
Disable iOS's left-sliding gesture to return. There is no effect on Android
tp.popGestureRecognizerEnable(params)
params
- Object
:
enable
:Boolean
- default:true
tp.popGestureRecognizerEnable({
enable: false
});
禁止webview自带的左滑手势触发goback
Disable the left sliding gesture by WebView to trigger goback
tp.forwardNavigationGesturesEnable(params)
params
- Object
:
enable
:Boolean
- default:true
tp.forwardNavigationGesturesEnable({
enable: false
});
获取用户某个底层选择的节点信息
Get information about the node selected by the user
tp.getNodeUrl(params)
params
- Object
:
blockchain
:String
-eos
|eth
|iost
| ...
Object
:
-
result
:Boolean
-
data
:Object
nodeUrl
:Stirng
blockchain
:String
-eos
|eth
|iost
| ...
-
msg
:String
tp.getNodeUrl({
blockchain: 'eos'
}).then(console.log)
> {
result: true,
data: {
nodeUrl: 'https://api.eosbeijing.one/',
blockchain: 'eos'
},
msg: 'success'
}
获取用户是否是暗黑模式
Get whether the user is in dark mode
tp.isDarkMode()
Object
:
result
:Boolean
data
:Boolean
msg
:String
tp.isDarkMode().then(console.log)
> {
result: true,
data: true,
msg: 'success'
}
-
TokenPocket is Compatible with Scatter-js both 1.0 and 2.0.
-
TokenPocket 兼容基于 Scatter-js 1.0 和 2.0 的应用
-
Scatter API: Scatter-JS
-
Check Our Scatter-demo:
-
可以查看我们的 Scatter demo:
tp.eosTokenTransfer(params)
params
- Object
:
from
:String
to
:String
amount
:String|Number
tokenName
:String
precision
:Number|String
contract
:String
memo
:String
- (optional),address
:String
- public key for current account
Object
:
-
result
:Boolean
-
data
:Object
transactionId
:Stirng
tp.eosTokenTransfer({
from: 'abcabcabcabc',
to: 'itokenpocket',
amount: '0.0100',
tokenName: 'EOS',
precision: 4,
contract: 'eosio.token',
memo: 'test',
address: 'EOS7ds9A9FGDsKrdymQ4ynKbMgbCVaaaaaaaaaaa'
}).then(console.log)
> {
result: true,
data: {transactionId: 'b428357c7xxxxxxxxxxxxxx'}
}
tp.pushEosAction(params)
params
- Object
:
actions
:Array
- Standard eos actionsaccount
:String
- current accountaddress
:String
- public key for current account
Object
:
result
:Boolean
data
:Object
transactionId
:Stirng
tp.pushEosAction({
actions: [
{
account: 'eosio.token',
name: 'transfer',
authorization: [{
actor: 'aaaabbbbcccc',
permission: 'active'
}],
data: {
from: 'aaaabbbbcccc',
to: 'itokenpocket',
quantity: '1.3000 EOS',
memo: 'something to say'
}
},
{
account: "eosio",
name: "delegatebw",
authorization: [
{
actor: 'aaaabbbbcccc',
permission: "active"
}
],
data: {
from: 'aaaabbbbcccc',
receiver: 'itokenpocket',
stake_net_quantity: "0.0100 EOS",
stake_cpu_quantity: "0.0100 EOS",
transfer: 0
}
}
],
address: 'EOS7ds9A9FGDsKrdymQ4ynKbMgbCVaaaaaaaaaaa',
account: 'aaaabbbbcccc'
}).then(console.log)
> {
result: true,
data: {transactionId: 'b428357c7xxxxxxxxxxxxxx'}
}
tp.getEosBalance(params)
params
- Object
:
account
:String
contract
:String
symbol
:String
Object
:
result
:Boolean
data
:Object
symbol
:String
balance
:String
contract
:String
account
:String
msg
:String
tp.getEosBalance({
account: 'itokenpocket',
contract: 'eosio.token',
symbol: 'EOS'
}).then(console.log)
> {
result: true,
data:{"symbol":"EOS","balance":"["142.2648 EOS"]","contract":"eosio.token","account":"itokenpocket"},
msg: 'success'
}
获取合约内table数据
tp.getEosTableRows(params)
params
- Object
:
json
:Boolean
code
:String
scope
:String
table
:String
table_key
:Stirng
lower_bound
:String
upper_bound
:String
limit
:Number
Object
:
result
:Boolean
data
:Object
rows
:Array
msg
:String
tp.getTableRows({
json: true,
code: 'abcabcabcabc',
scope: 'abcabcabcabc',
table: 'table1',
lower_bound: '10',
limit: 20
}).then(console.log)
> {
result: true,
data:{rows: [{a: 1, b: 'name' }, ...]},
msg: 'success'
}
tp.getEosAccountInfo(params)
params
- Object
:
account
:String
Object
:
result
:Boolean
data
:Object
- Standard account objectmsg
:String
tp.getEosAccountInfo({
account: 'itokenpocket'
}).then(console.log)
> {
result: true,
data:{"account_name":"itokenpocket",..., "is_proxy":0},
msg: 'success'
}
tp.getEosTransactionRecord(params)
params
- Object
:
account
:String
start
:Number
- default: 0count
:Number
- default: 10sort
:String
- 'desc | asc' default: desctoken
:String
- optionalcontract
:String
- optional
Object
:
result
:Boolean
data
:Object
- Standard account objectmsg
:String
tp.getEosTransactionRecord({
start: 10,
count: 20,
account: 'itokenpocket',
token: 'EOS',
sort: 'desc',
contract: 'eosio.token'
}).then(console.log)
> {
result: true,
data: [{
"title": "",
"comment": "",
"hid": "4bd63a191a1e3e00f13fe6df55d0c08803800a5e7cd0d0b15c92d52b3c42285e",
"producer": "bp4",
"timestamp": 1531578890,
"action_index": 2,
"account": "eosio",
"name": "delegatebw",
"from": "tokenpocket1",
"to": "clementtes43",
"blockNum": 4390980,
"quantity": "0.2000000000 EOS",
"count": "0.2000000000",
"symbol": "EOS",
"memo": "",
"maximum_upply": "",
"ram_price": "",
"bytes": "",
"status": 1,
"data": "",
real_value:"0.2000000000"
}, ...],
msg: 'success'
}
-
TokenPocket is Compatible with Metamask.
-
About Metamask
-
Webview injected an
window.ethereum
object. -
You can also using
window.tokenpocket.ethereum
-
We also supported eip-6963 https://eips.ethereum.org/EIPS/eip-6963
- About Ironman
tp.enuTokenTransfer(params)
params
- Object
:
from
:String
to
:String
amount
:String|Number
tokenName
:String
precision
:Number|String
contract
:String
memo
:String
- (optional),address
:String
- public key for current account
Object
:
-
result
:Boolean
-
data
:Object
transactionId
:Stirng
tp.enuTokenTransfer({
from: 'abcabcabcabc',
to: 'itokenpocket',
amount: '0.0100',
tokenName: 'ENU',
precision: 4,
contract: 'enu.token',
memo: 'test',
address: 'E7ds9A9FGDsKrdymQ4ynKbMgbCVaaaaaaaaaaa'
}).then(console.log)
> {
result: true,
data: {transactionId: 'b428357c7xxxxxxxxxxxxxx'}
}
tp.pushEnuAction(params)
params
- Object
:
actions
:Array
- Standard enu actionsaccount
:String
- current accountaddress
:String
- public key for current account
Object
:
result
:Boolean
data
:Object
transactionId
:Stirng
tp.pushEnuAction({
actions: [
{
account: 'enu.token',
name: 'transfer',
authorization: [{
actor: 'aaaabbbbcccc',
permission: 'active'
}],
data: {
from: 'aaaabbbbcccc',
to: 'itokenpocket',
quantity: '1.3000 ENU',
memo: 'something to say'
}
},
{
account: "enumivo",
name: "delegatebw",
authorization: [
{
actor: 'aaaabbbbcccc',
permission: "active"
}
],
data: {
from: 'aaaabbbbcccc',
receiver: 'itokenpocket',
stake_net_quantity: "0.0100 ENU",
stake_cpu_quantity: "0.0100 ENU",
transfer: 0
}
}
],
address: 'E7ds9A9FGDsKrdymQ4ynKbMgbCVaaaaaaaaaaa',
account: 'aaaabbbbcccc'
}).then(console.log)
> {
result: true,
data: {transactionId: 'b428357c7xxxxxxxxxxxxxx'}
}
tp.getEnuBalance(params)
params
- Object
:
account
:String
contract
:String
symbol
:String
Object
:
result
:Boolean
data
:Object
symbol
:String
balance
:String
contract
:String
account
:String
msg
:String
tp.getEnuBalance({
account: 'itokenpocket',
contract: 'enu.token',
tokenName: 'ENU'
}).then(console.log)
> {
result: true,
data:{"symbol":"ENU","balance":"["142.2648 ENU"]","contract":"enu.token","account":"itokenpocket"},
msg: 'success'
}
获取合约内table数据
tp.getEnuTableRows(params)
params
- Object
:
json
:Boolean
code
:String
scope
:String
table
:String
table_key
:Stirng
lower_bound
:String
upper_bound
:String
limit
:Number
Object
:
result
:Boolean
data
:Object
rows
:Array
msg
:String
tp.getTableRows({
json: true,
code: 'abcabcabcabc',
scope: 'abcabcabcabc',
table: 'table1',
lower_bound: '10',
limit: 20
}).then(console.log)
> {
result: true,
data:{rows: [{a: 1, b: 'name' }, ...]},
msg: 'success'
}
tp.getEnuAccountInfo(params)
params
- Object
:
account
:String
Object
:
result
:Boolean
data
:Object
- Standard account objectmsg
:String
tp.getEnuAccountInfo({
account: 'itokenpocket'
}).then(console.log)
> {
result: true,
data:{"account_name":"itokenpocket",..., "is_proxy":0}},
msg: 'success'
}
tp.getEnuTransactionRecord(params)
params
- Object
:
account
:String
start
:Number
- default: 0count
:Number
- default: 10sort
:String
- 'desc | asc' default: desctoken
:String
- optionalcontract
:String
- optional
Object
:
result
:Boolean
data
:Object
- Standard account objectmsg
:String
tp.getEnuTransactionRecord({
start: 10,
count: 20,
account: 'itokenpocket',
token: 'ENU',
sort: 'desc',
contract: 'enu.token'
}).then(console.log)
> {
result: true,
data: [{
"title": "",
"comment": "",
"hid": "4bd63a191a1e3e00f13fe6df55d0c08803800a5e7cd0d0b15c92d52b3c42285e",
"producer": "bp4",
"timestamp": 1531578890,
"action_index": 2,
"account": "enumivo",
"name": "delegatebw",
"from": "tokenpocket1",
"to": "clementtes43",
"blockNum": 4390980,
"quantity": "0.2000000000 ENU",
"count": "0.2000000000",
"symbol": "ENU",
"memo": "",
"maximum_upply": "",
"ram_price": "",
"bytes": "",
"status": 1,
"data": "",
real_value:"0.2000000000"
}, ...],
msg: 'success'
}
tp.signCosmosTransaction(stdTx)
stdTx
- Object
:
from
:String
chain_id
:String
account_number
:String | Number
sequence
:String | Number
fees
:Object
gas
:String
memo
:String
type
:String
msg
:Object
Object
:
-
result
:Boolean
-
data
:Object
-
msg
:String
tp.signCosmosTransaction({
"from": "cosmos1njg8uq4ek9y9yourfromaddress",
"chain_id": "cosmoshub-2",
"account_number": 1756,
"sequence": 3,
"fees": {
"denom": "uatom",
"amount": 500
},
"gas": 20000,
"memo": "",
"type": "transfer",
"msg": {
"to": "cosmos1njg8uq4ek9y9yourfromaddress",
"coins": [{
"denom": "uatom",
"amount": 100000
}]
}
}).then(console.log)
> {
"result": true,
"data": {
"tx": {
"signatures": [{
"pub_key": {
"type": "tendermint/PubKeySecp256k1",
"value": "AkG3bCO5p9MO8a1ABGYtyS8ed4aZuBKEY+"
},
"signature": "K7XCuz/ucESBZnQS94uOHZnJCUbFuWH2x659/3O04ihZaZT99cx+aaaaaaaaaaa=="
}],
"memo": "",
"msg": [{
"type": "cosmos-sdk/MsgSend",
"value": {
"amount": [{
"amount": "100000",
"denom": "uatom"
}],
"from_address": "cosmos1njg8uq4ek9y9yourfromaddress",
"to_address": "cosmos1njg8uq4ek9y9yourtoaddress"
}
}],
"fee": {
"amount": [{
"denom": "uatom",
"amount": "500"
}],
"gas": "20000"
}
},
"mode": "sync"
},
"msg": "success"
}
tp.cosmosArbitrarySignature(from, stdTx)
from
- String
: your address
stdTx
- String
: stdTx string
Object
:
result
:Boolean
data
:Object
msg
:String
var stdTx = {
"account_number": "0",
"chain_id": "testing",
"fee": {
"amount": [{
"amount": "0",
"denom": "stake"
}],
"gas": "500000"
},
"memo": "",
"msgs": [{
"amount": {
"amount": "50000000",
"denom": "stake"
},
"from_address": "cosmos1gw8w...l48gl5",
"type": "normal"
}],
"sequence": "0"
}
tp.cosmosArbitrarySignature('cosmos1gw8w...l48gl5', JSON.stringify(stdTx)).then(console.log)
> {
"result": true,
"data": {
"pub_key": [235, 90, 233, 135, 33, 2, 65, 183, 108, 35, 185, 167, 211, 14, 241, 173, 64, 4, 102, 45, 201, 47, 30, 119, 134, 153, 184, 26, 4, 32, 123, 216, 219, 95, 19, 140, 84, 254],
"signature": [19, 225, 27, 122, 188, 73, 69, 101, 136, 152, 100, 35, 2, 205, 66, 220, 20, 237, 160, 171, 36, 178, 195, 45, 161, 14, 86, 41, 21, 143, 222, 27, 40, 139, 233, 48, 48, 117, 251, 105, 144, 119, 187, 181, 124, 113, 167, 138, 15, 201, 98, 71, 116, 184, 114, 98, 240, 140, 224, 4, 251, 93, 60, 15]
},
"msg": "success"
}
- TokenPocket is Compatible with IWalletJS.
- TokenPocket 兼容基于 IWalletJS 的应用.
- IWalletJS API: IWalletJS
-
TokenPocket is Compatible with TronLink.
-
TokenPocket 兼容基于 TronLink 的应用.
-
Webview 内有注入
tronWeb
对象. -
Webview injected a
tronWeb
object.
tp.sendMoacTransaction(params)
params
- Object
:
from
:String
to
:String
gasPrice
:String|Number
gasLimit
:String|Number
data
:String
value
:String|Number
- (optional)chainId
:Number
- (optional)via
:String
- (optional)shardingFlag
:Number
- (optional)
Object
:
result
:Boolean
data
:String
- txhash
tp.sendMoacTransaction({
from: '0xaaaaaaa',
to: '0xaaaaaab',
gasPrice: 100000000,
gasLimit: 60000,
data: '0xaawefwefwefwefwefef',
value: 1000000000,
chainId: 99,
via: '',
shardingFlag: 0,
}).then(console.log)
> {
result: true,
data: '0xe1063e225d4365b79c30132077e82777c0966844f545ddecc017965c0b551f7e'
}
tp.signMoacTransaction(params)
params
- Object
:
from
:String
to
:String
gasPrice
:String|Number
gasLimit
:String|Number
data
:String
value
:String|Number
- (optional)chainId
:Number
- (optional)via
:String
- (optional)shardingFlag
:Number
- (optional)
Object
:
result
:Boolean
data
:String
- signed data
tp.signMoacTransaction({
from: '0xaaaaaaa',
to: '0xaaaaaab',
gasPrice: 100000000,
gasLimit: 60000,
data: '0xaawefwefwefwefwefef',
value: 1000000000,
chainId: 99,
via: '',
shardingFlag: 0,
}).then(console.log)
> {
result: true,
data: '0xf8ef8201598504a817c800830298109490cb7b42a9cb3accbe665e7d6cdde4ab346eca1483030d40b88402ef9b6b0000000000000000'
}
tp.moacTokenTransfer(params)
params
- Object
:
from
:String
to
:String
amount
:String|Number
gasLimit
:String|Number
tokenName
:String
decimal
:String|Number
contract
:String
Object
:
result
:Boolean
data
:Object
transactionId
:Stirng
tp.moacTokenTransfer({
from: '0xaaaaaaa',
to: '0xaaaaaab',
amount: '100',
gasLimit: 60000,
tokenName: 'MOAC',
decimal: 18,
contract: ''
}).then(console.log)
> {
result: true,
data: {transactionId: 'b428357c7xxxxxxxxxxxxxx'}
}
tp.signJingtumTransaction(params)
params
- Object
: tx object
Account
:String
Fee
:Float
TakerGets
:String|Object
TakerPays
:String|Object
TransactionType
:String
Sequence
:Number
OfferSequence
:Number
Amount
:String
Destination
:String
Object
:
result
:Boolean
data
:String
- signedDatamsg
:String
tp.signJingtumTransaction({
"Account":"j47J1UriYXXXXXXXXXXXX",
"Fee": 0.00001,
"Flags": 524288,
"TakerGets":"111",
"TakerPays":{
"currency":"CNY",
"issuer":"jGa9J9TkqtBcUoHe2zqhVFFbgUVED6o9or",
"value":"1.2321"
},
"TransactionType":"OfferCreate",
"Sequence":4368
}).then(console.log)
> {
result: true,
data: 'e1063e225d43650000000111...',
msg: ''
}
tp.signOkexchainTransaction(tx, address)
tx
- Object
:
chain_id
:String
account_number
:String | Number
sequence
:String | Number
fees
:Object
memo
:String
msgs
:Array
address
- String
: from address
Object
:
-
result
:Boolean
-
data
:Object
-
msg
:String
tp.signOkexchainTransaction({
"account_number":"222",
"chain_id":"okexchain-65",
"fee": {"amount": [{"amount":"0.020000000000000000","denom":"okt"}],"gas":"200000"},
"memo":"ahah",
"msgs":[
{
"type": "okexchain/token/MsgTransfer",
"value": {
"amount": [{"amount":"1.000000000000000000","denom":"okt"}],
"from_address": "okexchainxxxxxxxxfrom",
"to_address": "okexchainxxxxxxxxto"
}
}
],
"sequence":"15"
}, 'okexchainxxxxxxxxfrom').then(console.log)
> {
"result": true,
"data": {
"signatures": [{
"pub_key": {
"type": "tendermint/PubKeySecp256k1",
"value": [buffer]
},
"signature": [buffer]
}],
},
"msg": "success"
}
TokenPocket is compatible with Polkadot{.js} extension please check the offical doc:
TokenPocket is compatible with metamask, please check the offiacl doc:
Check https://github.com/solana-labs/wallet-adapter for using solana wallets including TokenPocket.
Or you can using the window.solana
Object directly in the webview.
We also supported the wallet-standard
protocol: https://github.com/solana-labs/wallet-standard
await window.solana.connect();
const publicKey = window.solana.publicKey.toBase58();
const network = "<NETWORK_URL>";
const connection = new Connection(network);
const transaction = new Transaction();
const signedTransaction = await window.solana.signTransaction(transaction);
const signature = await connection.sendRawTransaction(signedTransaction.serialize());
const encodedMessage = new TextEncoder().encode('Your message');
const signedMessage = await window.solana.signMessage(encodedMessage, "utf8");
TokenPocket is full compatible with unisat API which has window.unisat
injected in the browser.
You can call unisat.getAccounts()
, unisat.signPsbt
, etc.
Full API documents you can check: https://docs.unisat.io/dev/unisat-developer-service/unisat-wallet
Also you can always use window.tokenpocket
to detect if it is tokenpocket wallet.
tp.getCurrentBalance()
Object
:
result
:Boolean
data
:Object
-balance
:String
msg
:String
tp.getCurrentBalance().then(res => console.log)
> {
result: true,
data: {
balance: '0.013'
},
msg: 'success',
}
tp.btcTokenTransfer(params)
params
- Object
:
from
:String
to
:String
amount
:String
Object
:
result
:Boolean
data
:String
msg
:String
tp.btcTokenTransfer({
from: '3FYbry1GTFmxxxxxxxxxxx',
to: '1NVY7Gdng4Ti3bWm1tiPxxxxxxxxx',
amount: '0.0001',
}).then(res => console.log)
> {
result: true,
data: '5420a8f77594e9114c2d97dxxxxxxxxxxxxxxxxxxx', // android
msg: '5420a8f77594e9114c2d97dxxxxxxxxxxxxxxxxxxx', // ios
}
OMNI USDT
tp.usdtTokenTransfer(params)
params
- Object
:
from
:String
to
:String
amount
:String
Object
:
result
:Boolean
data
:String
msg
:String
tp.usdtTokenTransfer({
from: '3FYbry1GTFmxxxxxxxxxxx',
to: '1NVY7Gdng4Ti3bWm1tiPxxxxxxxxx',
amount: '10.02',
}).then(res => console.log)
> {
result: true,
data: '5420a8f77594e9114c2d97dxxxxxxxxxxxxxxxxxxx', // android
msg: '5420a8f77594e9114c2d97dxxxxxxxxxxxxxxxxxxx', // ios
}
const isTokenPocket = window.aptos && aptos.isTokenPocket
aptos.connect().then(console.log)
// {address: '0x1111...', publicKey: '0x22222...'}
aptos.account().then(console.log)
// {address: '0x1111...', publicKey: '0x22222...'}
aptos.getChainId().then(console.log)
// 31
aptos.getNodeUrl().then(console.log)
// 'https://testnet.aptoslabs.com'
aptos.network().then(console.log)
// 'Testnet'
const transaction = {
arguments: ['0x111111...', '112'],
function: '0x1::coin::transfer',
type: 'entry_function_payload',
type_arguments: ['0x1::aptos_coin::TestCoin'],
};
const options = { // optional parameter
max_gas_amount: '1000',
gas_unit_price: '100',
expiration_timestamp_secs: '1646793600',
sequence_number: '10'
}
aptos.signAndSubmitTransaction(transaction, options).then(console.log)
// { hash: "0x1111...", sender: "0x1111", sequence_number: "10", signature: {public_key: '0x222',signature: '0x333', type: 'ed25519_signature'}, payload: {}, max_gas_amount: '1009', gas_unit_price: '100', expiration_timestamp_secs: '1665721856' }
const transaction = {
arguments: ['0x111111...', '112'],
function: '0x1::coin::transfer',
type: 'entry_function_payload',
type_arguments: ['0x1::aptos_coin::TestCoin'],
};
const options = { // optional parameter
max_gas_amount: '1000',
gas_unit_price: '100',
expiration_timestamp_secs: '1646793600',
sequence_number: '10'
}
aptos.signTransaction(transaction, options).then(console.log)
// { "0": 156, "1": 177, "2": 187, "3": 244, "4": 44, ...}
aptos.signMessage({
address?: boolean, // Should we include the address of the account in the message
application?: boolean, // Should we include the domain of the dapp
chainId?: boolean, // Should we include the current chain id the wallet is connected to
message: 'hello world', // The message to be signed and displayed to the user
nonce: '1113' // A nonce the dapp should generate
}).then(console.log)
// return
// {
// address: string,
// application: string,
// chainId: number,
// fullMessage: string, // The message that was generated to sign
// message: string, // The message passed in by the user
// nonce: string,
// prefix: string, // Should always be APTOS
// signature: string // The signed full message
// }
TokenPocket's sui API follow the sui wallet standard:
https://docs.sui.io/standards/wallet-standard
TokenPocket has implemented all features defined in the standard.
TokenPocket's wallet name in sui standard is:
name()
: TokenPocket Wallet
TokenPocket mobile and extension has supported NIP-07