2

I wan't to be able to send a text string to another EOS account. How can this be done? Are there any mobile wallets that support this?

1 Answer 1

2

Yes, you can send arbitrary text messages to any account using the require_recipient() function. This function will introduce an inline action that communicates the parameters passed to the action to the desired recipient.

Example contract:

send_messages.cpp

#include <eosiolib/eosio.hpp>
#include <string>

using eosio::contract;
using std::string;

class send_messages : contract {
    public:
        send_messages(account_name account) : contract(account) {};

        void send(account_name account, string message) {
            require_recipient(account);
        }
};

EOSIO_ABI(send_messages, (send));

Afterwards, pushing an action to the contract as follows:

$ cleos push action <account-name> send '["<recipient>", "message"]' -p <acount-name>

would send the string "message" to the <recipient> in the form of an action.


In regards to wallet support for this, you only need a software that allows you to push actions to your contract, which would be enough as long as you publish your contract on the blockchain first.


what is the max character limit? and what is the cost of sending 1K, 10K, and 100KB text message.

There's not really a hard max character limit, as you can send as many strings of max_size() as you want. However, to process larger strings, you need more CPU and NET staked, but these resources are a bit impractical to approximate right now, especially as EOS renting systems would make this cheaper.

Naive calculation

However, if you want a back of the envelope calculations, perhaps you'd need to have staked about 0.01 EOS / 10,000 bytes message / day at current rates.

Explanation:

NET

For NET you'd need approximately as many bytes the message has + ~100bytes (e.g. you'd need 10,100 bytes to send a 10,000 bytes message.) According to eosrp.io, the price right now is 0.00050833 EOS/KiB/Day, so perhaps you'd look at 0.005 EOS / 10,000 bytes message / day for NET

CPU

This depends on the BP, the load, etc, and it's highly volatile, but I just tried to make such a transaction on Jungle testnet, and I got 2,000us. At current price of 0.00269295 EOS/ms/Day, that'd be ~0.005 EOS / 10,000 bytes message / day for CPU

2
  • what is the max character limit? and what is the cost of sending 1K, 10K, and 100KB text message. Commented Oct 4, 2018 at 17:07
  • @Patoshiパトシ updated my answer to include some cost discussion, but i wouldn't put too much thought in these estimates for now as the network keeps changing
    – confused00
    Commented Oct 4, 2018 at 17:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.