@coolwallets/icx
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

CoolWalletS ICX App

ICON API of CoolWalletS.

version

Install

npm install @coolwallets/icx

Usage

import cwsICX from '@coolwallets/icx'
const ICON = new cwsICX(transport, appPrivateKey, appId)

getAddress

Get address by address index.

const address = await ICON.getAddress(0)
console.log(address)

// hx76f46307b53686f2dd4a2c8ca2f22492e842c4bf

The address generated is compatible to BIP44 with account and change set to 0, which means calling getAddress(i) will get the address of folllowing BIP44 path:

m/44'/60'/0'/0/{i}

In the design of current hardware, we only support path m/44'/60'/0'/0/{i} for speed optimization. This might change in the future and we will then open a more general interface to deal with custom path.

signTransaction

Sign ICON Transaction. We suggest you to use Icon Official SDK to build an unsigned transaction.

const txObj = new IconBuilder.IcxTransactionBuilder()
    .from('hx76f46307b53686f2dd4a2c8ca2f22492e842c4bf')
    .to('hxe86b015c06145965931aff551d4958256a86226e')
    .value(IconAmount.of('0.023', IconAmount.Unit.ICX).toLoop())
    .stepLimit(IconConverter.toBigNumber(100000))
    .nid(IconConverter.toBigNumber(1))
    .version(IconConverter.toBigNumber(3))
    .timestamp(timestamp)
    .build();

// Returns raw transaction object
const rawTx = IconConverter.toRawTransaction(txObj);

// sign with address index 0
const signedTx = await ETH.signTransaction(rawTx, 0)

The signed transaction will be in form of Object, which you can use the official sdk to broadcast.

Package Sidebar

Install

npm i @coolwallets/icx

Weekly Downloads

20

Version

0.0.2

License

ISC

Unpacked Size

54.4 kB

Total Files

13

Last publish

Collaborators

  • coolwallet-team