name. This contract will have one unique entry per user, so this key will be a consistent and guaranteed unique value based on the user's
primary_keymethod. Every multi_index struct requires a primary key to be set. Behind the scenes, this method is used according to the index specification of your multi_index instantiation. EOSIO wraps boost::multi_index
primary_key()and return a struct member, in this case, the
keymember as previously discussed.
structwe need to configure the table. The eosio::multi_index constructor needs to be named and configured to use the struct we previously defined.
multi_indexconfiguration there is a table named people, that
_noperator to define an eosio::name type and uses that to name the table. This table contains a number of different singular "persons", so name the table "people".
personstruct defined in the previous step.
codeparameter which is the account on the blockchain that the contract is being deployed to.
eosio.cdt. This method accepts an
nametype argument and asserts that the account executing the transaction equals the provided value and has the proper permissions to do so.
address_index. To instantiate a table, two parameters are required:
get_self()function which will pass the name of this contract.
get_first_receiveris the account name this contract is deployed to.
addressbookcontract now has a functional action that will enable a user to create a row in the table if that record does not yet exist, and modify it if it already exists.
addressbook, making sure to include the ABI declarations and a require_auth that tests against the action's argument
userto verify only the owner of a record can modify their account.
erasefunctions add the following C++11 declaration:
[[eosio.table]]declaration will add the necessary descriptions to the ABI file.
require_authin our contract prevented alice from creating/modifying another user's row.