0.4.7 • Published 28 days ago

@rsksmart/tokenbridge-sdk v0.4.7

Weekly downloads
-
License
ISC
Repository
github
Last release
28 days ago

TokenBridge SDK

TokenBridge SDK simplifies the integration between client applications all the smart contracts that participate in the RSK token bridge.

Installation

npm install @rsksmart/tokenbridge-sdk

Usage

Create TokenBridge client instance

    const tokenBridge = new TokenBridge({ network: 'Testnet', rskConnection: connection })

Set the RPC URLs of the Networks that you'll be crossing and configure the SDK with those networks

    const networks = setNetworksRpcs({
      Sepolia: config.otherNetworkRpc,
      RskTestnet: config.rskRpc
    })
    tokenBridge.setCrossingNetworks(networks.RskTestnet, networks.Sepolia)

Then you can start doing operations with the client

    const toAddress = '0x123...'
    const pair = buildTokenPairs(networks.Sepolia.tokens, networks.RskTestnet.tokens)
      .find(tokenPair => tokenPair.originToken.tokenInfo.symbol === 'LINK') 
    const crossTx = await tokenBridge.cross(pair, 20, toAddress)

You can read more about RSK TokenBridge here.

Connect to RSK

You will need to be connected to the blockchain to execute most of the operations, to do that you need to create a RSKConnection object and provide it during SDK construction Flyover object

    const rsk = await BlockchainConnection.createUsingStandard(window.ethereum)
    const tokenBridge = new TokenBridge({ network: 'Testnet', rskConnection: connection })

Notice that the connection class is called BlockchainConnection. This will be renamed to BlockchainConnection in future updates.

Also you can change SDK connection at any moment by doing the following

    const sepolia = await BlockchainConnection.createUsingStandard(window.ethereum)
    await tokenBridge.changeConnection(sepolia)

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

Application Programming Interface

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

0.4.7

28 days ago

0.4.6

29 days ago

0.4.5

1 month ago

0.4.4

1 month ago

0.3.5

5 months ago

0.3.4

6 months ago

0.3.3

6 months ago

0.3.2

6 months ago

0.3.1

6 months ago

0.3.0

7 months ago

0.2.0

7 months ago

0.1.2

7 months ago

0.1.1

7 months ago

0.1.0

8 months ago