1.0.2 • Published 1 year ago

ton-inspector v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

TON Inspector

Easily find and confirm TON Blockchain transactions.

🌻 Features

  • Find transactions with (or without) specific message
  • Generate random messages to indentify transactions
  • Generate payment links

🔮 Install

npm i ton-inspector

💡 Basic usage

const inspector = require('ton-inspector') 

inspector.setApiKey('<Place your api key here>')
const amount = inspector.convertTonToNano(1) // Converting to nanocoins is required
inspector.findTransaction('<TON wallet address>', amount, '<Message>')
  .then(wallet => console.log(wallet))  // returns the source wallet
  .catch(err => console.log(err))

🚀 Available functions

setApiKey(api_key)

Authorize requests to TON API with your own API key. This function must be used together with findTransaction() | Parameter | Type | Required | Description | | ------ | ------ | ------ | ------ | | apikey | _String | yes | Sets the TON api key. Use the function before findTransaction() |

You can get your own TON API key using Telegram: @tonapibot

Example:

inspector.setApiKey('<Place your api key here>')
// then you can use findTransaction()

findTransaction(destination, amount, message, retries)

This function is to find the last transaction sent to the destination wallet with following amount of TON Coins and Message. The function sends requests to blockchain every 2 second trying to find the transaction. Maximum number of retries is limited.

ParameterTypeRequiredDescription
destinationStringyesTON wallet address
amountIntegeryesAmount of TON Coins. Notice: you must convert your amount to nanocoins before using the function. Use convertToNano(amount) for that
messageStringnoDefines the message the transaction should be accompanied with
retriesStringnoNumber of retries (Default: 5, max: 20).

Example:

const amount = inspector.convertTonToNano(10) // convert 10 TON to 10000000000 nanocoins
inspector.findTransaction('EQD3I34Ce9RpdNEpgoUB5dgWvywD4dSTVea4g2Da7eW-ETAK', amount, 'Z6W4J')
    .then(wallet => console.log(wallet)) // returns the wallet from where the transaction was sent
    .catch(err => console.log(err)) // returns an error if the transaction was not found

convertTonToNano(amount)

This function converts amount of TON coins into nanocoins. For instance: 1.15 TON => 1150000000 nanocoins

ParameterTypeRequiredDescription
amountInteger or floatyesAmount of TON Coins

Example:

const amount = inspector.convertTonToNano(10)
console.log(amount) // 10000000000

randomMsg(length)

This function generates random message. You can use the message as an unique transaction identificator. See examples for more info.

ParameterTypeRequiredDescription
lengthIntegernoLength of the message (default: 5, min: 3, max: 10)

Example:

console.log(inspector.randomMsg()) // 7XL8Q
console.log(inspector.randomMsg(7)) // LF541AR

generateLink(destination, amount, message)

This function generates payment link. For example, you can use the link in QR code or in a payment button. Link opens up TON Coin wallet app (e.g. Tonkeeper, Tonhub) with pre-generated transaction. See examples for more info.

ParameterTypeRequiredDescription
destinationStringyesTON wallet address
amountIntegeryesAmount of TON Coins. Notice: you must convert your amount to nanocoins before using the function. Use convertToNano(amount) for that
messageStringnoDefines the message the transaction should be accompanied with

Example:

const wallet = 'EQD3I34Ce9RpdNEpgoUB5dgWvywD4dSTVea4g2Da7eW-ETAK' // destination wallet address
const amount = inspector.convertTonToNano(10) // convert 10 TON to 10000000000 nanocoins
const msg = inspector.randomMsg() // generates random message with default length: LZCZ9

const link = inspector.paymentLink(wallet, amount, msg)
console.log(link) // ton://transfer/EQD3I34Ce9RpdNEpgoUB5dgWvywD4dSTVea4g2Da7eW-ETAK?amount=10000000000&text=LZCZ9

📚 Examples

Coming soon

License

MIT

Contact

Feel free to give feedback, share ideas and report bugs.

Telegram: @kirillmelcin

Email: hi@kirillmelcin.ru

Wallet: EQD3I34Ce9RpdNEpgoUB5dgWvywD4dSTVea4g2Da7eW-ETAK

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago