- TokenPocketProvider
- EVM Provider
- APTOS Provider
- TRON Provider
- BTC & Forked Provider
- Nostr (Under development)
interface TokenPocketWindow extends Window {
tokenpocket: TokenPocketProvider
}
interface TokenPocketProvider extends Window {
ethereum?: EvmProvider
tron?: TronProvider
aptos?: AptosProvider
bitcoin?: BitcoinProvider
nostr?: NostrProvider
// solana?: SolanaProvider
// cosmos?: CosmosProvider
// eos?: EosProvider
}
Support ETH, BSC, POLYGON, OP, ARB, HECO, OKC and any EVM chains.
Implementation of EIP-1193, EIP-1102, EIP-3085, EIP-695, EIP-1474, EIP-3326
interface RequestPayload {
method: string;
params?: unknown[] | object
}
interface EvmProvider {
readonly isTokenpocket: true;
request(payload: RequestPayload): Promise<RequestResponse>;
}
Support APTOS Network
Implementation of aptos-wallet-adapter
interface AptosProvider {
readonly isTokenPocket: true
connect(): Promise<AptosAccount>;
account(): Promise<AptosAccount>;
getChainId(): Promise<string | number>
getNodeUrl(): Promise<string>
network(): Promise<string>
signAndSubmitTransaction(transaction: AptosTransaction, options: AptosTransactionOpt): Promise<AptosTransactionResponse>;
signTransaction(transaction: AptosTransaction, options: AptosTransactionOpt): Promise<AptosSignedTransaction>;
signMessage(messageObj: AptosMessage): Promise<AptosMessage>;
request(payload: RequestPayload): Promise<RequestResponse>
}
implementation of TIP-1193, TIP-1102
Support TRON
interface RequestPayload {
method: string;
params?: unknown[] | object
}
interface TronProvider {
readonly isTokenpocket: true;
tronWeb: TronWeb;
request(payload: RequestPayload): Promise<RequestResponse>;
}
bitcoin.request({
method: 'tron_requestAccounts'
}).then(console.log)
// return
['TKqQ7zuL7yKp1NWuhGpoXTDiE3j2qiAbRE']
Support BTC / DOGE ...
interface RequestPayload {
method: string;
params?: unknown[] | object
}
interface BitcoinProvider {
readonly isTokenpocket: true;
request(payload: RequestPayload): Promise<RequestResponse>;
}
bitcoin.request({
method: 'btc_accounts'
}).then(console.log)
// return
['39Px4rNdV1c1MzEKeVUQgQThbWAD4vfVHC']
bitcoin.request({
method: 'btc_signMessage',
params: ['Hello world!', '39Px4rNdV1c1MzEKeVUQgQThbWAD4vfVHC']
}).then(console.log)
// return signature
"I9knbZ0oaUo7fl8mKBJPP4cTy9kOOdTed51EC4BbrfdJdMdqUKw5yX81J7nrDBbDlA/7adqhQr2Fdg8MRSbA1W8="
Using https://github.com/bitcoinjs/bitcoinjs-message to verify the signature
var bitcoinMessage = require('bitcoinjs-message')
console.log(bitcoinMessage.verify(message, address, signature[, network.messagePrefix]))
// return true or false
Reference: BIP-122
bitcoin.request({
method: 'btc_chainId'
}).then(console.log)
// return chainid
'000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f'
Reference: tp-js-sdk: btcTokenTransfer
We will migrate the tp-js-sdk's methods into this new protocol in the future. But we will keep this tp-js-sdk either.
Reference: tp-js-sdk: getCurrentBalance
We will migrate the tp-js-sdk's methods into this new protocol in the future. But we will keep this tp-js-sdk either.
Implementation of NIP-07
interface Nip04 {
encrypt(pubkey: string, plaintext: string): Promise<string>
decrypt(pubkey: string, ciphertext: string): Promise<string>
}
interface Relays {
[url: string]: {read: boolean, write: boolean}
}
interface Event {
id: string;
pubkey: string:
created_at: string;
kind: number;
tags?: array;
content: string;
sig?: string;
}
interface NostrProvider {
readonly isTokenPocket: true;
getPublicKey(): Promise<string>;
signEvent(event: Event): Promise<Event>;
getRelays(): Promise<Relays>
nip04: Nip04
}