@rsksmart/tokenbridge-sdk
v0.4.11
Published
SDK that simplifies interaction between RSK TokenBridge and client applications
Downloads
14
Readme
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