@secux/app-ada
SecuX Hardware Wallet ADA API
Usage
import { SecuxADA, AddressType } from "@secux/app-ada";
First, create instance of ITransport
Examples
-
Get shelley address
const path = "m/1852'/1815'/0'";
const address = await device.getAddress(path, AddressType.BASE);
const path = "m/1852'/1815'/0'";
const address = await device.getAddress(path, AddressType.REWARD);
-
Sign transaction
const inputs = [
{
path: "m/1852'/1815'/0'",
txId: "75c7d745c5212a11a0bfc2719c35bcc2f57fda88d7afb2eb3c5f2b02c3e99ccb",
index: 1,
amount: 12663894,
},
{
path: "m/1852'/1815'/0'",
txId: "6552b8f8b8b282542b07d6187fe80daa5b7a60461c97231f45c06fd97f8a3385",
index: 1,
amount: 2330624,
},
];
const output = {
address: "DdzFFzCqrhsjZHKn8Y9Txr4B9PaEtYcYp8TGa4gQTfJfjvuNLqvB8hPG35WRgK4FjcSYhgK7b2H24jLMeqmPoS3YhJq6bjStsx4BZVnn",
amount: 13000000
};
const { raw_tx } = await device.sign(inputs, output, {
changeAddress: "addr1qyk54vyyc856ngxermdzqhxnlk376ykkupru8rxcyryvg4kxs4un3x4r4rq422kwrtvc8p2a20dzhyr5v0n9lhwy2u6sfjujuz",
});
const input = {
path: "m/1852'/1815'/0'",
utxo: [
{
txId: "75c7d745c5212a11a0bfc2719c35bcc2f57fda88d7afb2eb3c5f2b02c3e99ccb",
index: 1,
amount: 12663894,
}
],
changeAddress: "addr1qyk54vyyc856ngxermdzqhxnlk376ykkupru8rxcyryvg4kxs4un3x4r4rq422kwrtvc8p2a20dzhyr5v0n9lhwy2u6sfjujuz",
};
const pool = "ea595c6f726db925b6832af51795fd8a46e700874c735d204f7c5841";
const { raw_tx } = await device.sign(
input,
pool,
{
needRegistration: true
}
);
const withdrawAmount = 150000;
const { raw_tx } = await device.sign(input, withdrawAmount);
- unstake (de-register staking key)
const { raw_tx } = await device.sign(
input,
{
withdrawAmount
}
);
API Reference
ADA package for SecuX device
Kind: global class
SecuxADA.prepareAddress ⇒ communicationData
Prepare data for address generation.
Returns: communicationData
- data for sending to device
Param | Type | Description |
---|
pathWith3Depth | string | m/1852'/1815'/... |
SecuxADA.addressConvert(xpublickey, type, [option]) ⇒ string
Convert bip32-publickey to ADA address.
Returns: string
- address
Param | Type | Description |
---|
xpublickey | string | Buffer | ada bip32-publickey |
type | AddressType | |
[option] | AddressOption | |
SecuxADA.resolveAddress(response, type, [option]) ⇒ string
Resolve address from response data.
Returns: string
- address
Param | Type | Description |
---|
response | communicationData | data from device |
type | AddressType | |
[option] | AddressOption | |
SecuxADA.prepareXPublickey(pathWith3Depth) ⇒ communicationData
Prepare data for bip32-publickey.
Returns: communicationData
- data for sending to device
Param | Type | Description |
---|
pathWith3Depth | string | m/1852'/1815'/... |
SecuxADA.resolveXPublickey(response) ⇒ string
Resolve bip32-publickey from response data.
Returns: string
- bip32-publickey (hex string)
Param | Type | Description |
---|
response | communicationData | data from device |
SecuxADA.prepareSign(inputs, output, [option]) ⇒ prepared
Prepare data for signing.
Param | Type |
---|
inputs | Array.<txInput> |
output | txOutput |
[option] | signOption |
SecuxADA.resolveSignatureList(response) ⇒ Array.<string>
Reslove signatures from response data.
Returns: Array.<string>
- signature array of hex string
Param | Type | Description |
---|
response | communicationData | data from device |
SecuxADA.resolveTransaction(response, serialized) ⇒ string
Resolve transaction for broadcasting.
Returns: string
- signed transaction (base64 encoded)
Param | Type | Description |
---|
response | communicationData | data from device |
serialized | communicationData | |
© 2018-21 SecuX Technology Inc.
authors:
andersonwu@secuxtech.com