@routerprotocol/router-pay-core
v1.0.3
Published
Core library for RouterPay
Downloads
207
Readme
Router Pay Core
Core library for Router Pay. Expand your dapp to anychain in walletless integration.
Installation
npm install @routerprotocol/router-pay-core
Usage
import RouterPay from '@routerprotocol/router-pay-core';
Initializes a new instance of the RouterPay class.
config
: An object containing:quoteUrl
(optional): Custom quote URLtransactionUrl
(optional): Custom transaction URLpartnerId
: Partner ID for RouterPay
const routerPay = new RouterPay({ quoteUrl: 'https://api-beta.pathfinder.routerprotocol.com/api/v2/quote', transactionUrl: 'https://btc-testnet.poap-nft.routernitro.com/internal', partnerId: 123456, });
Methods
getQuote
Retrieves a quote for a payment.
const quote = await routerPay.getQuote({
amount: 100,
currency: 'USD',
partnerId: 123456,
});
createTransaction
Creates a transaction for a payment.
const transaction = await routerPay.createTransaction({
quote: quote,
senderAddress: '0x1234567890123456789012345678901234567890',
receiverAddress: '0x0987654321098765432109876543210987654321',
});
Wait for transaction
Waits for a transaction to be confirmed.
const transaction = await routerPay.waitForTransaction(transaction.depositMeta);