0

From this tutorial

addressbook(name receiver, name code, datastream<const char*> ds): contract(receiver, code, ds)

I'm not familiar with 'datastream' and Googling isn't turning up any precise documentation on what that means. It seems to be the type for 'ds' in this context. But it's unclear to me what that type is, or by extension -- what 'ds' is.

1 Answer 1

0

You can consider it SerialBuffer in eosjs. Action data is transmitted in the form of byte sequence. eosio::contract from which class you inherits when you write your own smart contract, it generates code for dispatching action by deserializing byte sequence (action data) to proper arguments for action. (eg. name from, name to, asset quantity, string memo for eosio.token::transfer)

Usually you don't need to use datastream by yourself, but if you need to generate packed bytes, or deserialize specific type of data, you can utilize datastream. Refer to this example.

2
  • Thanks! Is this just standard constructor that is always (or often) used? addressbook(name receiver, name code, datastream<const char *> ds) : contract(receiver, code, ds){}
    – user4272
    Nov 1, 2020 at 7:50
  • 1
    Yes, it's standard form of eosio contract constructor. Or, you can write using contract::contract, if you don't have jobs to handle in constructor.
    – conr2d
    Nov 1, 2020 at 10:27

Your Answer

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