SecuX Hardware Wallet SOL API



@secux/app-sol> SecuX Hardware Wallet SOL API
``ts`
import { SecuxSOL } from "@secux/app-sol";
First, create instance of ITransport.
- Web Usb
- Web Bluetooth
- React Native Bluetooth
ts
const path = "m/44'/501'/0'";
const address = await device.getAddress(path); /*
// transfer data to hardware wallet by custom transport layer.
const data = SecuxBTC.prepareAddress(path);
const response = await device.Exchange(data);
const address = SecuxBTC.resolveAddress(response, path);
*/
`
- associated account
`ts
const address = await device.getAddress(
"m/44'/501'/0'",
// USDC
{ mintAccount: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v" }
);
`
- account with seed
`ts
const address = await device.getAddress(
"m/44'/501'/0'",
{
seed: "seed",
programId: "Stake11111111111111111111111111111111111111"
}
);
`2. Sign transaction.
- transfer asset
`ts
const { raw_tx } = await device.sign(
"",
instructions: [
{
type: "transfer",
params: {
to: "",
lamports: 1e9,
path: "m/44'/501'/0'"
}
}
]
); /*
// transfer data to hardware wallet by custom transport layer.
const { commandData, serialized } = SecuxSOL.prepareSign(
"",
instructions: [
{
type: "transfer",
params: {
from: "",
to: "",
lamports: 1e9,
path: "m/44'/501'/0'"
}
}
]
);
const response = await device.Exchange(commandData);
const raw_tx = SecuxSOL.resloveTransaction(response, serialized);
*/
` - transfer SPL token
`ts
const { raw_tx } = await device.sign(
"",
instructions:
SecuxSOL.Action.transferToken(
{
to: "",
owner: "",
amount: 1e6,
mint: "",
decimal: 6,
path: "m/44'/501'/0'",
// create ATA for reciever
createAccount: true
}
)
);
` - native staking
`ts
const { raw_tx } = await device.sign(
"",
instructions:
SecuxSOL.Action.stake(
{
owner: "",
stake: "",
vote: "",
lamports: 1e9,
path: "m/44'/501'/0'", // if give a seed, the createWithSeed instruction will be included.
// stake: ""
}
)
);
` - unstake
`ts
const { raw_tx } = await device.sign(
"",
instructions:
SecuxSOL.Action.unstake(
{
owner: "",
stake: "",
lamports: ,
path: "m/44'/501'/0'"
}
)
);
``Kind: global class
* SecuxSOL
* [.addressConvert(publickey, [option])](#SecuxSOL.addressConvert) ⇒ string
* .prepareAddress(path) ⇒ communicationData
* [.resolveAddress(response, [option])](#SecuxSOL.resolveAddress) ⇒ string
* .preparePublickey(path) ⇒ communicationData
* .resolvePublickey(response) ⇒ string
* .prepareSign(feePayer, content) ⇒ prepared
* .resolveSignatureList(response) ⇒ Array.<string>
* .resolveTransaction(response, serialized) ⇒ string
Returns: string - address
| Param | Type | Description |
| --- | --- | --- |
| publickey | string \| Buffer | ed25519 publickey |
| [option] | ATAOption \| SeedOption | |
Returns: communicationData - data for sending to device
| Param | Type | Description |
| --- | --- | --- |
| path | string | BIP32 path (hardened child key), ex: m/44'/501'/0'/0' |
Returns: string - SOL address
| Param | Type | Description |
| --- | --- | --- |
| response | communicationData | data from device |
| [option] | ATAOption \| SeedOption | |
Returns: communicationData - data for sending to device
| Param | Type | Description |
| --- | --- | --- |
| path | string | BIP32 path (hardened child key), ex: m/44'/501'/0'/0' |
Returns: string - ed25519 publickey (hex string)
| Param | Type | Description |
| --- | --- | --- |
| response | communicationData | data from device |
Returns: prepared - prepared object
| Param | Type | Description |
| --- | --- | --- |
| feePayer | string | solana account |
| content | txDetail | transaction object |
Returns: Array.<string> - signature array (base58 encoded)
| Param | Type | Description |
| --- | --- | --- |
| response | communicationData | data from device |
Returns: string - signed transaction (hex)
| Param | Type | Description |
| --- | --- | --- |
| response | communicationData | data from device |
| serialized | communicationData | |
object| Name | Type | Description |
| --- | --- | --- |
| mintAccount | string | token mint address |
object| Name | Type | Description |
| --- | --- | --- |
| seed | string | arbitary string (UTF-8) |
| programId | string | program address |
object| Name | Type | Description |
| --- | --- | --- |
| publickey | string \| Buffer | Ed25519 publickey |
| isSigner | boolean | |
| isWritable | boolean | |
| [path] | string | the path for signing |
object| Name | Type | Description |
| --- | --- | --- |
| programId | string | program address |
| accounts | accounts | |
| data | string \| Buffer | hex string or buffer |
object| Name | Type | Description |
| --- | --- | --- |
| type | string | instruction type |
| params | any | parameters |
object| Name | Type | Description |
| --- | --- | --- |
| recentBlockhash | string | a recent blockhash |
| instructions | Array.<(Instruction\|BuiltinInstruction)> | a least one instruction in a transaction |
| [feepayerPath] | string | option for signing via SecuX wallet |
object| Name | Type | Description |
| --- | --- | --- |
| commandData | communicationData | data for sending to device |
| rawTx | string | unsigned raw transaction |
*
© 2018-22 SecuX Technology Inc.
authors:
andersonwu@secuxtech.com