Skip to content

Latest commit

 

History

History
137 lines (127 loc) · 2.86 KB

nemSignTransaction.md

File metadata and controls

137 lines (127 loc) · 2.86 KB

NEM: Sign transaction

Asks device to sign given transaction. User is asked to confirm all transaction details on Trezor.

ES6

const result = await TrezorConnect.nemSignTransaction(params);

CommonJS

TrezorConnect.nemSignTransaction(params).then(function(result) {

});

Params

Optional common params

  • path - required string | Array<number>
  • transaction - required Object type of NEMTransaction

Example

Sign simple transaction

// common utility for hexlify message
function hexlify(str) {
    var result = '';
    var padding = '00';
    for (var i=0, l=str.length; i<l; i++) {
        var digit = str.charCodeAt(i).toString(16);
        var padded = (padding+digit).slice(-2);
        result += padded;
    }
    return result;
}

TrezorConnect.nemSignTransaction(
    path: "m/44'/1'/0'/0'/0'",
    transaction: {
        timeStamp: 74649215,
        amount: 2000000,
        fee: 2000000,
        recipient: "TALICE2GMA34CXHD7XLJQ536NM5UNKQHTORNNT2J",
        type: 257,
        deadline: 74735615,
        version: (0x98 << 24),
        message: {
            payload: hexlify('test_nem_transaction_transfer'),
            type: 1,
        },
    }
});

Sign mosaic transaction

TrezorConnect.nemSignTransaction(
    path: "m/44'/1'/0'/0'/0'",
    transaction: {
        timeStamp: 76809215,
        amount: 1000000,
        fee: 1000000,
        recipient: "TALICE2GMA34CXHD7XLJQ536NM5UNKQHTORNNT2J",
        type: 257,
        deadline: 76895615,
        version: (0x98 << 24),
        message: {},
        mosaics: [
            {
                mosaicId: {
                    namespaceId: "nem",
                    name: "xem",
                },
                quantity: 1000000,
            }
        ]
    }
});

Result

{
    success: true,
    payload: {
        data: string,
        signature: string,
    }
}

Error

{
    success: false,
    payload: {
        error: string // error message
    }
}

Migration from older version

version 4 and below

var tx = {
    timeStamp: 74649215,
    amount: 2000000,
    fee: 2000000,
    recipient: "TALICE2GMA34CXHD7XLJQ536NM5UNKQHTORNNT2J",
    type: 257,
    deadline: 74735615,
    version: (0x98 << 24),
    message: {
        payload: hexlify('test_nem_transaction_transfer'),
        type: 1,
    },
}
TrezorConnect.nemSignTx(
  "m/44'/1'/0'/0'/0'",
  tx,
  function(result) {
      // result not changed
  }
)

version 5

// params are key-value pairs inside Object
TrezorConnect.nemSignTransaction({ 
    path: "m/44'/1'/0'/0'/0'",
    transaction: tx
}).then(function(result) {
    // result not changed
})