I am trying to send 0 ETH transaction which will be able to send some readable text. I was trying it through data, but it is only used for smart contracts. Can you help me find some solution?
Data field can be used for non-smart contract transactions as well.
You are free to put any text to Data field.
However there are very few use cases where you would want to do so. It is better to pass around messages signed with the private key corresponding the address.
Related
Is it possible to view the actual data (schema data) that is stored by a smart contract? There is a "Counter" smart contract out there and I would like to see (perhaps on a block explorer) how and where this data is stored. I am looking to find the current state of the data (the counter) without calling "get_query" on the contract. Any advice is greatly appreciated.
Short answer no.
Building a contract, as a developer you choose what to send as a response, you can return events, attributes and data that can be read by explorers.
If the contract in question doesn't expose the counter data as an attribute, you have no way of getting this data without doing a query on that contract.
What I want to do is to validate the data inside a protobuf message before I send it to an external network. This is providing a security check.
The problem is that protobufs allow sending additional fields using an updated proto file, which allows backwards compatibility.
What this means is when I go to check a message, my autogenerated code parses the object, but drops the unknown fields. So this means the transmitted bytes could have information I don't know about.
A work around would be to transmit the version of data I have parsed and checked, which would mean dropping the new fields. That's the right security thing to do, but I still won't know that someone is sending me new version of messages. It would be nice to log that and be told I might need to update. I also want to communicate back to the sender that some of their data is being dropped.
Is there a way to know if the format of the message I received mismatches from the format I expect to receive?
As the question states, I'd like to have a user be able to enter something, such as username/password, to the Bot and make sure that the data is encrypted, and also be able to decrypt it (for immediate use only) using a built-in Bot framework encrypt/decrypt method where the secret key is hidden from me (the programmer). Basically I'd to be able to do something like:
string result = await activity;
string sensitiveInfo = Dialog.Decrypt(result.text);
Is there some way to tell a Dialog or the context to encrypt an activity?
This way if there is an activity logger logging chats sensitive chat info is not stored in plain text.
There is no built-in feature in bot framework that does encryption/decryption, you would have to write that piece yourself.
As for flagging a message for logging or not, you would probably be best using channelData rather than one of the state databags This is because the channel data is not associated with state data and only with the activity.
In your comment, you say "But I can't seem to figure out how to retrieve that value from an IActivity object" Well, you cant directly from the activity object itself. You would have to end up doing something like whats in my answer to this question if you were in a controller or something other than a dialog (like your implementation of IActivityLogger). However, when you save your data in channelData it is directly accessible from the Activity/IActivity object like activity.ChannelData.... Channel Data is a (JSON) object you can use to store any data you want and can also be used to send channel specific data to a channel to use the custom features of that channel.
I want to send some custom properties in the attachment for interactive messages and retrieve them back in the action response. is there a way to do this?
Yes, that is possible. However, it only works well for small sets of data.
Assuming we are talking about buttons the normal approach would be to use the value field of an action to transfer custom data based on which button the user clicked back to your app. The field is a normal string within a JSON message, which is send by POST request to your app. So it can in principle contain a whole data set, not only a single value. All you need to do is include it in the button attachment that is send to Slack and your app will receive the respective value field back. (depending on what data you want to send you might need to encode it, e.g. you want to encode binary data into base64, so that is can be transferred as JSON string)
I have used it successfully in one of my apps to transfer serialized objects containing information about the user's application context.
There is one caveat though, that caused me to later abandon this approach again. As I found out the field length is limited, so if your string is too long you might end up with truncated data. In my estimation the limit is about 2.000 chars, but I do not have a definitive number.
Instead of transferring all data in the attachment, I now keep the user application context in a server session (PHP) and only transfer IDs through the value field of my buttons.
Conclusion: If you have small sets of data you can transfer them through the value field. If you have larger sets of data I would not recommend it.
I have a message model and I want it to have several receivers, possibly a lot of them.
I would also like to be able to tell for each receiver if the message was viewed or not (read/unread). Also I would like a receiver to be able to delete the message.
The two possible solutions are the following, for each I have a Message model an User model.
For the first (using the ideas presented here http://www.google.com/events/io/2009/sessions/BuildingScalableComplexApps.html)
I have a MessageReceivers class which has a ListProperty containing the users that will receive the message and set the parent to the message. I query of this with messages = db.GqlQuery('SELECT __key__ FROM MessageReceivers WHERE receivers = :1', user) and the do a db.get([ key.parent() for key in messages ]).
The problem I have which this is that I'm not sure how to store the state of the message: whether it is read or not and a subsequent issue whether the user has new messages. An additional issue would be the overhead of deleting a message (would have to remove user from receivers list property)
For the second: I have a MessageReceiver for each receiver it has links to message and to user and also stores the state (read/unread).
Which of this two approached do you consider that it has a better performance? And in the case of the first do you have any suggestion on handling the status of the message.
I've implement first option in production. Drawback is that ListProperty is limited to 2500 entries if you use custom index. Shameless plug: See my blog bost http://bravenewmethod.wordpress.com/2011/03/23/developing-on-google-app-engine-for-production/
Read state storing. I did this by implementing an entity that stored unread messages up to few months back and then just assumed older ones read. Even simpler is to query the messages in date order, and store the last known message timestamp in entity and assume all older as read. I don't recommended keeping long history in entity with huge list property, because reading and storing such entities can get really slow.
Message deletion is expensive, no way around that.
If you need to store state per message, your best option is to write one entity per recipient, with read state (and anything else, such as flags, etcetera), rather than using the index relation pattern.