1

Suppose I want to save and send this information to all the world:

"I'm Fu Song, I made Taylor Swift pregnant, and I'm going to marry her on Christmas, 2018, so that I will still be a responsible man. I'll never fail her, and I'll kneel in front of the world if I fail her."

Should this information be within a transaction? If so, the "from" of transaction is my public address, but who should be the "to" of this transaction? (we can assume the data will be serialize into binary and save, if that matters)

1
  • What's more, could this save&send thing go without a smart contract? – Fu Song Jul 13 '18 at 7:37
0

First of all I would like to mention that the information which you intend to publish in the blockchain for the world to see seems to be incredibly important! xD

In the EOSIO software you actually center the interaction with the blockchain in the following way:

Transactions are pieces of computation that can either run fully to completion or be rolled back or discarded if they are invalid. Each transaction can have one or more actions, so if one of the action fails, the whole transaction fails and none of the other actions are applied on the blockchain.

This model moves away from the concept of transactions being simply a sending of funds from one account to another. Transactions in EOSIO are units of work that happen fully or not at all, similar to classical database transactions. This way, actions become the main place where smart contract work happens, and they can be very flexible. A typical transfer of funds becomes simply a transaction that contains a single action that is applied on the token contract to move the funds from one account to the other. This "transfer" action is defined in the contract's code, and it requires specific parameters, like from and to (the accounts), and amount that is being transferred.

For your case, you could define an action in your smart contract that could be called publish_important_info with a parameter info which is the string that gets stored in the blockchain. Your action's code could then grab that info and store it using the EOSIO persistence database API.

6
  • Thank you Andres! And I appreciate you valueing my important message : ) Actually I wonder: so recording and saving has to relate to a smart contract? Can I do it without a smart contract? – Fu Song Jul 13 '18 at 7:35
  • @FuSong every action is defined by some smart contract, even the transfer actions, which are in the eosio.token contract for example. If you wanted to just record a message in the blockchain without creating a specific contract for that, you could simply do a transfer and specify your message in the memo parameter I suppose. – Andres Berrios Jul 14 '18 at 0:21
  • Also please mark my answer as accepted if you found it useful and if it clears up your doubt. – Andres Berrios Jul 14 '18 at 0:22
  • Oh, you just really cleared my doubts. The best answer ever! – Fu Song Jul 14 '18 at 3:23
  • 1
    @AndrésBerríos I recently saw eosproof.io that provides a service you might be looking for (Note, I am not related to that project and it is not (yet?) open sourced) – friedger Jul 14 '18 at 10:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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