
Security News
Vite+ Joins the Push to Consolidate JavaScript Tooling
Evan You announces Vite+, a commercial, Rust-powered toolchain built on the Vite ecosystem to unify JavaScript development and fund open source.
@dotred/crypto-pay
Advanced tools
@dotred/crypto-pay - is a wrapper over the Crypto Pay API, which makes it easier to interact with the API
To install the library, you need to run the following commands: Supported node versions: 12.22.7+
npm install @dotred/crypto-pay
yarn add @dotred/crypto-pay
First, you need to create your application and get an API token. Open @CryptoBot
or @CryptoTestnetBot (for testnet), send a command /pay
to create a new app
and get API Token.
To start interacting with the API, you need to create a pay-instance. To do this, import the standard method from the library and call it by passing the previously received token
CommonJS example
const {Asset, createPayInstance} = require('@dotred/crypto-pay');
const instance = new createPayInstance('3323:AAlJ6KtPZCeXz8TVEQNX0lMhAldmclcmtnv', 'test');
const workWithInvoices = async () => {
await instance.createInvoice({asset: Asset.BTC, amount: '0.00005',});
await instance.createInvoice({asset: Asset.BTC, amount: '0.000045',});
await instance.createInvoice({asset: Asset.TON, amount: '12',});
const invoices = await instance.getInvoices();
console.log(invoices);
}
workWithInvoices().then().catch();
TypeScript example
import createPayInstance, { CryptoPay } from '@dotred/crypto-pay';
// You can create instance using function
const instance = createPayInstance('your_token');
// or class
const instance = new CryptoPay('your_token')
// If you want to use Testnet, you must pass the network type as the second parameter
const instance = createPayInstance('your_token', 'test');
Let's create some invoices and get only BTC invoices
import createPayInstance, { Asset } from '@dotred/crypto-pay';
const instance = createPayInstance('3138:AAGcw73KFgcqcQ2Sl4sktL2WHuUgAvPpWKh', 'test');
const workWithInvoices = async () => {
await instance.createInvoice({ asset: Asset.BTC, amount: '0.00005', });
await instance.createInvoice({ asset: Asset.BTC, amount: '0.000045', });
await instance.createInvoice({ asset: Asset.TON, amount: '12', });
const invoices = await instance.getInvoices({ asset: Asset.BTC });
console.log(invoices);
}
workWithInvoices().then().catch();
All methods are asynchronous (exception: createPayInstance)
Use this method to create a new pay-instance. Returns an object containing all the methods listed below
A simple method for testing your app's authentication token. Requires no parameters. Returns basic information about the app.
Use this method to create a new invoice. Returns object of created invoice.
asset (string)
Currency code. Supported assets: BTC, TON, ETH (only testnet), USDT, USDC, BUSD.
amount (string)
Amount of the invoice in float. For example: 125.50
description (string)
Optional. Description of the invoice. Up to 1024 symbols.
paid_btn_name (string) default - callback
Optional. Paid button name. This button will be shown when your invoice was paid. Supported names: viewItem -
View Item
openChannel - Open Channel
openBot - Open Bot
callback - Return
paid_btn_url (string)
Optional but requried when you use paid_btn_name. Paid button URL. You can set any payment success link (for example
link on your bot). Start with https or http.
payload (string, up to 1kb)
Optional. Some data. User ID, payment id, or any data you want to attach to the invoice.
Use this method to get invoices of your app. On success, the returns array of invoices.
Use this method to get paid and unconfirmed invoices of your app. On success, the returns array of paid and
unconfirmed
invoices.
Use this method to confirm paid invoice for your app. On success, the return confirmed invoice.
Use this method to get balance of your app. Returns array of assets.
Use this method to get exchange rates of supported currencies. Returns array of currencies.
Use this method to supported currencies. Returns array of currencies.
enum: BTC, TON, ETH, USDT, USDC, BUSD
enum: ACTIVE, PAID
FAQs
@dotred/crypto-pay - is a wrapper over the Crypto Pay API, which makes it easier to interact with the API
The npm package @dotred/crypto-pay receives a total of 12 weekly downloads. As such, @dotred/crypto-pay popularity was classified as not popular.
We found that @dotred/crypto-pay demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Evan You announces Vite+, a commercial, Rust-powered toolchain built on the Vite ecosystem to unify JavaScript development and fund open source.
Security News
Ruby Central’s incident report on the RubyGems.org access dispute sparks backlash from former maintainers and renewed debate over project governance.
Research
/Security News
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.