
Research
/Security News
Weaponizing Discord for Command and Control Across npm, PyPI, and RubyGems.org
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
@secux/app-trx
Advanced tools
@secux/app-trx
SecuX Hardware Wallet TRX API
import { SecuxTRX } from "@secux/app-trx";
First, create instance of ITransport
const path = "m/44'/195'/0'/0/0";
const address = await device.getAddress(path);
/*
// transfer data to hardware wallet by custom transport layer.
const data = SecuxTRX.prepareAddress(path);
const response = await device.Exchange(data);
const address = SecuxTRX.resolveAddress(response);
*/
const TronWeb = require("tronweb");
// fetch block data
const tronWeb = new TronWeb({ fullHost: 'https://api.trongrid.io' });
const block = await tronWeb.trx.getConfirmedCurrentBlock();
const content = {
to: "TJKiYicrKqB7PR2wywfWKkNMppNRqd6tXt",
amount: 1e5,
blockID: block.blockID,
blockNumber: block.block_header.raw_data.number,
timestamp: block.block_header.raw_data.timestamp
};
// sign
const { raw_tx, signature } = await device.sign("m/44'/195'/0'/0/0", content);
/*
// transfer data to hardware wallet by custom transport layer.
const { commandData, rawTx } = SecuxTRX.prepareSign("m/44'/195'/0'/0/0", content);
const response = await device.Exchange(commandData);
const raw_tx = SecuxTRX.resolveTransaction(response, rawTx);
*/
// broadcast
const response = await tronWeb.trx.sendHexTransaction(raw_tx);
const content = {
to: "TJKiYicrKqB7PR2wywfWKkNMppNRqd6tXt",
token: 1002000,
amount: 1e5,
blockID: block.blockID,
blockNumber: block.block_header.raw_data.number,
timestamp: block.block_header.raw_data.timestamp
};
const { raw_tx, signature } = await device.sign("m/44'/195'/0'/0/0", content);
/*
// transfer data to hardware wallet by custom transport layer.
const { commandData, rawTx } = SecuxTRX.prepareSign("m/44'/195'/0'/0/0", content);
const response = await device.Exchange(commandData);
const raw_tx = SecuxTRX.resolveTransaction(response, rawTx);
*/
const content = {
contract: "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",
// data field can use abi encoded string optionally
data: [
{ type: "address", value: "TJKiYicrKqB7PR2wywfWKkNMppNRqd6tXt" },
{ type: "uint256", value: 1e5 }
],
blockID: block.blockID,
blockNumber: block.block_header.raw_data.number,
timestamp: block.block_header.raw_data.timestamp
};
const { raw_tx, signature } = await device.sign("m/44'/195'/0'/0/0", content);
/*
// transfer data to hardware wallet by custom transport layer.
const { commandData, rawTx } = SecuxTRX.prepareSign("m/44'/195'/0'/0/0", content);
const response = await device.Exchange(commandData);
const raw_tx = SecuxTRX.resolveTransaction(response, rawTx);
*/
TRX package for SecuX device
Kind: global class
string
string
communicationData
string
communicationData
string
communicationData
prepared
string
string
string
Convert secp256k1 publickey to TRX address.
Returns: string
- TRX address
Param | Type |
---|---|
publickey | string | Buffer |
string
Convert TRX address to hex representation
Returns: string
- TRX address (hex)
Param | Type | Description |
---|---|---|
address | string | TRX address |
communicationData
Prepare data for address generation.
Returns: communicationData
- data for sending to device
Param | Type | Description |
---|---|---|
path | string | m/44'/195'/... |
string
Generate address from response data.
Returns: string
- TRX address
Param | Type | Description |
---|---|---|
response | communicationData | data from device |
communicationData
Prepare data for secp256k1 publickey.
Returns: communicationData
- data for sending to device
Param | Type | Description |
---|---|---|
path | string | m/44'/195'/... |
string
Resolve secp256k1 publickey from response data.
Returns: string
- secp256k1 publickey
Param | Type | Description |
---|---|---|
response | communicationData | data from device |
communicationData
Prepare data for xpub.
Returns: communicationData
- data for sending to device
Param | Type | Description |
---|---|---|
path | string | m/44'/195'/... |
Resolve xpub from response data.
Returns: xpub
Param | Type | Description |
---|---|---|
response | communicationData | data from device |
path | string | m/44'/195'/... |
prepared
Prepare data for signing.
Returns: prepared
- prepared object
Param | Type | Description |
---|---|---|
path | string | m/44'/195'/... |
content | transferData | trc10_Data | trc20_Data | transaction object |
string
Resolve signature from response data.
Returns: string
- signature (hex string)
Param | Type | Description |
---|---|---|
response | communicationData | data from device |
string
Resolve transaction for broadcasting.
Returns: string
- signed raw transaction
Param | Type | Description |
---|---|---|
response | communicationData | data from device |
serialized | communicationData | raw transaction |
object
Properties
Name | Type | Description |
---|---|---|
from | string | sending address |
to | string | receiving address |
amount | number | transfer amount |
blockID | string | |
blockNumber | number | |
timestamp | number | |
[feeLimit] | number | |
[expiration] | number |
object
Properties
Name | Type | Description |
---|---|---|
from | string | sending address |
to | string | receiving address |
token | string | number | token id number |
amount | number | transfer amount |
blockID | string | |
blockNumber | number | |
timestamp | number | |
[feeLimit] | number | |
[expiration] | number |
object
Properties
Name | Type | Description |
---|---|---|
from | string | sending address |
to | string | receiving address |
amount | number | string | transfer amount |
contract | string | contract address |
[data] | string | abi encoded string |
blockID | string | |
blockNumber | number | |
timestamp | number | |
[callValue] | number | amount of TRX to send to the contract when triggers. |
[tokenId] | number | id of TRC-10 token to be sent to the contract. |
[tokenValue] | number | amount of TRC-10 token to send to the contract when triggers. |
[feeLimit] | number | |
[expiration] | number |
object
Properties
Name | Type | Description |
---|---|---|
commandData | communicationData | data for sending to device |
rawTx | communicationData | unsigned raw transaction |
© 2018-21 SecuX Technology Inc.
authors:
andersonwu@secuxtech.com
FAQs
SecuX Hardware Wallet TRX API
We found that @secux/app-trx demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
Security News
Socket now integrates with Bun 1.3’s Security Scanner API to block risky packages at install time and enforce your organization’s policies in local dev and CI.
Research
The Socket Threat Research Team is tracking weekly intrusions into the npm registry that follow a repeatable adversarial playbook used by North Korean state-sponsored actors.