@rsksmart/flyover-sdk
TypeScript icon, indicating that this package has built-in type declarations

1.4.6 • Public • Published

Flyover SDK

Flyover SDK simplifies the integration between client applications and the components of the Flyover Protocol by providing an easy to use interface.

Installation

npm install @rsksmart/flyover-sdk

Usage

Create Flyover client instance

    const flyover = new Flyover({ network: 'Regtest'})

If you want, you can provide your own Regtest environment URL, if custom environment URL is not secure, then you must allow insecure connections

    const flyover = new Flyover({
        network: 'Regtest',
        customRegtestUrl: 'http://localhost:8080',
        allowInsecureConnections: true
    })

Then you can start doing operations with the client

    const providers = await flyover.getLiquidityProviders()
    flyover.useLiquidityProvider(providers.at(0))
    const quotes = await flyover.getQuotes({ /* QuoteRequest data... */ })
    const acceptedQuote = await flyover.acceptQuote(quotes.at(0))

You can read more about Flyover Protocol here or in its integration manual.

Connect to RSK

If you need to connect to RSK to execute some operation then you need to create an RSKConnection and provide it to Flyover object

    const rsk = await BlockchainConnection.createUsingStandard(window.ethereum)
    const flyover = new Flyover({ rskConnection: rsk, network: 'Regtest' })

or you can set it after creation

    const rsk = await BlockchainConnection.createUsingStandard(window.ethereum)
    await flyover.connectToRsk(rsk)

Also you can provide your own regtest LBC address if you want to connect to a local node for development purposes

    const rsk = await BlockchainConnection.createUsingStandard(window.ethereum)
    const flyover = new Flyover({ 
        rskConnection: rsk, 
        network: 'Regtest', 
        customLbcAddress: '0x1eD614cd3443EFd9c70F04b6d777aed947A4b0c4' 
    })

There are 3 ways to create an RSK connection, you can check them in RSKConnection class documentation

Supported addresses

Currently, not all the types of Bitcoin addresses are supported in Flyover Protocol. The address support is summarized in the following table:

Address type Testnet prefix Mainnet prefix Supported Testnet example Mainnet example
P2PKH m or n 1 mvL2bVzGUeC9oqVyQWJ4PxQspFzKgjzAqe 12higDjoCCNXSA95xZMWUdPvXNmkAduhWv
P2SH 2 3 2MzQwSSnBHWHqSAqtTVQ6v47XtaisrJa1Vc 342ftSRCvFHfCeFFBuz4xwbeqnDw6BGUey
P2WPKH tb1 bc1 tb1qvprq2gqzhj5nqmp8tm598yrs2g32vm0ut2lcge bc1q34aq5drpuwy3wgl9lhup9892qp6svr8ldzyy7c
P2WSH tb1 bc1 tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3q0sl5k7 bc1qeklep85ntjz4605drds6aww9u0qr46qzrv5xswd35uhjuj8ahfcqgf6hak
P2TR tb1p bc1p tb1p5cyxnuxmeuwuvkwfem96lqzszd02n6xdcjrs20cac6yqjjwudpxqp3mvzv bc1p5d7rjq7g6rdk2yhzks9smlaqtedr4dekq08ge8ztwac72sfr9rusxg3297

Model Syncrhonization

To synchronize the data structures of the project with the ones of the Liquidity Provider Server you need to run npm run api-sync <branch name>. This will update the src/api/bindings folder updating each structure to match LPS. All fields types will coincide with server structures, but its important to clarify that fields whose name contains the word fee, nonce, amount, cost or value will be build as bigint in TS interface instead of number. To synchronize the ABI of the LBC you need to run npm run api-sync <branch name>.

Application Programming Interface

To see the full API of this package please refer to the the docs folder of this project

Package Sidebar

Install

npm i @rsksmart/flyover-sdk

Weekly Downloads

6

Version

1.4.6

License

ISC

Unpacked Size

98.8 kB

Total Files

4

Last publish

Collaborators

  • luis.chavez.iov
  • maximst