### Get Transaction List Example (HTTP Request)
Source: https://help.tokenpocket.pro/developer-en/network/add-chain/addchain-multifunction
This example demonstrates how to construct an HTTP GET request to the universal_list endpoint for retrieving transaction data. It includes common query parameters like address, blockchain_id, and pagination controls.
```http
https://testtxserver.xxx.com/v1/transaction_action/universal_list?new_way=tp&search=&address=0x0Dd3758c88316723eC434C54BF3e56e733785DFE&blockchain_id=26&count=20&page=0&sort=&contract_address=&type=0
```
--------------------------------
### Request Ethereum Accounts and Display (HTML & JavaScript)
Source: https://help.tokenpocket.pro/developer-en/extension-wallet/guide/getting-started
This example shows a complete workflow for connecting to the TokenPocket Extension and displaying the user's Ethereum account address. It includes an HTML button to trigger the connection and JavaScript to handle the `eth_requestAccounts` request and update the UI with the account information. It utilizes an async function to handle the promise returned by `ethereum.request`.
```html
Account:
```
```javascript
const ethereumButton = document.querySelector('.enableEthereumButton');
const showAccount = document.querySelector('.showAccount');
hereumButton.addEventListener('click', () => {
getAccount();
});
async function getAccount() {
const accounts = await ethereum.request({ method: 'eth_requestAccounts' });
const account = accounts[0];
showAccount.innerHTML = account;
}
```
--------------------------------
### Transaction List Request Example (Polkadot)
Source: https://help.tokenpocket.pro/developer-en/network/add-chain/addchain-multifunction
This example demonstrates how to construct a GET request to the universal_list endpoint to retrieve transaction details for Polkadot. It includes common query parameters like address, count, page, and type.
```http
https://testtxserver.xxx.com/v1/transaction_action/universal_list?address=3iM6wt2uixaTdMj7ZQB6LN9qanvCCxWdd56oVwRg7fmj1uFw&search=&blockchain_id=21&count=40&page=0&sort&contract_address&type=0
```
--------------------------------
### Get Transaction Details API Example (JavaScript)
Source: https://help.tokenpocket.pro/developer-en/network/add-chain/addchain-multifunction
Provides an example of how to fetch specific transaction details using the TokenPocket Pro API. This snippet illustrates the method and URL structure for retrieving transaction information, along with key query parameters.
```javascript
const apiUrl = "https://xxxtxserver.xxx.com/v1/transaction_action/universal";
const params = {
ns: "some_namespace",
chain_id: 123,
blockchain_id: 456, // or use ns + chain_id
producer_block_Id: "some_block_id",
receiver: "some_receiver"
};
fetch(`${apiUrl}?${new URLSearchParams(params).toString()}
.then(response => response.json())
.then(data => {
console.log(data);
})
.catch(error => {
console.error('Error fetching transaction details:', error);
});
```
--------------------------------
### GET tp.getAppInfo()
Source: https://help.tokenpocket.pro/developer-en/wallet/js-sdk
Retrieves information about the TokenPocket application environment.
```APIDOC
## GET tp.getAppInfo()
### Description
Retrieves metadata and information about the current TokenPocket application instance.
### Method
GET
### Endpoint
tp.getAppInfo()
### Response
#### Success Response (200)
- **appInfo** (object) - Object containing application version, name, and environment details.
### Response Example
{
"name": "TokenPocket",
"version": "2.3.8"
}
```
--------------------------------
### Universal Transaction List Query API Example (JavaScript)
Source: https://help.tokenpocket.pro/developer-en/network/add-chain/addchain-multifunction
Demonstrates how to query a universal list of transactions using the TokenPocket Pro API. It includes example request parameters and the expected JSON response structure for transaction data.
```javascript
const apiUrl = "https://xxxtxserver.xxx.com/v1/transaction_action/universal_list";
const params = {
blockchain_id: 29,
search: "",
account: "eosio.token",
count: 20,
page: 0
};
fetch(`${apiUrl}?${new URLSearchParams(params).toString()}
.then(response => response.json())
.then(data => {
console.log(data);
})
.catch(error => {
console.error('Error fetching data:', error);
});
```
--------------------------------
### Connect to TokenPocket Extension (JavaScript)
Source: https://help.tokenpocket.pro/developer-en/extension-wallet/guide/getting-started
This code demonstrates how to initiate a connection to the TokenPocket Extension to access the user's Ethereum account. It uses the `eth_requestAccounts` method, which should be triggered by a user action like a button click. The method returns a promise that resolves with an array of Ethereum addresses.
```javascript
const ethereumButton = document.querySelector('.enableEthereumButton');
hereumButton.addEventListener('click', () => {
//Will Start the TokenPocket Extension extension
ethereum.request({ method: 'eth_requestAccounts' });
});
```
--------------------------------
### Android SDK Login Authorization Example
Source: https://help.tokenpocket.pro/developer-en/wallet/mobile-sdk/android
This Java code demonstrates how to use the TokenPocket SDK's `authorize` method to initiate a login request. It configures supported blockchains (e.g., Ethereum with ChainId 56), sets action details, and includes a callback mechanism for handling the response. The method must be called on the UI thread.
```java
Authorize authorize = new Authorize();
//Supported networks
List blockchains = new ArrayList();
//Evm series, the first parameter is Ethereum, the second parameter is the ChainId, like 1 is the ChainId for Ethereum.
blockchains.add(new Blockchain("ethereum", "56"));
authorize.setBlockchains(blockchains);
authorize.setAction("login");
//business id defined by developer
authorize.setActionId(String.valueOf(System.currentTimeMillis()));
authorize.setProtocol("TokenPocket");
authorize.setVersion("v1.0");
authorize.setDappName("zs");
authorize.setDappIcon("https://eosknights.io/img/icon.png");
authorize.setMemo("demo");
//if developer set callback url, after the wallet operation is completed, the result will be called back to the callbak URL through the post application json method
authorize.setCallbackUrl("http://115.205.0.178:9011/taaBizApi/taaInitData");
TPManager.getInstance().authorize(this, authorize, new TPListener() {
@Override
public void onSuccess(String s) {
//After successful authentication, signed message, wallet address will be returned
Toast.makeText(EthDemoActivity.this, s, Toast.LENGTH_LONG).show();
}
@Override
public void onError(String s) {
Toast.makeText(EthDemoActivity.this, s, Toast.LENGTH_LONG).show();
}
@Override
public void onCancel(String s) {
Toast.makeText(EthDemoActivity.this, s, Toast.LENGTH_LONG).show();
}
});
```
--------------------------------
### TokenPocket Pro SDK: EthGetEncryptionPublicKey
Source: https://help.tokenpocket.pro/developer-en/wallet/mobile-sdk/ios
This Objective-C example demonstrates how to request an encryption public key for Ethereum using the TokenPocket Pro SDK. It configures the request with dappName, dappIcon, blockchains, and specific data, then sends it via TPApi.sendObj.
```objectivec
TPEthGetEncryptionPublicKeyObj *ethGetEncryptionPublicKeyObj = [TPEthGetEncryptionPublicKeyObj new];
ethGetEncryptionPublicKeyObj.dappName = @"xxx";
ethGetEncryptionPublicKeyObj.dappIcon = @"https:.../xx.png";
ethGetEncryptionPublicKeyObj.blockchains = @[
[TPChainObj objWithNetwork:@"ethereum" chainId:@"56"], /** 如果选择 BSC */
];
TPEthGetEncryptionPublicKeyObjData *data = TPEthGetEncryptionPublicKeyObjData.new;
data.address = @"xxx";
ethGetEncryptionPublicKeyObj.data = data;
[TPApi sendObj:ethGetEncryptionPublicKeyObj];
/// Response ↓
TPRespObj.data
{
...,
"txId" : "abc...123",
"data" : {
"address":"xxx",
"encryptitonPublicKey":"xxx"
},
}
```
--------------------------------
### POST tp.fullScreen()
Source: https://help.tokenpocket.pro/developer-en/wallet/js-sdk
Controls the full-screen display mode for the DApp within the browser.
```APIDOC
## POST tp.fullScreen()
### Description
Sets the DApp view to full-screen or standard mode.
### Method
POST
### Endpoint
tp.fullScreen()
### Parameters
#### Request Body
- **fullScreen** (integer) - Required - 1 for full-screen mode, 0 for standard display.
### Request Example
{
"fullScreen": 0
}
```
--------------------------------
### TokenPocket Pro SDK: Sign Message
Source: https://help.tokenpocket.pro/developer-en/wallet/mobile-sdk/ios
This Objective-C example demonstrates how to request a message signature using the TokenPocket Pro SDK. It sets the dappName, dappIcon, message to be signed, and the target blockchain, then sends the request using TPApi.sendObj.
```objectivec
TPSignObj *sign = [TPSignObj new];
sign.dappName = @"xxx";
sign.dappIcon = @"https:.../xx.png";
sign.message = @"sign data...";
sign.blockchains = @[
[TPChainObj objWithNetwork:@"ethereum" chainId:@"56"], /** If selected BSC */
];
[TPApi sendObj:sign];
/// Response ↓
TPRespObj.data
{
...,
"sign" : "signature...",
}
```
--------------------------------
### TokenPocket Transfer Parameters (JSON)
Source: https://help.tokenpocket.pro/developer-en/wallet/pull-up-wallet-with-deeplink
Example JSON for the 'param' attribute to initiate a token transfer in TokenPocket. It includes details like 'to', 'amount', 'symbol', 'decimal', 'contract', and blockchain network information. Ensure this JSON is URL-encoded.
```json
{
"amount": 0.1,
"contract": "0x4d224452801ACEd8B2F0aebE155379bb5D594381",
"decimal": 18,
"desc": "",
"from": "0x5FDcc57FBeeb69f60dD7eC8d9c21B52F566e016E",
"memo": "0xe595a6",
"precision": 0,
"symbol": "AAA",
"to": "0x5FDcc57FBeeb69f60dD7eC8d9c21B52F566e016E",
"action": "transfer",
"actionId": "web-db4c5466-1a03-438c-90c9-2172e8becea5",
"blockchains": [
{
"chainId": "1",
"network": "ethereum"
}
],
"dappIcon": "https://eosknights.io/img/icon.png",
"dappName": "Test demo",
"expired": 0,
"protocol": "TokenPocket",
"version": "1.0"
}
```
--------------------------------
### GET /v1/transaction_action/universal
Source: https://help.tokenpocket.pro/developer-en/network/add-chain/addchain-multifunction
Retrieves specific transaction details for EOSIO-based chains.
```APIDOC
## GET /v1/transaction_action/universal
### Description
Queries detailed information for a specific transaction action.
### Method
GET
### Endpoint
/v1/transaction_action/universal
### Parameters
#### Query Parameters
- **ns** (string) - Optional - Namespace
- **chain_id** (int) - Optional - Chain ID
- **blockchain_id** (int) - Optional - Blockchain ID
- **producer_block_Id** (string) - Optional - Producer block ID
- **receiver** (string) - Optional - Receiver account
### Response
#### Success Response (200)
- **Hid** (string) - Transaction ID
- **Timestamp** (int64) - Transaction timestamp
- **From** (string) - Sender account
- **To** (string) - Receiver account
- **Quantity** (string) - Amount transferred
```
--------------------------------
### Get App Information using tp-js-sdk
Source: https://help.tokenpocket.pro/developer-en/wallet/js-sdk
Retrieves information about the current application running within the TokenPocket DApp browser. This function is part of the tp-js-sdk and is useful for understanding the DApp's environment.
```javascript
tp.getAppInfo()
```
--------------------------------
### Query Universal Transaction Details
Source: https://help.tokenpocket.pro/developer-en/network/add-chain/addchain-multifunction
Demonstrates how to perform a GET request to the universal transaction endpoint. It requires parameters such as 'from', 'blockchain_id', 'block_number', 'nonce', and 'call_index' to retrieve transaction metadata.
```http
GET /v1/transaction_action/universal?from=14TMRRRqJUJszegEd7C3svLWxLUyMQPzXJ1wA6UYRcdKFRQZ&blockchain_id=13&block_number=5163171&nonce=4&call_index=0
```
```json
{
"data": {
"decimal": 10,
"fee": "156000016",
"tip": "0",
"symbol": "DOT",
"comment": "0",
"timestamp": 1621620846,
"block_number": 5163171,
"value": "28645499945",
"hash": "0xe1e9bb207610dba7a98bbec411b549d951ddb8d6c27941ee9b1d32b26367831f",
"nonce": "4",
"callIndex": 0,
"from": "14TMRRRqJUJszegEd7C3svLWxLUyMQPzXJ1wA6UYRcdKFRQZ",
"to": "1119Ch5Ezu9fKdcZ9ThBFnTeEkUrhfhT59jHjGjKnvVvmsy",
"status": 1
},
"message": "success",
"result": 0
}
```
--------------------------------
### Transaction List Response Example (Polkadot)
Source: https://help.tokenpocket.pro/developer-en/network/add-chain/addchain-multifunction
This JSON object represents a successful response from the transaction list query. It contains a 'data' array with transaction objects, each detailing aspects like decimal, fee, symbol, timestamp, block number, and transaction hash.
```json
{
"data": [
{
"decimal": 10,
"fee": "155000015",
"tip": "0",
"symbol": "DOT",
"comment": "0",
"timestamp": 1633449756,
"block_number": 7129105,
"value": "739595473900",
"hash": "0xdb4cc8adf2b48a50699abc27ca3461b1c497292c1a7fb34cc73fcdbb2c808cc6",
"nonce": "0",
"callIndex": 0,
"from": "1119Ch5Ezu9fKdcZ9ThBFnTeEkUrhfhT59jHjGjKnvVvmsy",
"to": "16FLM85x3Q8qSthJ9riL5Xcop8GfRY8SxuaDqvtMeeyrZNNs",
"status": 1
},
{
"decimal": 10,
"fee": "156000016",
"tip": "0",
"symbol": "DOT",
"comment": "0",
"timestamp": 1621620846,
"block_number": 5163171,
"value": "28645499945",
"hash": "0xe1e9bb207610dba7a98bbec411b549d951ddb8d6c27941ee9b1d32b26367831f",
"nonce": "4",
"callIndex": 0,
"from": "14TMRRRqJUJszegEd7C3svLWxLUyMQPzXJ1wA6UYRcdKFRQZ",
"to": "1119Ch5Ezu9fKdcZ9ThBFnTeEkUrhfhT59jHjGjKnvVvmsy",
"status": 1
}
],
"message": "success",
"result": 0
}
```
--------------------------------
### GET /v1/transaction_action/universal
Source: https://help.tokenpocket.pro/developer-en/network/add-chain/addchain-multifunction
Retrieves detailed information for a specific EVM transaction using hash, block hash, or index parameters.
```APIDOC
## GET /v1/transaction_action/universal
### Description
Query detailed information for a specific transaction on an EVM-compatible blockchain.
### Method
GET
### Endpoint
/v1/transaction_action/universal
### Parameters
#### Query Parameters
- **ns** (string) - Optional - Namespace (required if querying via chain_id)
- **chain_id** (int) - Optional - Chain ID (required if querying via ns)
- **blockchain_id** (int) - Optional - Alternative to ns + chain_id
- **block_hash** (string) - Optional - The block hash
- **hash** (string) - Optional - The transaction hash
- **log_index** (int) - Optional - Log index
- **internal_index** (string) - Optional - Internal index
### Response
#### Success Response (200)
- **Title** (string) - Transaction title
- **Decimal** (int64) - Token decimal precision
- **Fee** (string) - Transaction fee
- **Symbol** (string) - Token symbol
- **Comment** (string) - Transaction remark
- **Timestamp** (int64) - Unix timestamp
- **BlockNumber** (int64) - Block number
- **TokenValue** (string) - Token amount
- **Gas** (string) - Gas fee used
### Response Example
{
"Title": "Transfer",
"Decimal": 18,
"Fee": "0.000254",
"Symbol": "ETH",
"Timestamp": 1644481313,
"BlockNumber": 3393917,
"TokenValue": "100000000000000",
"Gas": "21000"
}
```
--------------------------------
### POST tp.invokeQRScanner()
Source: https://help.tokenpocket.pro/developer-en/wallet/js-sdk
Triggers the native QR code scanner within the TokenPocket mobile app.
```APIDOC
## POST tp.invokeQRScanner()
### Description
Opens the native camera interface to scan a QR code and returns the decoded string.
### Method
POST
### Endpoint
tp.invokeQRScanner()
### Response
#### Success Response (200)
- **result** (string) - The decoded content from the scanned QR code.
### Response Example
{
"result": "abcdefg"
}
```
--------------------------------
### Implement Transaction UI and Event Handling
Source: https://help.tokenpocket.pro/developer-en/extension-wallet/guide/send-transaction
Provides a complete example of integrating transaction sending into a web page using HTML buttons and JavaScript event listeners to request accounts and trigger transactions.
```html
```
```javascript
const ethereumButton = document.querySelector('.enableEthereumButton');
const sendEthButton = document.querySelector('.sendEthButton');
let accounts = [];
sendEthButton.addEventListener('click', () => {
ethereum
.request({
method: 'eth_sendTransaction',
params: [
{
from: accounts[0],
to: '0x2f318C334780961FB129D2a6c30D0763d9a5C970',
value: '0x29a2241af62c0000',
gasPrice: '0x09184e72a000',
gas: '0x2710',
},
],
})
.then((txHash) => console.log(txHash))
.catch((error) => console.error);
});
ethereumButton.addEventListener('click', () => {
getAccount();
});
async function getAccount() {
accounts = await ethereum.request({ method: 'eth_requestAccounts' });
}
```
--------------------------------
### EVM Raw Transaction Data
Source: https://help.tokenpocket.pro/developer-en/scan-protocol
This snippet shows an example of raw transaction data for an EVM network, typically generated by a cold wallet and intended to be scanned by a watch-wallet for signing.
```text
0xf8ac82062e85013f2ed0c0828cf894eca41281c24451168a37211f0bc2b8645af4509280b844a9059cbb0000000000b79bbc09226198e8d15a05219fdd2a20cba0932621528743459250c016a00fd584c4e7bcfa0667e9f70a2
```
--------------------------------
### Open TokenPocket for Authorization (HTML)
Source: https://help.tokenpocket.pro/developer-en/wallet/pull-up-wallet-with-deeplink
This HTML snippet demonstrates how to create a link that, when clicked, will open the TokenPocket app to authorize login. The 'param' attribute should contain a JSON object with authorization details, URL-encoded.
```html
Open TokenPocket to authorize
```
--------------------------------
### Detect TokenPocket Extension (JavaScript)
Source: https://help.tokenpocket.pro/developer-en/extension-wallet/guide/getting-started
This snippet checks if the TokenPocket Extension is installed and running in the browser. It accesses the `window.ethereum` object and checks for the `isTokenPocket` property. This is crucial for ensuring your application can interact with the extension.
```javascript
if (typeof window.ethereum.isTokenPocket !== 'undefined') {
console.log('TokenPocket Extension is installed!');
}
```
--------------------------------
### TokenPocket Dynamic QRCode Fragment Generation Example
Source: https://help.tokenpocket.pro/developer-en/scan-protocol/dynamic-qrcode
Demonstrates how to generate QR code fragments for a given dataset. The data is split into parts, and each part is encoded with its corresponding index and CRC32 checksum, forming a sequence of dynamic QR code entries.
```text
tp:multiFragment-version=1.0&protocol=TokenPocket&data=
{
"content": "aaaaabbbbbbbbbbbcccccccccccc_3207688794",
"index": "0/2"
}
tp:multiFragment-version=1.0&protocol=TokenPocket&data=
{
"content": "aaaaabbbbbbbbbbbcccccccccccc_3207688794",
"index": "1/2"
}
```
--------------------------------
### Import and Initialize TokenPocket Pro iOS SDK
Source: https://help.tokenpocket.pro/developer-en/wallet/mobile-sdk/ios
This snippet shows how to import the TPSDK.h file into your AppDelegate.m and register your app's scheme using TPApi.registerAppID. It's essential for establishing communication between your app and the TokenPocket wallet.
```objectivec
#import
// In application:didFinishLaunchingWithOptions:
[TPApi registerAppID:@"demoapp"];
```
--------------------------------
### GET tpdapp://open
Source: https://help.tokenpocket.pro/developer-en/wallet/pull-up-wallet-with-deeplink
Endpoint to open a specific URL directly within the TokenPocket DApp browser.
```APIDOC
## GET tpdapp://open
### Description
Opens a specified URL inside the TokenPocket built-in DApp browser.
### Method
GET
### Endpoint
tpdapp://open?params={encoded_json}
### Parameters
#### Query Parameters
- **params** (string) - Required - A JSON object containing the target URL and chain info, encoded via encodeURIComponent.
### Request Example
```json
{
"url": "https://dapp.example.com",
"chain": "EOS",
"source": "my_app"
}
```
```
--------------------------------
### Register User Onboarding Initiator with TokenPocket Pro (JavaScript)
Source: https://help.tokenpocket.pro/developer-en/extension-wallet/api-reference/rpc-api
Registers the requesting website as the initiator of user onboarding with TokenPocket Pro. This method is typically called after TokenPocket Pro installation but before onboarding completion. It returns a boolean indicating success or failure and is useful for redirecting users back to the site post-onboarding.
```javascript
async function registerOnboarding() {
try {
const success = await ethereum.request({
method: 'wallet_registerOnboarding'
});
return success; // Returns true on success
} catch (error) {
console.error('Onboarding registration failed:', error);
return false;
}
}
```
--------------------------------
### GET tpoutside://pull.activity
Source: https://help.tokenpocket.pro/developer-en/wallet/pull-up-wallet-with-deeplink
General endpoint to trigger wallet operations like login, transfer, transaction signing, and message signing.
```APIDOC
## GET tpoutside://pull.activity
### Description
Triggers the TokenPocket wallet to perform specific actions. The 'param' query parameter must be a JSON object encoded with encodeURIComponent.
### Method
GET
### Endpoint
tpoutside://pull.activity?param={encoded_json}
### Parameters
#### Query Parameters
- **param** (string) - Required - A JSON object containing action details (action, actionId, blockchains, etc.), encoded via encodeURIComponent.
### Request Example
```json
{
"action": "login",
"callbackUrl": "http://example.com/callback",
"blockchains": [{"chainId": "1", "network": "ethereum"}],
"protocol": "TokenPocket",
"version": "v1.0"
}
```
### Response
#### Success Response (Callback)
The wallet will redirect to the provided `callbackUrl` with the operation result appended as query parameters.
```
--------------------------------
### Open DApp
Source: https://help.tokenpocket.pro/developer-en/scan-protocol
Structure for launching a specific DApp within the TokenPocket environment.
```JSON
{
"url": "https://dapp.mytokenpocket.vip/referendum/index.html#/",
"chain": "EOS",
"source": "xxx"
}
```
--------------------------------
### TokenPocket DApp Browser Parameters (JSON)
Source: https://help.tokenpocket.pro/developer-en/wallet/pull-up-wallet-with-deeplink
Example JSON structure for opening a URL in the TokenPocket DApp browser. It requires the 'url' to be opened and the 'chain' identifier (e.g., 'EOS'). This JSON object must be URL-encoded.
```json
{
"url": "https://dapp.mytokenpocket.vip/referendum/index.html#/",
"chain": "EOS"
"source": "xxx"
}
```
--------------------------------
### TokenPocket String Signing Parameters (JSON)
Source: https://help.tokenpocket.pro/developer-en/wallet/pull-up-wallet-with-deeplink
Example JSON for signing a string message in TokenPocket. Key fields include 'message', 'signType' (e.g., 'ethPersonalSign'), and 'hash' boolean. Ensure the entire JSON is URL-encoded before use.
```json
{
"hash": false,
"memo": "demo",
"message": "Ssd",
"signType": "ethPersonalSign",
"action": "sign",
"actionId": "web-db4c5466-1a03-438c-90c9-2172e8becea5",
"blockchains": [
{
"chainId": "1",
"network": "ethereum"
}
],
"dappIcon": "https://eosknights.io/img/icon.png",
"dappName": "Test demo",
"expired": 0,
"protocol": "TokenPocket",
"version": "1.1.8"
}
```
--------------------------------
### Request User Accounts via eth_requestAccounts
Source: https://help.tokenpocket.pro/developer-en/extension-wallet/api-reference/rpc-api
Demonstrates how to request user account access using the eth_requestAccounts method. It includes error handling for user rejection (4001 error) and should be triggered by user interaction.
```javascript
document.getElementById('connectButton', connect);
function connect() {
ethereum
.request({ method: 'eth_requestAccounts' })
.then(handleAccountsChanged)
.catch((error) => {
if (error.code === 4001) {
// EIP-1193 userRejectedRequest error
console.log('Please connect to TokenPocket Extension.');
} else {
console.error(error);
}
});
}
```
--------------------------------
### TokenPocket Transaction Signing Parameters (JSON)
Source: https://help.tokenpocket.pro/developer-en/wallet/pull-up-wallet-with-deeplink
Example JSON for signing a transaction in TokenPocket. The 'txData' field is crucial and contains the serialized transaction details. Other parameters like 'action', 'actionId', and blockchain info are also required. Remember to URL-encode the entire JSON.
```json
{
"txData": "{\"from\":\"0x22F4900A1fB41f751b8F616832643224606B75B4\",\"gasPrice\":\"0x6c088e200\",\"gas\":\"0xea60\",\"chainId\":\"1\",\"to\":\"0x7d1e7fb353be75669c53c18ded2abcb8c4793d80\",\"data\":\"0xa9059cbb000000000000000000000000171a0b081493722a5fb8ebe6f0c4adf5fde49bd8000000000000000000000000000000000000000000000000000000000012c4b0\"}",
"action": "pushTransaction",
"actionId": "web-db4c5466-1a03-438c-90c9-2172e8becea5",
"blockchains": [
{
"chainId": "1",
"network": "ethereum"
}
],
"dappIcon": "https://eosknights.io/img/icon.png",
"dappName": "Test demo",
"expired": 0,
"protocol": "TokenPocket",
"version": "1.1.8"
}
```
--------------------------------
### TokenPocket Authorization Parameters (JSON)
Source: https://help.tokenpocket.pro/developer-en/wallet/pull-up-wallet-with-deeplink
Example JSON structure for the 'param' attribute when initiating a login authorization via deep link. Key fields include callbackUrl, action, actionId, and blockchain details. The entire JSON must be URL-encoded before being appended to the deep link.
```json
{
"callbackUrl": "http://115.205.0.178:9011/taaBizApi/taaInitData",
"memo": "demo",
"action": "login",
"actionId": "1647604216423",
"blockchains": [
{
"chainId": "1",
"network": "ethereum"
}
],
"dappIcon": "https://eosknights.io/img/icon.png",
"dappName": "zs",
"expired": 1602,
"protocol": "TokenPocket",
"version": "v1.0"
}
```
--------------------------------
### Initialize TokenPocket SDK
Source: https://help.tokenpocket.pro/developer-en/wallet/eos-miniwallet-sdk/ios
Configures the SDK within the AppDelegate. This sets the AppID, seed, and blockchain node URLs required for subsequent operations.
```Objective-C
[TPApi registerAppID:@"tpsdk"];
[TPApi setSeed:@"xxxx" error:nil];
[TPApi setBlockChain:TPBlockChainTypeEOSMainNet nodeUrl:@"http://eosinfo.mytokenpocket.vip" plugNodeUrl:@"http://eosinfo.mytokenpocket.vip"];
```
--------------------------------
### Perform Token Transfer using TokenPocket Pro SDK
Source: https://help.tokenpocket.pro/developer-en/wallet/mobile-sdk/android
This snippet demonstrates how to initiate a token transfer using the TokenPocket Pro SDK. It requires setting up transfer parameters such as recipient, amount, contract address, and supported blockchains. The SDK handles the interaction with the TokenPocket wallet for user confirmation and transaction broadcasting. Note that the returned transaction hash indicates the transaction has been sent, not necessarily confirmed on-chain.
```java
Transfer transfer = new Transfer();
//Supported networks
List blockchains = new ArrayList<>();
//Evm series, the first parameter is Ethereum, the second parameter is the ChainId, like 1 is the ChainId for Ethereum.
blockchains.add(new Blockchain("ethereum", "56"));
transfer.setBlockchains(blockchains);
transfer.setProtocol("TokenPocket");
transfer.setVersion("1.0");
transfer.setDappName("Test demo");
transfer.setDappIcon("https://eosknights.io/img/icon.png");
//business id defined by developer
transfer.setActionId("web-db4c5466-1a03-438c-90c9-2172e8becea5");
//data,If it is a native token, you can add on-chain data
transfer.setMemo("0xe595a6");
transfer.setAction("transfer");
//sender
transfer.setFrom("0x52bc44d5378309ee2abf1539bf71de1b7d7be3b5");
//receiver
transfer.setTo("0x32ff06198da462f1c519d30f4d328b3fef295d19");
//contract address, if you are transferring ether, this parameter is optional
transfer.setContract("0xdAC17F958D2ee523a2206206994597C13D831ec7");
//token amount. For example, we transfer 0.01 USDT here, which is equivalent to passing 0.01 USDT.
transfer.setAmount(0.01);
//Required
transfer.setDecimal(18);
transfer.setSymbol("USDT");
transfer.setDesc("Only for ui display, not on the chain");
//if developer set callback url, after the wallet operation is completed, the result will be called back to the callbak URL through the post application json method
transfer.setCallbackUrl("http://115.205.0.178:9011/taaBizApi/taaInitData");
TPManager.getInstance().transfer(this, transfer, new TPListener() {
@Override
public void onSuccess(String s) {
//The result of the transfer. Note that developer needs to confirm the final result on chain with the hash. We just return the hash after sending transaction, it can not guarantee a successful transaction.
Toast.makeText(EthTransferActivity.this, s, Toast.LENGTH_LONG).show();
}
@Override
public void onError(String s) {
Toast.makeText(EthTransferActivity.this, s, Toast.LENGTH_LONG).show();
}
@Override
public void onCancel(String s) {
Toast.makeText(EthTransferActivity.this, s, Toast.LENGTH_LONG).show();
}
});
```
--------------------------------
### Get Transaction Details API Endpoint (HTTP)
Source: https://help.tokenpocket.pro/developer-en/network/add-chain/addchain-multifunction
This outlines the HTTP GET endpoint for retrieving detailed transaction information. It specifies the base URL and the primary function of the endpoint, which is to query transaction details using various identifiers.
```http
get: /v1/transaction_action/universal
```
--------------------------------
### GET /v1/transaction_action/universal_list
Source: https://help.tokenpocket.pro/developer-en/network/add-chain/addchain-multifunction
Retrieves a paginated list of transactions for a specific address on a given blockchain.
```APIDOC
## GET /v1/transaction_action/universal_list
### Description
Fetches a list of transactions associated with a specific address, supporting pagination and filtering.
### Method
GET
### Endpoint
/v1/transaction_action/universal_list
### Parameters
#### Query Parameters
- **address** (string) - Required - The wallet address to query
- **blockchain_id** (int) - Required - The blockchain identifier
- **count** (int) - Optional - Number of records to return
- **page** (int) - Optional - Page number for pagination
### Response
#### Success Response (200)
- **hash** (string) - Transaction hash
- **status** (int) - 1: success, 0: failure, 2: pending, 99: unknown
- **value** (string) - Transaction value
- **from** (string) - Sender address
- **to** (string) - Recipient address
### Response Example
{
"data": [{
"hash": "0x1305d359d3796a5b9c1f0b3e8e204933a16fdbc9677667cbb6ea8db3f9a83611",
"status": 1,
"value": "100000000000000",
"from": "0x0dd3758c88316723ec434c54bf3e56e733785dfe",
"to": "0x0657659db21230061aae817ae26e5d15de66cf2e"
}]
}
```
--------------------------------
### Configure RPC Node Endpoints
Source: https://help.tokenpocket.pro/developer-en/network/add-chain/addchain-multifunction
Defines the format for providing multiple available RPC node URLs. These nodes are used by the wallet to initiate transactions and query contract information.
```json
rpc: [
"https://rpc.api.xxxx.network",
"https://rpc.api2.xxxxx.network"
]
```
--------------------------------
### Get Transaction Records List (EOSIO)
Source: https://help.tokenpocket.pro/developer-en/network/add-chain/addchain-multifunction
Retrieves a list of transaction records specifically for EOSIO.
```APIDOC
## GET /v1/transaction_action/universal_list
### Description
Retrieves a list of transaction records for EOSIO. This endpoint is designed to fetch multiple transaction records.
### Method
GET
### Endpoint
`/v1/transaction_action/universal_list`
### Parameters
#### Query Parameters
*The specific query parameters for this endpoint are not detailed in the provided text, but it is implied they are related to transaction record retrieval.*
### Request Example
*No specific request example provided for this endpoint.*
### Response
#### Success Response (200)
*The structure of the success response for this endpoint is not detailed in the provided text. It is expected to be a list of transaction records, potentially similar to the response of the universal endpoint but possibly with EOSIO-specific fields.*
#### Response Example
*No specific response example provided for this endpoint.*
```
--------------------------------
### GET /v1/transaction_action/universal_list
Source: https://help.tokenpocket.pro/developer-en/network/add-chain/addchain-multifunction
Retrieves a list of transaction actions based on blockchain identifiers, accounts, and search filters.
```APIDOC
## GET /v1/transaction_action/universal_list
### Description
Fetches a paginated list of transaction actions. Users can filter by blockchain ID, account, or search terms.
### Method
GET
### Endpoint
/v1/transaction_action/universal_list
### Parameters
#### Query Parameters
- **ns** (string) - Optional - Namespace (exists only by querying data through chain id)
- **chain_id** (int) - Optional - Chain ID
- **blockchain_id** (int) - Optional - Blockchain ID (either ns + chain_id or blockchain_id can be added)
- **search** (string) - Optional - Search term
- **code** (string) - Optional - Code address
- **account** (string) - Optional - Account name
- **symbol** (string) - Optional - Token symbol
- **page** (int) - Optional - Page number
- **count** (int) - Optional - Number of items per page
- **sort** (string) - Optional - Sort order (default: desc)
- **type** (int) - Optional - 0: all, 1: from, 2: to
### Request Example
https://xxxtxserver.xxx.com/v1/transaction_action/universal_list?blockchain_id=29&search=&account=eosio.token&count=20&page=0
### Response
#### Success Response (200)
- **data** (array) - List of transaction objects
- **message** (string) - Status message
- **result** (int) - Result code
#### Response Example
{
"data": [
{
"hid": "817d47c381f284b269ca372ae6b911804bb7ed50efcf2bc2784c88d2b13e7f8a",
"receiver": "eosio.token",
"timestamp": 1645463197,
"account": "realmnftgame",
"name": "transfer",
"from": "whkm2.c.wam",
"to": "eosio.token",
"quantity": "974.9580 RLM",
"symbol": "RLM",
"status": 1
}
],
"message": "success",
"result": 0
}
```
--------------------------------
### Get Transaction Details
Source: https://help.tokenpocket.pro/developer-en/network/add-chain/addchain-multifunction
Retrieves detailed information about a specific transaction using its hash and other identifying parameters.
```APIDOC
## GET /v1/transaction_action/universal
### Description
Retrieves detailed information about a specific transaction based on provided identifiers like blockchain ID, block hash, and transaction hash.
### Method
GET
### Endpoint
`/v1/transaction_action/universal`
### Query Parameters
- **blockchain_id** (int) - Required - The ID of the blockchain.
- **block_hash** (string) - Required - The hash of the block containing the transaction.
- **hash** (string) - Required - The hash of the transaction.
- **log_index** (int) - Optional - The index of the log entry.
- **internal_index** (string) - Optional - The internal index of the transaction.
### Response
#### Success Response (200)
- **data** (object) - Contains transaction details.
- **decimal** (int) - Decimal places of the token.
- **fee** (string) - Transaction fee.
- **symbol** (string) - Token symbol.
- **timestamp** (int) - Transaction timestamp.
- **block_number** (int) - Block number.
- **token_value** (string) - Value of the token transferred.
- **gas** (string) - Gas used for the transaction.
- **gas_price** (string) - Gas price of the transaction.
- **used_gas** (string) - Gas actually used.
- **value** (string) - Value transferred in the transaction.
- **hash** (string) - Transaction hash.
- **nonce** (string) - Transaction nonce.
- **block_hash** (string) - Hash of the block.
- **log_index** (int) - Index of the log entry.
- **from** (string) - Sender address.
- **to** (string) - Receiver address.
- **addr_token** (string) - Token address.
- **type** (int) - Type of transaction (0: native currency, 1: token).
- **input** (string) - Transaction input data.
- **input_status** (int) - Status of the input.
- **status** (int) - Transaction status (1: success, 0: failure, 2: pending, 99: unknown).
- **message** (string) - Success message.
- **result** (int) - Result code.
#### Response Example
```json
{
"data": {
"decimal": 0,
"fee": "0.000763",
"symbol": "",
"timestamp": 1639603935,
"block_number": 1228952,
"token_value": "0",
"gas": "113334",
"gas_price": "1000000",
"used_gas": "113334",
"value": "0",
"hash": "0x539839a5a2dc3bf4edb3dca041fce0aec0e557811cdf7518007d6712d873726a",
"nonce": "0x5",
"block_hash": "0xf07696455e6bb138cff50390da1e47eb80745efdbcc16a609e4cec955f6a07af",
"log_index": -1,
"from": "0x389264158278811653",
"to": "0x389254976595034117",
"addr_token": "389253055922569221",
"type": 1,
"input": "0x1ebcfe800000000000000000000000000000000000000000000000000000000000000100",
"input_status": 0,
"status": 1
},
"message": "success",
"result": 0
}
```
```