Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@secux/app-ada

Package Overview
Dependencies
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@secux/app-ada

SecuX Hardware Wallet ADA API

  • 3.0.4
  • latest
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

lerna view on npm npm module downloads

@secux/app-ada

SecuX Hardware Wallet ADA API

Usage

import { SecuxADA, AddressType } from "@secux/app-ada";

First, create instance of ITransport


Examples

  1. Get shelley address

    • base address
    const path = "m/1852'/1815'/0'";
    const address = await device.getAddress(path, AddressType.BASE);
    
    /*
    
    // transfer data to hardware wallet by custom transport layer
    const data = SecuxADA.prepareAddress(path);
    const response = await device.Exchange(data);
    const address = SecuxADA.resolveAddress(response, AddressType.BASE);
    
    */
    
    • reward address
    const path = "m/1852'/1815'/0'";
    const address = await device.getAddress(path, AddressType.REWARD);
    
  2. Sign transaction

    • transfer asset
    const inputs = [
        {
            path: "m/1852'/1815'/0'",
            txId: "75c7d745c5212a11a0bfc2719c35bcc2f57fda88d7afb2eb3c5f2b02c3e99ccb",
            index: 1,
            amount: 12663894,
            // for custom transport layer, each utxo needs xpublickey.
            // xpublickey: "c232950d7c27b78542795ce4cad053e8dfaab7679ba5477563be5c60c1a4d0613fc81fd9bb8f30822c1252c29cc6af147831da44fb86acad6c04fcc95700b92b"
        },
        {
            path: "m/1852'/1815'/0'",
            txId: "6552b8f8b8b282542b07d6187fe80daa5b7a60461c97231f45c06fd97f8a3385",
            index: 1,
            amount: 2330624,
            // for custom transport layer, each utxo needs xpublickey.
            // xpublickey: "c232950d7c27b78542795ce4cad053e8dfaab7679ba5477563be5c60c1a4d0613fc81fd9bb8f30822c1252c29cc6af147831da44fb86acad6c04fcc95700b92b"
        },
    ];
    
    const output = {
        // daedalus or shelley address is accepted.
        address: "DdzFFzCqrhsjZHKn8Y9Txr4B9PaEtYcYp8TGa4gQTfJfjvuNLqvB8hPG35WRgK4FjcSYhgK7b2H24jLMeqmPoS3YhJq6bjStsx4BZVnn",
        amount: 13000000
    };
    
    const { raw_tx } = await device.sign(inputs, output, {
        changeAddress: "addr1qyk54vyyc856ngxermdzqhxnlk376ykkupru8rxcyryvg4kxs4un3x4r4rq422kwrtvc8p2a20dzhyr5v0n9lhwy2u6sfjujuz",
    });
    
    /*
    
    // transfer data to hardware wallet by custom transport layer.
    const { commandData, serialized } = SecuxADA.prepareSign(inputs, output, {
        changeAddress: "addr1qyk54vyyc856ngxermdzqhxnlk376ykkupru8rxcyryvg4kxs4un3x4r4rq422kwrtvc8p2a20dzhyr5v0n9lhwy2u6sfjujuz",
    });
    const response = await device.Exchange(commandData);
    const raw_tx = SecuxADA.resloveTransaction(response, serialized);
    
    */
    
    • stake
    const input = {
        path: "m/1852'/1815'/0'",
        utxo: [
            {
                txId: "75c7d745c5212a11a0bfc2719c35bcc2f57fda88d7afb2eb3c5f2b02c3e99ccb",
                index: 1,
                amount: 12663894,
            }
        ],
        changeAddress: "addr1qyk54vyyc856ngxermdzqhxnlk376ykkupru8rxcyryvg4kxs4un3x4r4rq422kwrtvc8p2a20dzhyr5v0n9lhwy2u6sfjujuz",
        // for custom transport layer, each utxo needs xpublickey.
        // xpublickey: "c232950d7c27b78542795ce4cad053e8dfaab7679ba5477563be5c60c1a4d0613fc81fd9bb8f30822c1252c29cc6af147831da44fb86acad6c04fcc95700b92b"
    };
    
    // pool id (support bech32 encoded)
    const pool = "ea595c6f726db925b6832af51795fd8a46e700874c735d204f7c5841";
    
    const { raw_tx } = await device.sign(
        input,
        pool,
        {
            // An account needs to have a stake pool registration certificate 
            // before it can participate in stake delegation between stake pools.
            needRegistration: true
        }
    );
    
    /*
    
    // transfer data to hardware wallet by custom transport layer.
    const { commandData, serialized } = SecuxADA.prepareStake(
        input,
        pool,
        {
            needRegistration: true
        }
    );
    const response = await device.Exchange(commandData);
    const raw_tx = SecuxADA.resolveTransaction(response, serialized);
    
    */
    
    • withdrawal
    const withdrawAmount = 150000;
    const { raw_tx } = await device.sign(input, withdrawAmount);
    
    /*
    
    // transfer data to hardware wallet by custom transport layer.
    const { commandData, serialized } = SecuxADA.prepareStake(input, withdrawAmount);
    const response = await device.Exchange(commandData);
    const raw_tx = SecuxADA.resolveTransaction(response, serialized);
    
    */
    
    • unstake (de-register staking key)
    const { raw_tx } = await device.sign(
        input, 
        {
            // With de-registration operation, the balance of reward address must be 0.
            withdrawAmount
        }
    );
    
    /*
    
    // transfer data to hardware wallet by custom transport layer.
    const { commandData, serialized } = SecuxADA.prepareUnstake(input, { withdrawAmount });
    const response = await device.Exchange(commandData);
    const raw_tx = SecuxADA.resolveTransaction(response, serialized);
    
    */
    

API Reference

ADA package for SecuX device

Kind: global class


SecuxADA.addressConvert(xpublickey, type, [option]) ⇒ string

Convert bip32-publickey to ADA address.

Returns: string - address

ParamTypeDescription
xpublickeystring | Bufferada bip32-publickey
typeAddressType
[option]AddressOption

SecuxADA.prepareAddress(pathWith3Depth) ⇒ communicationData

Prepare data for address generation.

Returns: communicationData - data for sending to device

ParamTypeDescription
pathWith3Depthstringm/1852'/1815'/...

SecuxADA.resolveAddress(response, type, [option]) ⇒ string

Resolve address from response data.

Returns: string - address

ParamTypeDescription
responsecommunicationDatadata from device
typeAddressType
[option]AddressOption

SecuxADA.prepareXPublickey(pathWith3Depth) ⇒ communicationData

Prepare data for bip32-publickey.

Returns: communicationData - data for sending to device

ParamTypeDescription
pathWith3Depthstringm/1852'/1815'/...

SecuxADA.resolveXPublickey(response) ⇒ string

Resolve bip32-publickey from response data.

Returns: string - bip32-publickey (hex string)

ParamTypeDescription
responsecommunicationDatadata from device

SecuxADA.prepareSign(inputs, output, [option]) ⇒ prepared

Prepare data for signing.

ParamType
inputsArray.<txInput>
outputtxOutput
[option]signOption

SecuxADA.resolveSignatureList(response) ⇒ Array.<string>

Reslove signatures from response data.

Returns: Array.<string> - signature array of hex string

ParamTypeDescription
responsecommunicationDatadata from device

SecuxADA.resolveTransaction(response, serialized) ⇒ string

Resolve transaction for broadcasting.

Returns: string - signed transaction (base64 encoded)

ParamTypeDescription
responsecommunicationDatadata from device
serializedcommunicationData

SecuxADA.prepareStake(input, pool, [option]) ⇒ prepared

Prepare data for signing.

ParamTypeDescription
inputstakeInput
poolstringpool hash or id
[option]stakeOption

SecuxADA.prepareUnstake(input, [option]) ⇒ prepared

Prepare data for signing.

ParamType
inputstakeInput
[option]unstakeOption

SecuxADA.prepareWithdraw(input, amount, [option]) ⇒ prepared

Prepare data for signing.

ParamTypeDescription
inputstakeInput
amountnumber | stringrewards
[option]withdrawOption



AddressType : enum

Properties

NameTypeDescription
BASEnumber0
ENTERPRISEnumber1
POINTERnumber2
REWARDnumber3
BOOTSTRAPv1number4
BOOTSTRAPv2number5

PointerOption : object

Properties

NameType
slotnumber
txIndexnumber
certIndexnumber

AddressOption : object

Properties

NameTypeDescription
[addressIndex]numberaccount index
[stakeIndex]numberstake key index
[pointer]PointerOptionoption for Pointer address

txInput : object

Properties

NameTypeDescription
pathstring3-depth path of CIP-1852
xpublickeystring | BufferED25519 publickey from path
txIdstringreferenced transaction hash
indexnumberreferenced transaction output index
amountnumber | stringreferenced transaction output amount
[addressIndex]numberdefault: 0
[stakeIndex]numberdefault: 0

txOutput : object

Properties

NameTypeDescription
addressstringreceiver's address
amountnumber | stringamount of payment

signOption : object

Properties

NameTypeDescription
[changeAddress]stringdefault: sender's address
[fee]number | string
[TimeToLive]number

stakeOption : object

Properties

NameTypeDescription
[stakeIndex]numberdefault: 0
[needRegistration]booleaninclude registration or not
[fee]number | string
[TimeToLive]number

withdrawOption : object

Properties

NameTypeDescription
[stakeIndex]numberdefault: 0
[fee]number | string
[TimeToLive]number

unstakeOption : object

Properties

NameTypeDescription
[stakeIndex]numberdefault: 0
[withdrawAmount]booleanwithdraw and de-registration
[fee]number | string
[TimeToLive]number

utxo : object

Properties

NameTypeDescription
txIdstringreferenced transaction hash
indexnumberreferenced transaction output index
amountnumber | stringreferenced transaction output amount
[addressIndex]numberdefault: 0

stakeInput : object

Properties

NameTypeDescription
pathstring3-depth path of CIP-1852
utxoArray.<utxo>
changeAddressstringowner's account
xpublickeystring | Buffercardano bip32-publickey
[stakeIndex]numberdefault: 0

prepared : object

Properties

NameTypeDescription
commandDatacommunicationDatadata for sending to device
serializedcommunicationData


© 2018-21 SecuX Technology Inc.

authors:
andersonwu@secuxtech.com

Keywords

FAQs

Package last updated on 13 Apr 2022

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc