| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
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>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:
tp.getAppInfo().then(console.log)
> {
result: true,
data: {
name: 'TokenPocket',
system: 'android',
version: '0.3.4',
sys_version: '26'
},
msg: 'success'
}tp.getDeviceId()Object:
tp.getDeviceId().then(console.log)
> {
device_id: 'dexa23333'
}分享到各个社交媒体
Share to SNS
tp.shareNewsToSNS(params)params- Object:
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:
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:
Object:
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:
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:
tp.setMenubar({
flag: 1
});跳到TP聊天 (已移除)
Open TP IM (Removed)
tp.startChat(params)params- Object:
tp.startChat({
account: 'itokenpocket',
sessionType: 0,
blockchain: 'eos'
});保存图片
Save image
tp.saveImage(params)params- Object:
tp.saveImage({
url: 'https://dapp.mytokenpocket.vip/tokenpocket_logo.png'
});
横屏
rotate the screen horizontal
tp.rollHorizontal(params)params- Object:
tp.rollHorizontal({
horizontal: true
});禁止iOS自带的左滑手势返回,对安卓无影响
Disable iOS's left-sliding gesture to return. There is no effect on Android
tp.popGestureRecognizerEnable(params)params- Object:
tp.popGestureRecognizerEnable({
enable: false
});禁止webview自带的左滑手势触发goback
Disable the left sliding gesture by WebView to trigger goback
tp.forwardNavigationGesturesEnable(params)params- Object:
tp.forwardNavigationGesturesEnable({
enable: false
});获取用户某个底层选择的节点信息
Get information about the node selected by the user
tp.getNodeUrl(params)params- Object:
Object:
result: Boolean
data: Object
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:
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:
Object:
result: Boolean
data: Object
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:
Object:
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:
Object:
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:
Object:
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:
Object:
tp.getEosAccountInfo({
account: 'itokenpocket'
}).then(console.log)
> {
result: true,
data:{"account_name":"itokenpocket",..., "is_proxy":0},
msg: 'success'
}tp.getEosTransactionRecord(params)params- Object:
Object:
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
tp.enuTokenTransfer(params)params- Object:
Object:
result: Boolean
data: Object
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:
Object:
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:
Object:
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:
Object:
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:
Object:
tp.getEnuAccountInfo({
account: 'itokenpocket'
}).then(console.log)
> {
result: true,
data:{"account_name":"itokenpocket",..., "is_proxy":0}},
msg: 'success'
}tp.getEnuTransactionRecord(params)params- Object:
Object:
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:
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:
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 TronLink.
TokenPocket 兼容基于 TronLink 的应用.
Webview 内有注入 tronWeb 对象.
Webview injected a tronWeb object.
tp.sendMoacTransaction(params)params- Object:
Object:
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:
Object:
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:
Object:
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
Object:
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:
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:
In TokenPocket mobile wallet, we support all standard SVM chains. You can add your SVM chain through add custom network feature in the wallet.
For all svm chains you can follow the same develop method below:
(Recommended) We supported the wallet-standard protocol: https://github.com/solana-labs/wallet-standard with the name TokenPocket.
Checking https://github.com/solana-labs/wallet-adapter old protocol for using solana wallets including TokenPocket.
Some of our api are compatible with mainstream Solana wallets: Phantom and Backpack.
Or you can using the window.solana Object directly in the webview. which provide standard connect, signTransaction, signMessage methods.
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:
tp.getCurrentBalance().then(res => console.log)
> {
result: true,
data: {
balance: '0.013'
},
msg: 'success',
}tp.btcTokenTransfer(params)params- Object:
Object:
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:
Object:
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)
// 31aptos.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
| Back | FazBrowse Home | New Git URL |