From e072dbeb887d377970c55b9951a48a7a1d0008d0 Mon Sep 17 00:00:00 2001 From: ZeroWave022 <36341766+ZeroWave022@users.noreply.github.com> Date: Sun, 18 Feb 2024 23:05:14 +0100 Subject: [PATCH 1/2] docs: Add example on creating transaction --- README.md | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 40f4306..83627bb 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Welcome to the tip.cc API Client npm package! -# Installation +## Installation Simply create an npm project if you don't have an already, and install the package. @@ -11,7 +11,7 @@ npm init npm i tipcc.js ``` -# Getting Started +## Getting Started > Tip: Want to get started without an introduction? Check out our [documentation](https://tipccjs.org/). @@ -59,6 +59,8 @@ client.on('ready', async () => { ## Transactions +### Events + To receive transactions as events, use [TransactionManager](https://tipccjs.org/classes/TransactionManager)'s events: ```js @@ -71,6 +73,8 @@ client.transactions.on('tip', (transaction) => { }); ``` +### Fetching + You can also get a single or many transactions by id: ```js @@ -97,6 +101,27 @@ client.on('ready', async () => { Using no filter will get all transactions for the bot/user. This is not recommended, unless you know what you're doing. +### Creating (sending) + +You can send a transaction to one or more users: + +```js +client.on('ready', async () => { + const transaction = await client.transactions.create({ + recipient_s: ['discord-id-here'], + value: '0.1', + currencyCode: 'BTC', + }); + + const amount = transaction[0].amount; + + console.log(`${amount.value} ${amount.currencyCode} successfully sent to ${transaction[0].recipient.username}`,); +}); +``` + +Notice that you can choose between using a `rawValue` or `value` when sending a transaction. +The `value` will automatically get converted, while `rawValue` assumes you have done this conversion yourself. + ## Exchange rates Use the [ExchangeRateCache](https://tipccjs.org/classes/ExchangeRateCache) to get exchange rates: From 3e6f2aaca38f5a6c8ac6481c0bb399d71591779a Mon Sep 17 00:00:00 2001 From: ZeroWave022 <36341766+ZeroWave022@users.noreply.github.com> Date: Sun, 18 Feb 2024 23:09:19 +0100 Subject: [PATCH 2/2] docs: Remove typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 83627bb..251e547 100644 --- a/README.md +++ b/README.md @@ -115,7 +115,7 @@ client.on('ready', async () => { const amount = transaction[0].amount; - console.log(`${amount.value} ${amount.currencyCode} successfully sent to ${transaction[0].recipient.username}`,); + console.log(`${amount.value} ${amount.currencyCode} successfully sent to ${transaction[0].recipient.username}`); }); ```