-
Notifications
You must be signed in to change notification settings - Fork 94
Sending textcoins
Textcoin is a payment sent though email or other text based media, such as chat apps (Telegram, Whatsapp, WeChat, etc). See https://medium.com/byteball/sending-cryptocurrency-to-email-5c9bce22b8a9. Textcoins can also be printed on paper, scratch cards, or PIN envelopes and passed on like paper wallets.
Sending textcoins from server-side (headless) wallets is easy: you use the same functions you normally use to send to Byteball addresses but instead of the recipient's Byteball address you write:
-
textcoin:userEmailAddress
for sending to email, or -
textcoin:someUniqueIdentifierOtherThanEmail
for sending via any other text based media
Examples: textcoin:pandanation@wwfus.org
or textcoin:ASDFGHJKL
.
Sample code:
var headlessWallet = require('headless-byteball');
let opts = {
asset: null,
amount: 1000, // bytes
to_address: "textcoin:pandanation@wwfus.org",
email_subject: "Payment in textcoin"
};
headlessWallet.issueChangeAddressAndSendMultiPayment(opts, (err, unit, assocMnemonics) => {
....
});
The opts
object has an optional field email_subject
which is the subject of the email sent to the user. To send emails, you need to set the following fields in your configuration files:
-
from_email
: the address your emails are sent from. Must be on your domain, otherwise the emails are likely to be non-delivered or labeled as spam -
smtpTransport
: type of SMTP transport used to deliver emails:-
local
: (this is the default) use/usr/sbin/sendmail
-
direct
: connect directly to the recipient's MX server, this minimizes the number of intermediaries who are able to see and potentially steal the textcoin, but this method is not reliable as there are no retries -
relay
: send through a relay server. In this case, you need to also set its host name insmtpRelay
. If it requires authentication, you need to also setsmtpUser
andsmtpPassword
.
-
The callback of issueChangeAddressAndSendMultiPayment
and all similar functions has an optional 3rd parameter assocMnemonics
which is an associative array of all generated textcoins (BIP39 mnemonics) indexed by the address
from the input parameters.
{
"textcoin:pandanation@wwfus.org": "barely-album-remove-version-endorse-vocal-weasel-kitten-when-fit-elbow-crop"
}
All the keys of the array have a textcoin:
prefix, like in input parameters.
If you are sending though any media other than email, you use assocMnemonics
to find mnemonics generated for each output address (in the example above, you would find it by the key textcoin:ASDFGHJKL
) and then deliver them yourself.
For example, if you are writing a Telegram bot that rewards users for certain actions, you create a clickable link by prefixing the mnemonic with https://byteball.org/#textcoin?
:
https://byteball.org/#textcoin?barely-album-remove-version-endorse-vocal-weasel-kitten-when-fit-elbow-crop
and send it in chat.
If you are going to print a paper wallet from an ATM, you just print the mnemonic and optionally encode it in a QR code.
Example code in a Telegram bot that sends users textcoins for passing a quiz: https://github.com/byteball/telegram-quiz/blob/master/src/wallet.js
Example code that creates a list of textcoins for subsequent mass sending (e.g. via MailChimp): https://github.com/byteball/headless-byteball/blob/master/play/create_textcoins_list.js