From ac2c16b5e4e4ca51df2ddf36212f4892ea1c62a8 Mon Sep 17 00:00:00 2001 From: iamveritas Date: Fri, 2 Apr 2021 12:07:27 +0300 Subject: [PATCH 1/9] updates to match newest how to template --- .../01_compile-a-contract-via-cli.md | 49 +++++++---- .../10_compile/02_how-to-configure-cmake.md | 84 ++++++++++++------- .../03_compiling-contracts-with-cmake.md | 40 ++++++--- ...to_restrict_access_to_an_action_by_user.md | 31 +++++-- 4 files changed, 135 insertions(+), 69 deletions(-) diff --git a/docs/06_how-to-guides/10_compile/01_compile-a-contract-via-cli.md b/docs/06_how-to-guides/10_compile/01_compile-a-contract-via-cli.md index 060efe3869..efd2773736 100644 --- a/docs/06_how-to-guides/10_compile/01_compile-a-contract-via-cli.md +++ b/docs/06_how-to-guides/10_compile/01_compile-a-contract-via-cli.md @@ -1,20 +1,35 @@ --- -content_title: How to compile a contract via CLI +content_title: How to compile a smart contract via CLI --- -## Preconditions -- You have the source of your contract saved in one of your local folders, e.g. `./examples/hello` -For details on how to create your first contract follow [this tutorial here](https://developers.eos.io/eosio-home/docs/your-first-contract) - -Follow these steps to compile your contract: - -1. Navigate to the hello folder in examples (./examples/hello), you should then see the ./src/hello.cpp file -2. Now run following commands: -```sh -$ mkdir build -$ cd build -$ eosio-cpp -abigen ../src/hello.cpp -o hello.wasm -I ../include/ -``` -3. This will generate two files: -- The compiled binary wasm, hello.wasm -- The generated ABI file, hello.abi +## Overview + +This how-to guide provides instructions how to compile a smart contract using the command line interface (CLI). + +## Before you begin + +* You have the source of the contract saved in a local folder, e.g. `./examples/hello/` +For details on how to create your first contract follow the [Hello World Contract](https://developers.eos.io/welcome/latest/smart-contract-guides/hello-world) guide. + +## Procedure + +Follow the following steps to compile your contract. + +1. Navigate to the hello folder in examples `./examples/hello`. You should see the `./src/hello.cpp` file. + +2. Run the following commands: + + ```sh + mkdir build + cd build + eosio-cpp -abigen ../src/hello.cpp -o hello.wasm -I ../include/ + ``` + +3. Verify the following two files were generated: + +* the compiled binary wasm: `hello.wasm`, +* and the generated ABI file: `hello.abi`. + +## Summary + +In conclusion, the above instructions show how to compile a smart contract using the command line interface (CLI). diff --git a/docs/06_how-to-guides/10_compile/02_how-to-configure-cmake.md b/docs/06_how-to-guides/10_compile/02_how-to-configure-cmake.md index 22549b473c..12b68f0ebb 100644 --- a/docs/06_how-to-guides/10_compile/02_how-to-configure-cmake.md +++ b/docs/06_how-to-guides/10_compile/02_how-to-configure-cmake.md @@ -2,53 +2,77 @@ content_title: How to configure CMake --- -## CMake Configuration +## Overview + +This how-to guide provides instructions how to configure CMake. + +## Before you begin + +* You have installed CMake, for detailed instructions consult the official [CMake installation page](https://CMake.org/install/). + +## Procedure + +The following steps show: + +* [Automatic generation of CMake configuration](#automatic-generation-of-CMake-configuration) +* [Manual generation of CMake configuration](#manual-generation-of-CMake-configuration) ### Automatic generation of CMake configuration -To compile an EOSIO smart contract with CMake, you'll need a CMake file. To use the new `eosio-init` tool to generate the directory structure stub .hpp/.cpp files and the cmake configuration files follow these steps: +To compile an EOSIO smart contract with CMake, you'll need a CMake file. To use the new `eosio-init` tool to generate the directory structure stub `.hpp/.cpp` files and the CMake configuration files follow these steps: -1. cd ~ -2. eosio-init --path=. --project=test_contract -3. cd test_contract -4. cd build -5. cmake .. -6. make -7. ls -al test_contract + ```sh + cd ~ + eosio-init --path=. --project=test_contract + cd test_contract + cd build + cmake .. + make + ls -al test_contract + ``` At this point, you'll have the `test_contract.abi` and `test_contract.wasm` files in `~/test_contract/test_contract`. These files are ready to be deployed. ### Manual generation of CMake configuration -To create manually the cmake configuration, the template `CMakeLists.txt` in the examples folder is a good boilerplate for manual usage. +To create manually the CMake configuration, the template `CMakeLists.txt` in the examples folder is a good boilerplate for manual usage. 1. In `CMakeLists.txt`: -``` -cmake_minimum_required(VERSION 3.5) -project(test_example VERSION 1.0.0) -find_package(eosio.cdt) + ```sh + cmake_minimum_required(VERSION 3.5) + project(test_example VERSION 1.0.0) + + find_package(eosio.cdt) -add_contract( test test test.cpp ) -``` + add_contract( test test test.cpp ) + ``` 2. In `test.cpp`: -``` -#include -using namespace eosio; -class [[eosio::contract]] test : public eosio::contract { -public: - using contract::contract; + ```c++ + #include + using namespace eosio; - [[eosio::action]] void testact( name test ) { - } -}; + class [[eosio::contract]] test : public eosio::contract { + public: + using contract::contract; -EOSIO_DISPATCH( test, (testact) ) -``` + [[eosio::action]] void testact( name test ) { + } + }; + + EOSIO_DISPATCH( test, (testact) ) + ``` 3. The following CMake macros are provided: -- `add_contract` is used to build your smart contract and generate an ABI. The first parameter is the contract name, the second is the cmake target name, and the rest are the CPP files needed to build the contract. -- `target_ricardian_directory` can be used to add the directory where your ricardian contracts live to a specific cmake target. -- `add_native_library` and `add_native_executable` are CMake macros for the native tester. They are drop in replacements for `add_library` and `add_executable`. + +* `add_contract` is used to build your smart contract and generate an ABI. The first parameter is the contract name, the second is the CMake target name, and the rest are the CPP files needed to build the contract. + +* `target_ricardian_directory` can be used to add the directory where your ricardian contracts live to a specific CMake target. + +* `add_native_library` and `add_native_executable` are CMake macros for the native tester. They are drop in replacements for `add_library` and `add_executable`. + +## Summary + +In conclusion, the above instructions show how to configure CMake . diff --git a/docs/06_how-to-guides/10_compile/03_compiling-contracts-with-cmake.md b/docs/06_how-to-guides/10_compile/03_compiling-contracts-with-cmake.md index 54bd0814d6..eb0314f097 100644 --- a/docs/06_how-to-guides/10_compile/03_compiling-contracts-with-cmake.md +++ b/docs/06_how-to-guides/10_compile/03_compiling-contracts-with-cmake.md @@ -2,20 +2,34 @@ content_title: How to compile a smart contract with CMake --- -## Preconditions -- You have the source of your contract saved in one of your local folders, e.g. `./examples/hello` -For details on how to create your first contract follow [this tutorial here](https://developers.eos.io/eosio-home/docs/your-first-contract) +## Overview -Follow these steps to compile your contract: +This how-to guide provides instructions on how to compile a smart contract with CMake. + +## Before you begin + +* You have the source of the contract saved in a local folder, e.g. `./examples/hello/` +For details on how to create your first contract follow the [Hello World Contract](https://developers.eos.io/welcome/latest/smart-contract-guides/hello-world) guide. + +## Procedure + +Follow the following steps to compile your contract. 1. Navigate to the hello folder in examples (./examples/hello), you should then see the ./src/hello.cpp file 2. Run following commands: -```sh -$ mkdir build -$ cd build -$ cmake .. -$ make -``` -3. This will generate two files: -- The compiled binary wasm, hello.wasm -- The generated ABI file, hello.abi + + ```sh + mkdir build + cd build + cmake .. + make + ``` + +3. Verify the following two files were generated: + +* the compiled binary wasm: `hello.wasm`, +* and the generated ABI file: `hello.abi`. + +## Summary + +In conclusion, the above instructions show how to compile a smart contract with CMake. diff --git a/docs/06_how-to-guides/20_authorization/how_to_restrict_access_to_an_action_by_user.md b/docs/06_how-to-guides/20_authorization/how_to_restrict_access_to_an_action_by_user.md index d439981846..0305eb7f4b 100644 --- a/docs/06_how-to-guides/20_authorization/how_to_restrict_access_to_an_action_by_user.md +++ b/docs/06_how-to-guides/20_authorization/how_to_restrict_access_to_an_action_by_user.md @@ -3,22 +3,35 @@ content_title: How To Perform Authorization Checks link_text: How To Perform Authorization Checks --- -## Preconditions +## Overview -The following conditions are assumed: +This how-to guide provides instructions how to perform authorization checks in a smart contract. -1. You have the sources of a contract with `hi` action defined. +## Before you begin + +1. You have the sources of a contract with a `hi` action defined and implemented. 2. The `hi` action has defined one input parameter `user` of type `name`. -3. The `hi` action prints the name of the `user` account. -4. The `hi` action needs to authorize the `user` account. -## Authorization Methods +## Code Reference -To restrict access to the `hi` action, you can do it in three ways. +See the following code reference guides for functions which can be used to implement authorization checks in a smart contract: -### 1. Use eosio::check(eosio::has_auth(...)...) +* function [has_auth(name n)](https://developers.eos.io/manuals/eosio.cdt/latest/namespaceeosio#function-has_auth) +* function [require_auth(name n)](https://developers.eos.io/manuals/eosio.cdt/latest/namespaceeosio/#function-require_auth-12) +* function [require_auth2(capi_name name, capi_name permission)](https://developers.eos.io/manuals/eosio.cdt/v1.8/group__action__c#function-require_auth2) +* function [check(bool pred, ...)](https://developers.eos.io/manuals/eosio.cdt/latest/group__system/#function-check) -The below code enforces the action `hi` to be executed only by the account that is sent as parameter to the action, no matter what permission the account uses to sign the transaction (e.g. owner, active, code). +## Procedure + +The following steps show how to check authorization for `user` account for the `hi` action. There are three ways to accomplish an authorization check in a smart contract action implementation. You can use any of the methods provided below depending on your needs: + +* [Use check(...) in combination with has_auth(...)](#1-use-checkhas_auth) +* [Use require_auth(...)](#2-use-require_auth) +* [Use require_auth2(...)](#3-use-require_auth2) + +### 1. Use check(has_auth(...)...) + +The following code example enforces the action `hi` to be executed only by the account that is sent as parameter to the action, no matter what permission the account uses to sign the transaction (e.g. owner, active, code). [[info | Error message is custom]] | Observe that in this case the yielded error message is a custom one and thus it can be used to provide a better experience for the user. From 988fec947ef015499f385bfe9e915021052ac1a5 Mon Sep 17 00:00:00 2001 From: iamveritas Date: Fri, 2 Apr 2021 12:15:50 +0300 Subject: [PATCH 2/9] add the forgotten summary section --- .../how_to_restrict_access_to_an_action_by_user.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/06_how-to-guides/20_authorization/how_to_restrict_access_to_an_action_by_user.md b/docs/06_how-to-guides/20_authorization/how_to_restrict_access_to_an_action_by_user.md index 0305eb7f4b..9a171ee1fd 100644 --- a/docs/06_how-to-guides/20_authorization/how_to_restrict_access_to_an_action_by_user.md +++ b/docs/06_how-to-guides/20_authorization/how_to_restrict_access_to_an_action_by_user.md @@ -76,3 +76,7 @@ void hi( name user ) { [[info | Error message is not custom]] | Note that this time, as well as previous method, you can not customize the yielded error message, it will be a generic authorization error message. + +## Summary + +In conclusion, the above instructions show how to how to perform authorization checks in a smart contract. From b5e2872bdd0c784547b7301342ec25c4f07f787a Mon Sep 17 00:00:00 2001 From: iamveritas Date: Fri, 2 Apr 2021 13:07:05 +0300 Subject: [PATCH 3/9] updates -- take 3 --- .../kv_map/10_how-to-use-kv-map.md | 20 ++++++++++++------- .../kv_map/30_how-to-upsert-into-kv-map.md | 18 ++++++++++------- .../kv_map/40_how-to-delete-from-kv-map.md | 18 ++++++++++------- .../kv_map/50_how-to-iterate-kv-map.md | 18 ++++++++++------- .../kv_map/70_how-to-find-in-kv-map.md | 18 +++++++++++------ .../90_how-to-allow-users-to-pay-kv-map.md | 14 ++++++++----- .../kv_table/10_how-to-use-kv-table.md | 10 +++++----- .../20_how-to-create-indexes-kv-table.md | 14 ++++++------- .../30_how-to-upsert-into-kv-table.md | 12 +++++------ .../40_how-to-delete-from-kv-table.md | 14 ++++++------- .../kv_table/50_how-to-iterate-kv-table.md | 14 ++++++------- .../60_how-to-check-a-record-kv-table.md | 14 ++++++------- .../kv_table/70_how-to-find-in-kv-table.md | 14 ++++++------- .../80_how-to-query-range-in-kv-table.md | 14 ++++++------- .../90_how-to-allow-users-to-pay-kv-table.md | 12 +++++------ .../60_how-to-return-values-from-actions.md | 2 +- 16 files changed, 127 insertions(+), 99 deletions(-) diff --git a/docs/06_how-to-guides/30_key-value-api/kv_map/10_how-to-use-kv-map.md b/docs/06_how-to-guides/30_key-value-api/kv_map/10_how-to-use-kv-map.md index ad792f4b5a..d3c93175f8 100644 --- a/docs/06_how-to-guides/30_key-value-api/kv_map/10_how-to-use-kv-map.md +++ b/docs/06_how-to-guides/30_key-value-api/kv_map/10_how-to-use-kv-map.md @@ -3,19 +3,21 @@ content_title: How-To Use Key-Value Map link_text: "How-To Use Key-Value Map" --- -## Summary +## Overview -This how-to procedure demonstrates how to define and use a `Key-Value Map` (`kv map`) in your smart contract. +This how-to demonstrates how to define and use a `Key-Value Map` (`kv map`) in a smart contract. To accomplish this task use `eosio::kv::map` template class, specify the name for the map object instantiated, the type of the key, and the type for the values stored for each key. The types used for the key and the values can be any standard type, or a user defined type. -## Prerequisites +## Before you begin + +Complete the following prerequisites: -* The EOSIO development environment, for details consult the [Get Started](https://developers.eos.io/welcome/latest/getting-started/development-environment/introduction) Guide. -* A smart contract named `smrtcontract`. -* A user defined type named `person`, which defines the data stored in the map. +* An EOSIO development environment, for details consult the [Get Started Guide](https://developers.eos.io/welcome/latest/getting-started-guide/index) +* A smart contract named `smrtcontract` +* A user defined type named `person`, which defines the data stored in the map -Refer to the following possible implementation of your starting point. +Refer to the following possible implementation for your starting point. `smartcontract.hpp file` @@ -63,6 +65,10 @@ class [[eosio::contract]] smartcontract : public eosio::contract { }; ``` +## Summary + +In conclusion, the above instructions show how to define and use a `Key-Value Map` (`kv map`) in a smart contract. + ## Next Steps The following option is available when you complete the procedure: diff --git a/docs/06_how-to-guides/30_key-value-api/kv_map/30_how-to-upsert-into-kv-map.md b/docs/06_how-to-guides/30_key-value-api/kv_map/30_how-to-upsert-into-kv-map.md index 1c2f680917..cbb4eee55e 100644 --- a/docs/06_how-to-guides/30_key-value-api/kv_map/30_how-to-upsert-into-kv-map.md +++ b/docs/06_how-to-guides/30_key-value-api/kv_map/30_how-to-upsert-into-kv-map.md @@ -3,20 +3,20 @@ content_title: How-To Upsert Into Key-Value Map link_text: "How-To Upsert Into Key-Value Map" --- -## Summary +## Overview -This how-to procedure provides instructions to upsert into `Key-Value Map` (`kv map`). Upsert means insert when the item doesn't already exist, and update the item if it already exists in the map. +This how-to provides instructions to upsert into `Key-Value Map` (`kv map`). Upsert means insert when the item doesn't already exist, and update the item if it already exists in the map. -## Prerequisites +## Before you begin -Before you begin, complete the following prerequisites: +Complete the following prerequisites: -* An EOSIO development environment, for details consult the [Get Started](https://developers.eos.io/welcome/latest/getting-started/development-environment/introduction) Guide +* Install EOSIO development environment, for details consult the [Get Started Guide](https://developers.eos.io/welcome/latest/getting-started-guide/index) * A smart contract named `smrtcontract` * A user defined type named `person`, which defines the data stored in the map -* A `kv map` object, name `my_map`, which stores objects of type `person`, with unique keys of type `int`. +* A `kv map` object, name `my_map`, which stores objects of type `person`, with unique keys of type `int` -Refer to the following possible implementation of your starting point. +Refer to the following possible implementation for your starting point. `smartcontract.hpp file` @@ -105,6 +105,10 @@ void smartcontract::upsert( } ``` +## Summary + +In conclusion, the above instructions show how to upsert into `Key-Value Map` (`kv map`). + ## Next Steps The following options are available when you complete the procedure: diff --git a/docs/06_how-to-guides/30_key-value-api/kv_map/40_how-to-delete-from-kv-map.md b/docs/06_how-to-guides/30_key-value-api/kv_map/40_how-to-delete-from-kv-map.md index f472e63b2e..433fdf7bf1 100644 --- a/docs/06_how-to-guides/30_key-value-api/kv_map/40_how-to-delete-from-kv-map.md +++ b/docs/06_how-to-guides/30_key-value-api/kv_map/40_how-to-delete-from-kv-map.md @@ -3,20 +3,20 @@ content_title: How-To Delete from Key-Value Map link_text: "How-To Delete from Key-Value Map" --- -## Summary +## Overview -This how-to procedure provides instructions to delete from `Key-Value Map` (`kv map`) based on the unique key. +This how-to provides instructions to delete from `Key-Value Map` (`kv map`) based on the unique key. -## Prerequisites +## Before you begin -Before you begin, complete the following prerequisites: +Complete the following prerequisites: -* An EOSIO development environment, for details consult the [Get Started](https://developers.eos.io/welcome/latest/getting-started/development-environment/introduction) Guide +* An EOSIO development environment, for details consult the [Get Started Guide](https://developers.eos.io/welcome/latest/getting-started-guide/index) * A smart contract named `smrtcontract` * A user defined type named `person`, which defines the data stored in the map -* A `kv map` object, name `my_map`, which stores objects of type `person`, with unique keys of type `int`. +* A `kv map` object, name `my_map`, which stores objects of type `person`, with unique keys of type `int` -Refer to the following possible implementation of your starting point. +Refer to the following possible implementation for your starting point. `smartcontract.hpp file` @@ -104,3 +104,7 @@ void kv_map::delete(int id) { } } ``` + +## Summary + +In conclusion, the above instructions show how to delete from `Key-Value Map` (`kv map`) based on the unique key. diff --git a/docs/06_how-to-guides/30_key-value-api/kv_map/50_how-to-iterate-kv-map.md b/docs/06_how-to-guides/30_key-value-api/kv_map/50_how-to-iterate-kv-map.md index 14028e56b8..296a2ea14c 100644 --- a/docs/06_how-to-guides/30_key-value-api/kv_map/50_how-to-iterate-kv-map.md +++ b/docs/06_how-to-guides/30_key-value-api/kv_map/50_how-to-iterate-kv-map.md @@ -3,20 +3,20 @@ content_title: How-To Iterate Through Key-Value Map link_text: "How-To Iterate Through Key-Value Map" --- -## Summary +## Overview -This how-to procedure provides instructions to iterate through a `Key-Value Map` (`kv map`) and read values from it. +This how-to provides instructions to iterate through a `Key-Value Map` (`kv map`) and read values from it. -## Prerequisites +## Before you begin -Before you begin, complete the following prerequisites: +Complete the following prerequisites: -* An EOSIO development environment, for details consult the [Get Started](https://developers.eos.io/welcome/latest/getting-started/development-environment/introduction) Guide +* An EOSIO development environment, for details consult the [Get Started Guide](https://developers.eos.io/welcome/latest/getting-started-guide/index) * A smart contract named `smrtcontract` * A user defined type named `person`, which defines the data stored in the map * A `kv map` object, name `my_map`, which stores objects of type `person`, with unique keys of type `int`. -Refer to the following possible implementation of your starting point. +Refer to the following possible implementation for your starting point. `smartcontract.hpp file` @@ -41,7 +41,7 @@ class [[eosio::contract]] smartcontract : public eosio::contract { }; ``` -## Procedures +## Procedure Complete the following steps to implement an action that is iterating through the first N `person` objects in `kv map` and prints their first and last names: @@ -100,3 +100,7 @@ void kv_map::iterate(int iterations_count) { } } }``` + +## Summary + +In conclusion, the above instructions show how to iterate through a `Key-Value Map` (`kv map`) and read values from it. \ No newline at end of file diff --git a/docs/06_how-to-guides/30_key-value-api/kv_map/70_how-to-find-in-kv-map.md b/docs/06_how-to-guides/30_key-value-api/kv_map/70_how-to-find-in-kv-map.md index 5caabe27fd..32370d83ba 100644 --- a/docs/06_how-to-guides/30_key-value-api/kv_map/70_how-to-find-in-kv-map.md +++ b/docs/06_how-to-guides/30_key-value-api/kv_map/70_how-to-find-in-kv-map.md @@ -3,20 +3,20 @@ content_title: How-To Find in Key-Value Map link_text: "How-To Find in Key-Value Map" --- -## Summary +## Overview -This how-to procedure provides instructions to find an object in `Key-Value Map` (`kv map`) based on the unique key. +This how-to provides instructions to find an object in `Key-Value Map` (`kv map`) based on the unique key. -## Prerequisites +## Before you begin -Before you begin, complete the following prerequisites: +Complete the following prerequisites: -* An EOSIO development environment, for details consult the [Get Started](https://developers.eos.io/welcome/latest/getting-started/development-environment/introduction) Guide +* An EOSIO development environment, for details consult the [Get Started Guide](https://developers.eos.io/welcome/latest/getting-started-guide/index) * A smart contract named `smrtcontract` * A user defined type named `person`, which defines the data stored in the map * A `kv map` object, name `my_map`, which stores objects of type `person`, with unique keys of type `int`. -Refer to the following possible implementation of your starting point. +Refer to the following possible implementation for your starting point. `smartcontract.hpp file` @@ -100,6 +100,12 @@ void kv_map::find(int id) { } ``` +## Summary + +In conclusion, the above instructions show how to find an object in `Key-Value Map` (`kv map`) based on the unique key. + +## Next Steps + The following options are available when you complete the procedure: * [Update](30_how-to-upsert-into-kv-map.md) the `person` found. diff --git a/docs/06_how-to-guides/30_key-value-api/kv_map/90_how-to-allow-users-to-pay-kv-map.md b/docs/06_how-to-guides/30_key-value-api/kv_map/90_how-to-allow-users-to-pay-kv-map.md index 6e687611c0..ec6ef01cdf 100644 --- a/docs/06_how-to-guides/30_key-value-api/kv_map/90_how-to-allow-users-to-pay-kv-map.md +++ b/docs/06_how-to-guides/30_key-value-api/kv_map/90_how-to-allow-users-to-pay-kv-map.md @@ -3,18 +3,18 @@ content_title: How-To Allow Users to Pay for Key-Value Map Resources link_text: "How-To Allow Users to Pay for Key-Value Map Resources" --- -## Summary +## Overview -This how-to procedure provides instructions to allow users to pay for the resources needed to store data in a `Key-Value Map` (`kv map`). +This how-to provides instructions to allow users to pay for the resources needed to store data in a `Key-Value Map` (`kv map`). -Before you begin, complete the following prerequisites: +Complete the following prerequisites: -* An EOSIO development environment, for details consult the [Get Started](https://developers.eos.io/welcome/latest/getting-started/development-environment/introduction) Guide +* An EOSIO development environment, for details consult the [Get Started Guide](https://developers.eos.io/welcome/latest/getting-started-guide/index) * A smart contract named `smrtcontract` * A user defined type named `person`, which defines the data stored in the map * A `kv map` object, name `my_map`, which stores objects of type `person`, with unique keys of type `int`. -Refer to the following possible implementation of your starting point. +Refer to the following possible implementation for your starting point. `smartcontract.hpp file` @@ -102,6 +102,10 @@ void smartcontract::upsert( } ``` +## Summary + +In conclusion, the above instructions show how to allow users to pay for the resources needed to store data in a `Key-Value Map` (`kv map`). + ## Next Steps The following options are available when you complete the procedure: diff --git a/docs/06_how-to-guides/30_key-value-api/kv_table/10_how-to-use-kv-table.md b/docs/06_how-to-guides/30_key-value-api/kv_table/10_how-to-use-kv-table.md index 9aab1dadec..c87c35d734 100644 --- a/docs/06_how-to-guides/30_key-value-api/kv_table/10_how-to-use-kv-table.md +++ b/docs/06_how-to-guides/30_key-value-api/kv_table/10_how-to-use-kv-table.md @@ -3,22 +3,22 @@ content_title: How-To Use Key-Value Table link_text: "How-To Use Key-Value Table" --- -## Summary +## Overview -This how-to procedure demonstrates how to define and use a `Key-Value Table` (`kv table`) in your smart contract. +This how-to demonstrates how to define and use a `Key-Value Table` (`kv table`) in a smart contract. To accomplish this task, define the user type which will be stored in the `kv table`, and extend the `eosio::kv::table` template class with a specialized definition based on the user defined type. [[caution | Alpha version]] | `Key-Value Table` is designated as `alpha` and should not be used in production code. -## Prerequisites +## Before you begin -* The EOSIO development environment, for details consult the [Get Started](https://developers.eos.io/welcome/latest/getting-started/development-environment/introduction) Guide. +* The EOSIO development environment, for details consult the [Get Started Guide](https://developers.eos.io/welcome/latest/getting-started-guide/index). * A smart contract named `smrtcontract`. * A user defined type named `person`, which defines the data stored in the table. -Refer to the following possible implementation of your starting point. +Refer to the following possible implementation for your starting point. `smartcontract.hpp file` diff --git a/docs/06_how-to-guides/30_key-value-api/kv_table/20_how-to-create-indexes-kv-table.md b/docs/06_how-to-guides/30_key-value-api/kv_table/20_how-to-create-indexes-kv-table.md index 09852875e1..3a1e301101 100644 --- a/docs/06_how-to-guides/30_key-value-api/kv_table/20_how-to-create-indexes-kv-table.md +++ b/docs/06_how-to-guides/30_key-value-api/kv_table/20_how-to-create-indexes-kv-table.md @@ -3,9 +3,9 @@ content_title: How-To Create Indexes on a Key-Value Table link_text: "How-To Create Indexes on a Key-Value Table" --- -## Summary +## Overview -This how-to procedure provides instructions to create the following indexes on a `Key-Value Table` (`kv table`): +This how-to provides instructions to create the following indexes on a `Key-Value Table` (`kv table`): * A unique index using the macro `KV_NAMED_INDEX` * A unique index using the `eosio::kv::table::index` template class @@ -17,11 +17,11 @@ The `KV_NAMED_INDEX` macro and the `eosio::kv::table::index` template class are [[caution | Alpha version]] | `Key-Value Table` is designated as `alpha` and should not be used in production code. -## Prerequisites +## Before you begin -Before you begin, complete the following prerequisites: +Complete the following prerequisites: -* An EOSIO development environment, for details consult the [Get Started](https://developers.eos.io/welcome/latest/getting-started/development-environment/introduction) Guide +* An EOSIO development environment, for details consult the [Get Started Guide](https://developers.eos.io/welcome/latest/getting-started-guide/index) * A smart contract named `smrtcontract` * A user defined type which defines the data stored in the table, named `person` * A `kv table` type which stores objects of type `person`, named `address_table` @@ -31,7 +31,7 @@ Before you begin, complete the following prerequisites: * `last_name`, * `personal_id`. -Refer to the following possible implementation of your starting point. +Refer to the following possible implementation for your starting point. `smartcontract.hpp file` @@ -52,7 +52,7 @@ class [[eosio::contract]] smrtcontract : public contract { }; ``` -## Procedures +## Procedure ### Define a unique index on property account_name using the macro KV_NAMED_INDEX diff --git a/docs/06_how-to-guides/30_key-value-api/kv_table/30_how-to-upsert-into-kv-table.md b/docs/06_how-to-guides/30_key-value-api/kv_table/30_how-to-upsert-into-kv-table.md index 73612a99d4..e57f51c009 100644 --- a/docs/06_how-to-guides/30_key-value-api/kv_table/30_how-to-upsert-into-kv-table.md +++ b/docs/06_how-to-guides/30_key-value-api/kv_table/30_how-to-upsert-into-kv-table.md @@ -3,25 +3,25 @@ content_title: How-To Upsert Into Key-Value Table link_text: "How-To Upsert Into Key-Value Table" --- -## Summary +## Overview -This how-to procedure provides instructions to upsert into `Key-Value Table` (`kv table`). +This how-to provides instructions to upsert into `Key-Value Table` (`kv table`). [[caution | Alpha version]] | `Key-Value Table` is designated as `alpha` and should not be used in production code. Use the method `put` defined by the `eosio::kv::table` type to accomplish this task. -## Prerequisites +## Before you begin -Before you begin, complete the following prerequisites: +Complete the following prerequisites: -* An EOSIO development environment, for details consult the [Get Started](https://developers.eos.io/welcome/latest/getting-started/development-environment/introduction) Guide +* An EOSIO development environment, for details consult the [Get Started Guide](https://developers.eos.io/welcome/latest/getting-started-guide/index) * A smart contract named `smrtcontract` * A user defined type named `person`, which defines the data stored in the table * A `kv table` type which stores objects of type `person`, named `address_table`. The primary index of the `kv table` is defined based on the `person::account_name` property. -Refer to the following possible implementation of your starting point. +Refer to the following possible implementation for your starting point. `smartcontract.hpp file` diff --git a/docs/06_how-to-guides/30_key-value-api/kv_table/40_how-to-delete-from-kv-table.md b/docs/06_how-to-guides/30_key-value-api/kv_table/40_how-to-delete-from-kv-table.md index dc97f8a876..307e5f79db 100644 --- a/docs/06_how-to-guides/30_key-value-api/kv_table/40_how-to-delete-from-kv-table.md +++ b/docs/06_how-to-guides/30_key-value-api/kv_table/40_how-to-delete-from-kv-table.md @@ -3,25 +3,25 @@ content_title: How-To Delete from Key-Value Table link_text: "How-To Delete from Key-Value Table" --- -## Summary +## Overview -This how-to procedure provides instructions to delete an object from a `Key-Value Table` (`kv table`). +This how-to provides instructions to delete an object from a `Key-Value Table` (`kv table`). [[caution | Alpha version]] | `Key-Value Table` is designated as `alpha` and should not be used in production code. Use the method `erase` defined by the `eosio::kv::table` type to accomplish this task. -## Prerequisites +## Before you begin -Before you begin, complete the following prerequisites: +Complete the following prerequisites: -* An EOSIO development environment, for details consult the [Get Started](https://developers.eos.io/welcome/latest/getting-started/development-environment/introduction) Guide +* An EOSIO development environment, for details consult the [Get Started Guide](https://developers.eos.io/welcome/latest/getting-started-guide/index) * A smart contract named `smrtcontract` * A user defined type named `person`, which defines the data stored in the table * A `kv table` type which stores objects of type `person`, named `address_table`. The primary index of the `kv table` is defined based on the `person::account_name` property. -Refer to the following possible implementation of your starting point. +Refer to the following possible implementation for your starting point. `smartcontract.hpp file` @@ -53,7 +53,7 @@ class [[eosio::contract]] smrtcontract : public contract { Complete the following steps to delete a `person` object from `address_table`: -1. Create a new action `delete`, in your smart contract class, which takes as input parameters an account name, a first name, a last name and a personal id. +1. Create a new action `delete`, in a smart contract class, which takes as input parameters an account name, a first name, a last name and a personal id. 2. In the `delete` action access the instance of `address_table` by declaring a local variable of `address_table` type. 3. Call the `erase` method of the `address_table` and pass to it the primary key for the object which is deleted. If you try to erase an object which is not present in the `kv table` no error will be raised. diff --git a/docs/06_how-to-guides/30_key-value-api/kv_table/50_how-to-iterate-kv-table.md b/docs/06_how-to-guides/30_key-value-api/kv_table/50_how-to-iterate-kv-table.md index c815d3693c..5064068468 100644 --- a/docs/06_how-to-guides/30_key-value-api/kv_table/50_how-to-iterate-kv-table.md +++ b/docs/06_how-to-guides/30_key-value-api/kv_table/50_how-to-iterate-kv-table.md @@ -3,20 +3,20 @@ content_title: How-To Iterate Through Key-Value Table link_text: "How-To Iterate Through Key-Value Table" --- -## Summary +## Overview -This how-to procedure provides instructions to iterate through a `Key-Value Table` (`kv table`) and read values from it. +This how-to provides instructions to iterate through a `Key-Value Table` (`kv table`) and read values from it. [[caution | Alpha version]] | `Key-Value Table` is designated as `alpha` and should not be used in production code. Use the `iterator` defined by the `eosio::kv::table::index` class to accomplish this task. -## Prerequisites +## Before you begin -Before you begin, complete the following prerequisites: +Complete the following prerequisites: -* An EOSIO development environment, for details consult the [Get Started](https://developers.eos.io/welcome/latest/getting-started/development-environment/introduction) Guide. +* An EOSIO development environment, for details consult the [Get Started Guide](https://developers.eos.io/welcome/latest/getting-started-guide/index). * A smart contract named `smrtcontract`. * A user defined type which defines the data stored in the table, named `person`. * A `kv table` type which stores objects of type `person`, named `address_table`. @@ -27,7 +27,7 @@ Before you begin, complete the following prerequisites: * `personal_id`. * A unique index, named `account_name_uidx`, defined on the `account_name` property.. -Refer to the following possible implementation of your starting point. +Refer to the following possible implementation for your starting point. `smartcontract.hpp file` @@ -55,7 +55,7 @@ class [[eosio::contract]] smrtcontract : public contract { }; ``` -## Procedures +## Procedure Complete the following steps to implement an action that is iterating through the first N `person` objects in `address_table` and prints their first and last names: diff --git a/docs/06_how-to-guides/30_key-value-api/kv_table/60_how-to-check-a-record-kv-table.md b/docs/06_how-to-guides/30_key-value-api/kv_table/60_how-to-check-a-record-kv-table.md index 2bf88337bf..32a7c78347 100644 --- a/docs/06_how-to-guides/30_key-value-api/kv_table/60_how-to-check-a-record-kv-table.md +++ b/docs/06_how-to-guides/30_key-value-api/kv_table/60_how-to-check-a-record-kv-table.md @@ -3,20 +3,20 @@ content_title: How-To Check a Record in a Key-Value Table link_text: "How-To Check a Record in a Key-Value Table" --- -## Summary +## Overview -This how-to procedure provides instructions to check if a specific object exists in a `Key-Value Table` (`kv table`). +This how-to provides instructions to check if a specific object exists in a `Key-Value Table` (`kv table`). [[caution | Alpha version]] | `Key-Value Table` is designated as `alpha` and should not be used in production code. Use the method `exists` defined by the `eosio::kv::table::index` class to accomplish this task. -## Prerequisites +## Before you begin -Before you begin, complete the following prerequisites: +Complete the following prerequisites: -* An EOSIO development environment, for details consult the [Get Started](https://developers.eos.io/welcome/latest/getting-started/development-environment/introduction) Guide. +* An EOSIO development environment, for details consult the [Get Started Guide](https://developers.eos.io/welcome/latest/getting-started-guide/index). * A smart contract named `smrtcontract`. * A user defined type which defines the data stored in the table, named `person`. * A `kv table` type which stores objects of type `person`, named `address_table`. @@ -27,7 +27,7 @@ Before you begin, complete the following prerequisites: * `personal_id`. * A unique index, named `account_name_uidx`, defined on the `account_name` property.. -Refer to the following possible implementation of your starting point. +Refer to the following possible implementation for your starting point. `smartcontract.hpp file` @@ -55,7 +55,7 @@ class [[eosio::contract]] smrtcontract : public contract { }; ``` -## Procedures +## Procedure Complete the following steps to implement an action that is verifying whether a particular `person` identified by its `account_name` exists in the `address_table`: diff --git a/docs/06_how-to-guides/30_key-value-api/kv_table/70_how-to-find-in-kv-table.md b/docs/06_how-to-guides/30_key-value-api/kv_table/70_how-to-find-in-kv-table.md index 479f98f65a..4268a8aeb3 100644 --- a/docs/06_how-to-guides/30_key-value-api/kv_table/70_how-to-find-in-kv-table.md +++ b/docs/06_how-to-guides/30_key-value-api/kv_table/70_how-to-find-in-kv-table.md @@ -3,20 +3,20 @@ content_title: How-To Find in Key-Value Table link_text: "How-To Find in Key-Value Table" --- -## Summary +## Overview -This how-to procedure provides instructions to find a specific object in a `Key-Value Table` (`kv table`). +This how-to provides instructions to find a specific object in a `Key-Value Table` (`kv table`). [[caution | Alpha version]] | `Key-Value Table` is designated as `alpha` and should not be used in production code. Use the method `find()` defined by the `eosio::kv::table::index` class to accomplish this task. -## Prerequisites +## Before you begin -Before you begin, complete the following prerequisites: +Complete the following prerequisites: -* An EOSIO development environment, for details consult the [Get Started](https://developers.eos.io/welcome/latest/getting-started/development-environment/introduction) Guide. +* An EOSIO development environment, for details consult the [Get Started Guide](https://developers.eos.io/welcome/latest/getting-started-guide/index). * A smart contract named `smrtcontract`. * A user defined type which defines the data stored in the table, named `person`. * A `kv table` type which stores objects of type `person`, named `address_table`. @@ -27,7 +27,7 @@ Before you begin, complete the following prerequisites: * `personal_id`. * A unique index, named `account_name_uidx`, defined on the `account_name` property.. -Refer to the following possible implementation of your starting point. +Refer to the following possible implementation for your starting point. `smartcontract.hpp file` @@ -55,7 +55,7 @@ class [[eosio::contract]] smrtcontract : public contract { }; ``` -## Procedures +## Procedure Complete the following steps to implement an action to find a particular `person` identified by the `account_name` in the `address_table` and returns the person back to the caller: diff --git a/docs/06_how-to-guides/30_key-value-api/kv_table/80_how-to-query-range-in-kv-table.md b/docs/06_how-to-guides/30_key-value-api/kv_table/80_how-to-query-range-in-kv-table.md index b348a441ca..b461fc101a 100644 --- a/docs/06_how-to-guides/30_key-value-api/kv_table/80_how-to-query-range-in-kv-table.md +++ b/docs/06_how-to-guides/30_key-value-api/kv_table/80_how-to-query-range-in-kv-table.md @@ -3,20 +3,20 @@ content_title: How-To Query Range in Key-Value Table link_text: "How-To Query Range in Key-Value Table" --- -## Summary +## Overview -This how-to procedure provides instructions to retrieve a list of values, from a `Key-Value Table` (`kv table`) index, which share a particular commonality. +This how-to provides instructions to retrieve a list of values, from a `Key-Value Table` (`kv table`) index, which share a particular commonality. [[caution | Alpha version]] | `Key-Value Table` is designated as `alpha` and should not be used in production code. Use the method `range` defined by the `eosio::kv::table::index` class to accomplish this task. -## Prerequisites +## Before you begin -Before you begin, complete the following prerequisites: +Complete the following prerequisites: -* An EOSIO development environment, for details consult the [Get Started](https://developers.eos.io/welcome/latest/getting-started/development-environment/introduction) Guide. +* An EOSIO development environment, for details consult the [Get Started Guide](https://developers.eos.io/welcome/latest/getting-started-guide/index). * A smart contract named `smrtcontract`. * A user defined type which defines the data stored in the table, named `person`. * A `kv table` type which stores objects of type `person`, named `address_table`. @@ -28,7 +28,7 @@ Before you begin, complete the following prerequisites: * A unique index, named `account_name_uidx`, defined on the `account_name` property.. * A non-unique index defined on the `last_name` property, named `last_name_idx`. -Refer to the following possible implementation of your starting point. +Refer to the following possible implementation for your starting point. `smartcontract.hpp file` @@ -60,7 +60,7 @@ class [[eosio::contract]] smrtcontract : public contract { }; ``` -## Procedures +## Procedure Complete the following steps to implement an action to retrieve a list of persons with the same name from `address_table` and return it back to the caller: diff --git a/docs/06_how-to-guides/30_key-value-api/kv_table/90_how-to-allow-users-to-pay-kv-table.md b/docs/06_how-to-guides/30_key-value-api/kv_table/90_how-to-allow-users-to-pay-kv-table.md index df7cb936a3..f101221769 100644 --- a/docs/06_how-to-guides/30_key-value-api/kv_table/90_how-to-allow-users-to-pay-kv-table.md +++ b/docs/06_how-to-guides/30_key-value-api/kv_table/90_how-to-allow-users-to-pay-kv-table.md @@ -3,25 +3,25 @@ content_title: How-To Allow Users to Pay for Key-Value Table Resources link_text: "How-To Allow Users to Pay for Key-Value Table Resources" --- -## Summary +## Overview -This how-to procedure provides instructions to allow users to pay for the resources needed to store data in a `Key-Value Table` (`kv table`). +This how-to provides instructions to allow users to pay for the resources needed to store data in a `Key-Value Table` (`kv table`). [[caution | Alpha version]] | `Key-Value Table` is designated as `alpha` and should not be used in production code. Use the method `put` defined by the `eosio::kv::table` type to accomplish this task and provide as the second parameter the account name which is the payer for the resources needed. -## Prerequisites +## Before you begin -Before you begin, complete the following prerequisites: +Complete the following prerequisites: -* An EOSIO development environment, for details consult the [Get Started](https://developers.eos.io/welcome/latest/getting-started/development-environment/introduction) Guide +* An EOSIO development environment, for details consult the [Get Started Guide](https://developers.eos.io/welcome/latest/getting-started-guide/index) * A smart contract named `smrtcontract` * A user defined type named `person`, which defines the data stored in the table * A `kv table` type which stores objects of type `person`, named `address_table`. The primary index of the `kv table` is defined based on the `person::account_name` property. -Refer to the following possible implementation of your starting point. +Refer to the following possible implementation for your starting point. `smartcontract.hpp file` diff --git a/docs/06_how-to-guides/60_how-to-return-values-from-actions.md b/docs/06_how-to-guides/60_how-to-return-values-from-actions.md index 04d15ebedb..e184a02d27 100644 --- a/docs/06_how-to-guides/60_how-to-return-values-from-actions.md +++ b/docs/06_how-to-guides/60_how-to-return-values-from-actions.md @@ -10,7 +10,7 @@ In order to accomplish this, use the `return` statement and pass the desired ret ## Prerequisites -* Set your EOSIO development environment. Refer to the [Get Started](https://developers.eos.io/welcome/latest/getting-started/development-environment/introduction) Guide. +* Set your EOSIO development environment. Refer to the [Get Started Guide](https://developers.eos.io/welcome/latest/getting-started-guide/index). * You have a smart contract, let’s call it `smrtcontract`, and it builds without error. * You have an action, let’s call it `checkwithrv`, from which you want to return a value of a user defined type `action_response`. From c3eb5e1a34e75c60419aff3547f3f71f8bafa8b2 Mon Sep 17 00:00:00 2001 From: iamveritas Date: Fri, 2 Apr 2021 13:22:19 +0300 Subject: [PATCH 4/9] updates take 3 --- .../30_key-value-api/kv_table/10_how-to-use-kv-table.md | 8 +++++++- .../kv_table/20_how-to-create-indexes-kv-table.md | 4 ++++ .../kv_table/30_how-to-upsert-into-kv-table.md | 4 ++++ .../kv_table/40_how-to-delete-from-kv-table.md | 4 ++++ .../kv_table/50_how-to-iterate-kv-table.md | 4 ++++ .../kv_table/60_how-to-check-a-record-kv-table.md | 4 ++++ .../kv_table/70_how-to-find-in-kv-table.md | 4 ++++ .../kv_table/80_how-to-query-range-in-kv-table.md | 4 ++++ .../kv_table/90_how-to-allow-users-to-pay-kv-table.md | 4 ++++ .../50_how-to-create-and-use-action-wrappers.md | 3 +++ 10 files changed, 42 insertions(+), 1 deletion(-) diff --git a/docs/06_how-to-guides/30_key-value-api/kv_table/10_how-to-use-kv-table.md b/docs/06_how-to-guides/30_key-value-api/kv_table/10_how-to-use-kv-table.md index c87c35d734..ce25d82ec9 100644 --- a/docs/06_how-to-guides/30_key-value-api/kv_table/10_how-to-use-kv-table.md +++ b/docs/06_how-to-guides/30_key-value-api/kv_table/10_how-to-use-kv-table.md @@ -14,7 +14,9 @@ To accomplish this task, define the user type which will be stored in the `kv ta ## Before you begin -* The EOSIO development environment, for details consult the [Get Started Guide](https://developers.eos.io/welcome/latest/getting-started-guide/index). +Complete the following prerequisites: + +* An EOSIO development environment, for details consult the [Get Started Guide](https://developers.eos.io/welcome/latest/getting-started-guide/index). * A smart contract named `smrtcontract`. * A user defined type named `person`, which defines the data stored in the table. @@ -72,6 +74,10 @@ class [[eosio::contract]] smrtcontract : public contract { }; ``` +## Summary + +In conclusion, the above instructions show how to define and use a `Key-Value Table` (`kv table`) in a smart contract. + ## Next Steps The following options are available when you complete the procedure: diff --git a/docs/06_how-to-guides/30_key-value-api/kv_table/20_how-to-create-indexes-kv-table.md b/docs/06_how-to-guides/30_key-value-api/kv_table/20_how-to-create-indexes-kv-table.md index 3a1e301101..882793c2b6 100644 --- a/docs/06_how-to-guides/30_key-value-api/kv_table/20_how-to-create-indexes-kv-table.md +++ b/docs/06_how-to-guides/30_key-value-api/kv_table/20_how-to-create-indexes-kv-table.md @@ -177,6 +177,10 @@ class [[eosio::contract]] smrtcontract : public contract { }; ``` +## Summary + +In conclusion, the above instructions show how to create indexes on a `Key-Value Table` (`kv table`). + ## Next Steps The following options are available when you complete the procedure: diff --git a/docs/06_how-to-guides/30_key-value-api/kv_table/30_how-to-upsert-into-kv-table.md b/docs/06_how-to-guides/30_key-value-api/kv_table/30_how-to-upsert-into-kv-table.md index e57f51c009..9dfde3096b 100644 --- a/docs/06_how-to-guides/30_key-value-api/kv_table/30_how-to-upsert-into-kv-table.md +++ b/docs/06_how-to-guides/30_key-value-api/kv_table/30_how-to-upsert-into-kv-table.md @@ -105,6 +105,10 @@ void smrtcontract::upsert( } ``` +## Summary + +In conclusion, the above instructions show how to upsert into `Key-Value Table` (`kv table`). + ## Next Steps The following options are available when you complete the procedure: diff --git a/docs/06_how-to-guides/30_key-value-api/kv_table/40_how-to-delete-from-kv-table.md b/docs/06_how-to-guides/30_key-value-api/kv_table/40_how-to-delete-from-kv-table.md index 307e5f79db..7c0a31d9de 100644 --- a/docs/06_how-to-guides/30_key-value-api/kv_table/40_how-to-delete-from-kv-table.md +++ b/docs/06_how-to-guides/30_key-value-api/kv_table/40_how-to-delete-from-kv-table.md @@ -96,6 +96,10 @@ void smrtcontract::delete(eosio::name account_name) { } ``` +## Summary + +In conclusion, the above instructions show how to delete an object from a `Key-Value Table` (`kv table`). + ## Next Steps The following options are available when you complete the procedure: diff --git a/docs/06_how-to-guides/30_key-value-api/kv_table/50_how-to-iterate-kv-table.md b/docs/06_how-to-guides/30_key-value-api/kv_table/50_how-to-iterate-kv-table.md index 5064068468..60b9e5b744 100644 --- a/docs/06_how-to-guides/30_key-value-api/kv_table/50_how-to-iterate-kv-table.md +++ b/docs/06_how-to-guides/30_key-value-api/kv_table/50_how-to-iterate-kv-table.md @@ -118,3 +118,7 @@ std::vector smrtcontract::iterate(int iterations_count) { } } ``` + +## Summary + +In conclusion, the above instructions show how to iterate through a `Key-Value Table` (`kv table`) and read values from it. diff --git a/docs/06_how-to-guides/30_key-value-api/kv_table/60_how-to-check-a-record-kv-table.md b/docs/06_how-to-guides/30_key-value-api/kv_table/60_how-to-check-a-record-kv-table.md index 32a7c78347..048c7ceefe 100644 --- a/docs/06_how-to-guides/30_key-value-api/kv_table/60_how-to-check-a-record-kv-table.md +++ b/docs/06_how-to-guides/30_key-value-api/kv_table/60_how-to-check-a-record-kv-table.md @@ -102,6 +102,10 @@ bool smrtcontract::verify(string personal_id, string country) { } ``` +## Summary + +In conclusion, the above instructions show how to check if a specific object exists in a `Key-Value Table` (`kv table`). + ## Next Steps The following options are available when you complete the procedure: diff --git a/docs/06_how-to-guides/30_key-value-api/kv_table/70_how-to-find-in-kv-table.md b/docs/06_how-to-guides/30_key-value-api/kv_table/70_how-to-find-in-kv-table.md index 4268a8aeb3..243bdaac2f 100644 --- a/docs/06_how-to-guides/30_key-value-api/kv_table/70_how-to-find-in-kv-table.md +++ b/docs/06_how-to-guides/30_key-value-api/kv_table/70_how-to-find-in-kv-table.md @@ -119,6 +119,10 @@ person smrtcontract::find(name account_name) { } ``` +## Summary + +In conclusion, the above instructions show how to find a specific object in a `Key-Value Table` (`kv table`). + ## Next Steps The following options are available when you complete the procedure: diff --git a/docs/06_how-to-guides/30_key-value-api/kv_table/80_how-to-query-range-in-kv-table.md b/docs/06_how-to-guides/30_key-value-api/kv_table/80_how-to-query-range-in-kv-table.md index b461fc101a..c5d852b499 100644 --- a/docs/06_how-to-guides/30_key-value-api/kv_table/80_how-to-query-range-in-kv-table.md +++ b/docs/06_how-to-guides/30_key-value-api/kv_table/80_how-to-query-range-in-kv-table.md @@ -119,6 +119,10 @@ std::vector smrtcontract::getbylastname(string last_name) { } ``` +## Summary + +In conclusion, the above instructions show how to retrieve a list of values, from a `Key-Value Table` (`kv table`) index, which share a particular commonality. + ## Next Steps The following options are available when you complete the procedure: diff --git a/docs/06_how-to-guides/30_key-value-api/kv_table/90_how-to-allow-users-to-pay-kv-table.md b/docs/06_how-to-guides/30_key-value-api/kv_table/90_how-to-allow-users-to-pay-kv-table.md index f101221769..758ebe0e40 100644 --- a/docs/06_how-to-guides/30_key-value-api/kv_table/90_how-to-allow-users-to-pay-kv-table.md +++ b/docs/06_how-to-guides/30_key-value-api/kv_table/90_how-to-allow-users-to-pay-kv-table.md @@ -107,6 +107,10 @@ void smrtcontract::upsert( } ``` +## Summary + +In conclusion, the above instructions show how to pay for the resources needed to store data in a `Key-Value Table` (`kv table`). + ## Next Steps The following options are available when you complete the procedure: diff --git a/docs/06_how-to-guides/50_how-to-create-and-use-action-wrappers.md b/docs/06_how-to-guides/50_how-to-create-and-use-action-wrappers.md index 9692ff7b76..f00f6aceda 100644 --- a/docs/06_how-to-guides/50_how-to-create-and-use-action-wrappers.md +++ b/docs/06_how-to-guides/50_how-to-create-and-use-action-wrappers.md @@ -4,6 +4,7 @@ link_text: "How to create and use action wrappers" --- 1. Start with a contract `multi_index_example` which has an action `mod` defined like below in file `multi_index_example.hpp`; the action modifies the integer value `n` stored for row with key `user`. + ```cpp class [[eosio::contract]] multi_index_example : public contract { // ... @@ -11,7 +12,9 @@ class [[eosio::contract]] multi_index_example : public contract { // ... } ``` + 2. To define an action wrapper for the `mod` action, make use of the `eosio::action_wrapper` template, with the first parameter the action name as a `eosio::name` and second parameter as the reference to the action method + ```diff class [[eosio::contract]] multi_index_example : public contract { // ... From d214537ef6d094dae2fc0df278121d815c89c9dc Mon Sep 17 00:00:00 2001 From: iamveritas Date: Tue, 6 Apr 2021 16:12:55 +0300 Subject: [PATCH 5/9] how to action wrapper --- ...to_restrict_access_to_an_action_by_user.md | 2 +- ...0_how-to-create-and-use-action-wrappers.md | 58 +++++++++++++++++-- 2 files changed, 54 insertions(+), 6 deletions(-) diff --git a/docs/06_how-to-guides/20_authorization/how_to_restrict_access_to_an_action_by_user.md b/docs/06_how-to-guides/20_authorization/how_to_restrict_access_to_an_action_by_user.md index 9a171ee1fd..2910c27cfd 100644 --- a/docs/06_how-to-guides/20_authorization/how_to_restrict_access_to_an_action_by_user.md +++ b/docs/06_how-to-guides/20_authorization/how_to_restrict_access_to_an_action_by_user.md @@ -79,4 +79,4 @@ void hi( name user ) { ## Summary -In conclusion, the above instructions show how to how to perform authorization checks in a smart contract. +In conclusion, the above instructions show how to perform authorization checks in a smart contract. diff --git a/docs/06_how-to-guides/50_how-to-create-and-use-action-wrappers.md b/docs/06_how-to-guides/50_how-to-create-and-use-action-wrappers.md index f00f6aceda..d02f11932d 100644 --- a/docs/06_how-to-guides/50_how-to-create-and-use-action-wrappers.md +++ b/docs/06_how-to-guides/50_how-to-create-and-use-action-wrappers.md @@ -3,7 +3,19 @@ content_title: How to create and use action wrappers link_text: "How to create and use action wrappers" --- -1. Start with a contract `multi_index_example` which has an action `mod` defined like below in file `multi_index_example.hpp`; the action modifies the integer value `n` stored for row with key `user`. +## Overview + +This how-to guide provides instructions on how to create and use an action wrapper in a smart contract. + +## Before you begin + +Complete the following prerequisites: + +* An EOSIO development environment, for details consult the [Get Started Guide](https://developers.eos.io/welcome/latest/getting-started-guide/index). +* A smart contract named `multi_index_example`, defined in file `multi_index_example.hpp`. +* An action `mod` which modifies the integer value `n` stored for row with key `user`. + +Refer to the following possible implementation for your starting point. ```cpp class [[eosio::contract]] multi_index_example : public contract { @@ -13,7 +25,25 @@ class [[eosio::contract]] multi_index_example : public contract { } ``` -2. To define an action wrapper for the `mod` action, make use of the `eosio::action_wrapper` template, with the first parameter the action name as a `eosio::name` and second parameter as the reference to the action method +## Code Reference + +See the following code reference guide for action wrapper: + +* [eosio::action_wrapper](../structeosio_1_1action__wrapper). + +## Procedure + +Complete the following steps to create and use action wrapper in the smart contract: + +1. [Define the action wrapper](#1-define-the-action-wrapper) +2. [Use the action wrapper](#2-use-the-action-wrapper) + * [2.1. Include Header File](#21-include-header-file) + * [2.2. Instantiate The Action Wrapper](#22-instantiate-the-action-wrapper) + * [2.3. Send The Action Using The Action Wrapper](#23-send-the-action-using-the-action-wrapper) + +### 1. Define The Action Wrapper + +To define an action wrapper for the `mod` action, make use of the `eosio::action_wrapper` template, with the first parameter the action name as a `eosio::name` and second parameter as the reference to the action method: ```diff class [[eosio::contract]] multi_index_example : public contract { @@ -24,17 +54,31 @@ class [[eosio::contract]] multi_index_example : public contract { // ... } ``` -3. To use the action wrapper, you have to include the header file where the action wrapper is defined + +### 2. Use The Action Wrapper + +#### 2.1. Include Header File + +To use the action wrapper, you have to include the header file where the action wrapper is defined: + ```cpp #include ``` -4. Then instantiate the `mod_action` defined above, specifying the contract to send the action to as the first argument. In this case, it is assumed the contract is deployed to `multiindexex` account, and a structure which is defined by two parameters: the self account, obtained by `get_self()` call, and the `active` permission (you can modify these two parameters based on your requirements). + +#### 2.2. Instantiate The Action Wrapper + +Instantiate the `mod_action` defined above, specifying the contract to send the action to as the first argument. In this case, it is assumed the contract is deployed to `multiindexex` account, and a structure which is defined by two parameters: the self account, obtained by `get_self()` call, and the `active` permission (you can modify these two parameters based on your requirements). + ```diff #include +multi_index_example::mod_action modaction("multiindexex"_n, {get_self(), "active"_n}); ``` -5. And finally call the `send` method of the action wrapper and pass in the `mod` action's parameters as positional arguments + +#### 2.3. Send The Action Using The Action Wrapper + +Call the `send` method of the action wrapper and pass in the `mod` action's parameters as positional arguments: + ```diff #include @@ -44,3 +88,7 @@ multi_index_example::mod_action modaction("multiindexex"_n, {get_self(), 1}); ``` For a full example see the [`multi_index` contract implementation](/~https://github.com/EOSIO/eosio.cdt/tree/master/examples/multi_index_example). + +## Summary + +In conclusion, the above instructions show how to create and use action wrapper in a smart contract. From edb426b3129f032e0c5d4e7e75f65019b958f54a Mon Sep 17 00:00:00 2001 From: iamveritas Date: Tue, 6 Apr 2021 16:28:58 +0300 Subject: [PATCH 6/9] cosmetic updates --- .../kv_map/10_how-to-use-kv-map.md | 2 +- .../kv_map/30_how-to-upsert-into-kv-map.md | 2 +- .../kv_map/40_how-to-delete-from-kv-map.md | 2 +- .../kv_map/50_how-to-iterate-kv-map.md | 2 +- .../kv_map/70_how-to-find-in-kv-map.md | 2 +- .../90_how-to-allow-users-to-pay-kv-map.md | 2 +- .../kv_table/10_how-to-use-kv-table.md | 2 +- .../20_how-to-create-indexes-kv-table.md | 2 +- .../30_how-to-upsert-into-kv-table.md | 2 +- .../40_how-to-delete-from-kv-table.md | 2 +- .../kv_table/50_how-to-iterate-kv-table.md | 2 +- .../60_how-to-check-a-record-kv-table.md | 2 +- .../kv_table/70_how-to-find-in-kv-table.md | 2 +- .../80_how-to-query-range-in-kv-table.md | 2 +- .../90_how-to-allow-users-to-pay-kv-table.md | 2 +- ...0_how-to-create-and-use-action-wrappers.md | 2 +- .../60_how-to-return-values-from-actions.md | 25 +++++++++++++------ 17 files changed, 34 insertions(+), 23 deletions(-) diff --git a/docs/06_how-to-guides/30_key-value-api/kv_map/10_how-to-use-kv-map.md b/docs/06_how-to-guides/30_key-value-api/kv_map/10_how-to-use-kv-map.md index d3c93175f8..470f7d2e22 100644 --- a/docs/06_how-to-guides/30_key-value-api/kv_map/10_how-to-use-kv-map.md +++ b/docs/06_how-to-guides/30_key-value-api/kv_map/10_how-to-use-kv-map.md @@ -17,7 +17,7 @@ Complete the following prerequisites: * A smart contract named `smrtcontract` * A user defined type named `person`, which defines the data stored in the map -Refer to the following possible implementation for your starting point. +Refer to the following possible implementation for your starting point: `smartcontract.hpp file` diff --git a/docs/06_how-to-guides/30_key-value-api/kv_map/30_how-to-upsert-into-kv-map.md b/docs/06_how-to-guides/30_key-value-api/kv_map/30_how-to-upsert-into-kv-map.md index cbb4eee55e..be19c9554d 100644 --- a/docs/06_how-to-guides/30_key-value-api/kv_map/30_how-to-upsert-into-kv-map.md +++ b/docs/06_how-to-guides/30_key-value-api/kv_map/30_how-to-upsert-into-kv-map.md @@ -16,7 +16,7 @@ Complete the following prerequisites: * A user defined type named `person`, which defines the data stored in the map * A `kv map` object, name `my_map`, which stores objects of type `person`, with unique keys of type `int` -Refer to the following possible implementation for your starting point. +Refer to the following possible implementation for your starting point: `smartcontract.hpp file` diff --git a/docs/06_how-to-guides/30_key-value-api/kv_map/40_how-to-delete-from-kv-map.md b/docs/06_how-to-guides/30_key-value-api/kv_map/40_how-to-delete-from-kv-map.md index 433fdf7bf1..5cd727e298 100644 --- a/docs/06_how-to-guides/30_key-value-api/kv_map/40_how-to-delete-from-kv-map.md +++ b/docs/06_how-to-guides/30_key-value-api/kv_map/40_how-to-delete-from-kv-map.md @@ -16,7 +16,7 @@ Complete the following prerequisites: * A user defined type named `person`, which defines the data stored in the map * A `kv map` object, name `my_map`, which stores objects of type `person`, with unique keys of type `int` -Refer to the following possible implementation for your starting point. +Refer to the following possible implementation for your starting point: `smartcontract.hpp file` diff --git a/docs/06_how-to-guides/30_key-value-api/kv_map/50_how-to-iterate-kv-map.md b/docs/06_how-to-guides/30_key-value-api/kv_map/50_how-to-iterate-kv-map.md index 296a2ea14c..c9c5e31d8a 100644 --- a/docs/06_how-to-guides/30_key-value-api/kv_map/50_how-to-iterate-kv-map.md +++ b/docs/06_how-to-guides/30_key-value-api/kv_map/50_how-to-iterate-kv-map.md @@ -16,7 +16,7 @@ Complete the following prerequisites: * A user defined type named `person`, which defines the data stored in the map * A `kv map` object, name `my_map`, which stores objects of type `person`, with unique keys of type `int`. -Refer to the following possible implementation for your starting point. +Refer to the following possible implementation for your starting point: `smartcontract.hpp file` diff --git a/docs/06_how-to-guides/30_key-value-api/kv_map/70_how-to-find-in-kv-map.md b/docs/06_how-to-guides/30_key-value-api/kv_map/70_how-to-find-in-kv-map.md index 32370d83ba..6d8b78fcef 100644 --- a/docs/06_how-to-guides/30_key-value-api/kv_map/70_how-to-find-in-kv-map.md +++ b/docs/06_how-to-guides/30_key-value-api/kv_map/70_how-to-find-in-kv-map.md @@ -16,7 +16,7 @@ Complete the following prerequisites: * A user defined type named `person`, which defines the data stored in the map * A `kv map` object, name `my_map`, which stores objects of type `person`, with unique keys of type `int`. -Refer to the following possible implementation for your starting point. +Refer to the following possible implementation for your starting point: `smartcontract.hpp file` diff --git a/docs/06_how-to-guides/30_key-value-api/kv_map/90_how-to-allow-users-to-pay-kv-map.md b/docs/06_how-to-guides/30_key-value-api/kv_map/90_how-to-allow-users-to-pay-kv-map.md index ec6ef01cdf..fc2b5336c1 100644 --- a/docs/06_how-to-guides/30_key-value-api/kv_map/90_how-to-allow-users-to-pay-kv-map.md +++ b/docs/06_how-to-guides/30_key-value-api/kv_map/90_how-to-allow-users-to-pay-kv-map.md @@ -14,7 +14,7 @@ Complete the following prerequisites: * A user defined type named `person`, which defines the data stored in the map * A `kv map` object, name `my_map`, which stores objects of type `person`, with unique keys of type `int`. -Refer to the following possible implementation for your starting point. +Refer to the following possible implementation for your starting point: `smartcontract.hpp file` diff --git a/docs/06_how-to-guides/30_key-value-api/kv_table/10_how-to-use-kv-table.md b/docs/06_how-to-guides/30_key-value-api/kv_table/10_how-to-use-kv-table.md index ce25d82ec9..94ada5b62b 100644 --- a/docs/06_how-to-guides/30_key-value-api/kv_table/10_how-to-use-kv-table.md +++ b/docs/06_how-to-guides/30_key-value-api/kv_table/10_how-to-use-kv-table.md @@ -20,7 +20,7 @@ Complete the following prerequisites: * A smart contract named `smrtcontract`. * A user defined type named `person`, which defines the data stored in the table. -Refer to the following possible implementation for your starting point. +Refer to the following possible implementation for your starting point: `smartcontract.hpp file` diff --git a/docs/06_how-to-guides/30_key-value-api/kv_table/20_how-to-create-indexes-kv-table.md b/docs/06_how-to-guides/30_key-value-api/kv_table/20_how-to-create-indexes-kv-table.md index 882793c2b6..b83ebe676b 100644 --- a/docs/06_how-to-guides/30_key-value-api/kv_table/20_how-to-create-indexes-kv-table.md +++ b/docs/06_how-to-guides/30_key-value-api/kv_table/20_how-to-create-indexes-kv-table.md @@ -31,7 +31,7 @@ Complete the following prerequisites: * `last_name`, * `personal_id`. -Refer to the following possible implementation for your starting point. +Refer to the following possible implementation for your starting point: `smartcontract.hpp file` diff --git a/docs/06_how-to-guides/30_key-value-api/kv_table/30_how-to-upsert-into-kv-table.md b/docs/06_how-to-guides/30_key-value-api/kv_table/30_how-to-upsert-into-kv-table.md index 9dfde3096b..9e0bfe7ea3 100644 --- a/docs/06_how-to-guides/30_key-value-api/kv_table/30_how-to-upsert-into-kv-table.md +++ b/docs/06_how-to-guides/30_key-value-api/kv_table/30_how-to-upsert-into-kv-table.md @@ -21,7 +21,7 @@ Complete the following prerequisites: * A user defined type named `person`, which defines the data stored in the table * A `kv table` type which stores objects of type `person`, named `address_table`. The primary index of the `kv table` is defined based on the `person::account_name` property. -Refer to the following possible implementation for your starting point. +Refer to the following possible implementation for your starting point: `smartcontract.hpp file` diff --git a/docs/06_how-to-guides/30_key-value-api/kv_table/40_how-to-delete-from-kv-table.md b/docs/06_how-to-guides/30_key-value-api/kv_table/40_how-to-delete-from-kv-table.md index 7c0a31d9de..5f21c20ecf 100644 --- a/docs/06_how-to-guides/30_key-value-api/kv_table/40_how-to-delete-from-kv-table.md +++ b/docs/06_how-to-guides/30_key-value-api/kv_table/40_how-to-delete-from-kv-table.md @@ -21,7 +21,7 @@ Complete the following prerequisites: * A user defined type named `person`, which defines the data stored in the table * A `kv table` type which stores objects of type `person`, named `address_table`. The primary index of the `kv table` is defined based on the `person::account_name` property. -Refer to the following possible implementation for your starting point. +Refer to the following possible implementation for your starting point: `smartcontract.hpp file` diff --git a/docs/06_how-to-guides/30_key-value-api/kv_table/50_how-to-iterate-kv-table.md b/docs/06_how-to-guides/30_key-value-api/kv_table/50_how-to-iterate-kv-table.md index 60b9e5b744..38cb5ace6d 100644 --- a/docs/06_how-to-guides/30_key-value-api/kv_table/50_how-to-iterate-kv-table.md +++ b/docs/06_how-to-guides/30_key-value-api/kv_table/50_how-to-iterate-kv-table.md @@ -27,7 +27,7 @@ Complete the following prerequisites: * `personal_id`. * A unique index, named `account_name_uidx`, defined on the `account_name` property.. -Refer to the following possible implementation for your starting point. +Refer to the following possible implementation for your starting point: `smartcontract.hpp file` diff --git a/docs/06_how-to-guides/30_key-value-api/kv_table/60_how-to-check-a-record-kv-table.md b/docs/06_how-to-guides/30_key-value-api/kv_table/60_how-to-check-a-record-kv-table.md index 048c7ceefe..6f4d33104f 100644 --- a/docs/06_how-to-guides/30_key-value-api/kv_table/60_how-to-check-a-record-kv-table.md +++ b/docs/06_how-to-guides/30_key-value-api/kv_table/60_how-to-check-a-record-kv-table.md @@ -27,7 +27,7 @@ Complete the following prerequisites: * `personal_id`. * A unique index, named `account_name_uidx`, defined on the `account_name` property.. -Refer to the following possible implementation for your starting point. +Refer to the following possible implementation for your starting point: `smartcontract.hpp file` diff --git a/docs/06_how-to-guides/30_key-value-api/kv_table/70_how-to-find-in-kv-table.md b/docs/06_how-to-guides/30_key-value-api/kv_table/70_how-to-find-in-kv-table.md index 243bdaac2f..6192a387c6 100644 --- a/docs/06_how-to-guides/30_key-value-api/kv_table/70_how-to-find-in-kv-table.md +++ b/docs/06_how-to-guides/30_key-value-api/kv_table/70_how-to-find-in-kv-table.md @@ -27,7 +27,7 @@ Complete the following prerequisites: * `personal_id`. * A unique index, named `account_name_uidx`, defined on the `account_name` property.. -Refer to the following possible implementation for your starting point. +Refer to the following possible implementation for your starting point: `smartcontract.hpp file` diff --git a/docs/06_how-to-guides/30_key-value-api/kv_table/80_how-to-query-range-in-kv-table.md b/docs/06_how-to-guides/30_key-value-api/kv_table/80_how-to-query-range-in-kv-table.md index c5d852b499..852797ad53 100644 --- a/docs/06_how-to-guides/30_key-value-api/kv_table/80_how-to-query-range-in-kv-table.md +++ b/docs/06_how-to-guides/30_key-value-api/kv_table/80_how-to-query-range-in-kv-table.md @@ -28,7 +28,7 @@ Complete the following prerequisites: * A unique index, named `account_name_uidx`, defined on the `account_name` property.. * A non-unique index defined on the `last_name` property, named `last_name_idx`. -Refer to the following possible implementation for your starting point. +Refer to the following possible implementation for your starting point: `smartcontract.hpp file` diff --git a/docs/06_how-to-guides/30_key-value-api/kv_table/90_how-to-allow-users-to-pay-kv-table.md b/docs/06_how-to-guides/30_key-value-api/kv_table/90_how-to-allow-users-to-pay-kv-table.md index 758ebe0e40..3824fcb20e 100644 --- a/docs/06_how-to-guides/30_key-value-api/kv_table/90_how-to-allow-users-to-pay-kv-table.md +++ b/docs/06_how-to-guides/30_key-value-api/kv_table/90_how-to-allow-users-to-pay-kv-table.md @@ -21,7 +21,7 @@ Complete the following prerequisites: * A user defined type named `person`, which defines the data stored in the table * A `kv table` type which stores objects of type `person`, named `address_table`. The primary index of the `kv table` is defined based on the `person::account_name` property. -Refer to the following possible implementation for your starting point. +Refer to the following possible implementation for your starting point: `smartcontract.hpp file` diff --git a/docs/06_how-to-guides/50_how-to-create-and-use-action-wrappers.md b/docs/06_how-to-guides/50_how-to-create-and-use-action-wrappers.md index d02f11932d..8c337f83b8 100644 --- a/docs/06_how-to-guides/50_how-to-create-and-use-action-wrappers.md +++ b/docs/06_how-to-guides/50_how-to-create-and-use-action-wrappers.md @@ -15,7 +15,7 @@ Complete the following prerequisites: * A smart contract named `multi_index_example`, defined in file `multi_index_example.hpp`. * An action `mod` which modifies the integer value `n` stored for row with key `user`. -Refer to the following possible implementation for your starting point. +Refer to the following possible implementation for your starting point: ```cpp class [[eosio::contract]] multi_index_example : public contract { diff --git a/docs/06_how-to-guides/60_how-to-return-values-from-actions.md b/docs/06_how-to-guides/60_how-to-return-values-from-actions.md index e184a02d27..40ae679320 100644 --- a/docs/06_how-to-guides/60_how-to-return-values-from-actions.md +++ b/docs/06_how-to-guides/60_how-to-return-values-from-actions.md @@ -2,19 +2,21 @@ content_title: How-To Return Values From Action --- -## Summary +## Overview This how-to demonstrates how a smart contract developer implements return values from an action. In order to accomplish this, use the `return` statement and pass the desired returned value, which can be of any C++ primitive type, a standard library type, or a user defined type. -## Prerequisites +## Before you begin + +Complete the following prerequisites: -* Set your EOSIO development environment. Refer to the [Get Started Guide](https://developers.eos.io/welcome/latest/getting-started-guide/index). -* You have a smart contract, let’s call it `smrtcontract`, and it builds without error. -* You have an action, let’s call it `checkwithrv`, from which you want to return a value of a user defined type `action_response`. +* An EOSIO development environment, for details consult the [Get Started Guide](https://developers.eos.io/welcome/latest/getting-started-guide/index). +* A smart contract, let’s call it `smrtcontract`, which builds without error. +* An action, let’s call it `checkwithrv`, from which you want to return a value of a user defined type `action_response`. -Refer to the following example. +Refer to the following possible implementation for your starting point: ```cpp struct action_response @@ -36,7 +38,7 @@ class [[eosio::contract]] smrtcontract : public contract { Complete the following steps to return an instance of `action_response` from the `checkwithrv` action: -1. Create an instance of the `action_response` C++ defined structure. +1. Create an instance of `action_response` C++ defined structure. 2. Initialize its data members based on the action’s business logic. 3. Use `return` statement and pass as a parameter the instance created and initialized in previous steps. @@ -45,7 +47,10 @@ Complete the following steps to return an instance of `action_response` from the action_response smrtcontract::checkwithrv( name nm ) { print_f("Name : %\n", nm); + // create instance of the action response structure action_response results; + + // initialize its data members results.id = 1; if (nm == "hello"_n) { results.status = {0, "Validation has passed."}; @@ -53,6 +58,8 @@ action_response smrtcontract::checkwithrv( name nm ) { else { results.status = {1, "Input param `name` not equal to `hello`."}; } + + // use return statement return results; // the `set_action_return_value` intrinsic is invoked automatically here } ``` @@ -69,3 +76,7 @@ The following options are available when you complete the procedure: [[info | Returned values from actions availability]] The returned values from actions are only available to the clients sending the action via the RPC API. Currently, there is no support for an inline action to be able to use the return value, because inline actions don't execute synchronously. + +## Summary + +In conclusion, the above instructions show how to return values from actions. From 3d0cbbf8ff3fce72b1a95af4de79027b9db59f9a Mon Sep 17 00:00:00 2001 From: iamveritas Date: Thu, 8 Apr 2021 14:38:00 +0300 Subject: [PATCH 7/9] how to write an abi file it is actually a tutorial not a how to --- .../03_create-an-abi-file.md} | 5 ++++- docs/09_tutorials/index.md | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) rename docs/{06_how-to-guides/70_how-to-write-an-abi-file.md => 09_tutorials/03_create-an-abi-file.md} (99%) diff --git a/docs/06_how-to-guides/70_how-to-write-an-abi-file.md b/docs/09_tutorials/03_create-an-abi-file.md similarity index 99% rename from docs/06_how-to-guides/70_how-to-write-an-abi-file.md rename to docs/09_tutorials/03_create-an-abi-file.md index e2c12b3f63..42537a1ebc 100644 --- a/docs/06_how-to-guides/70_how-to-write-an-abi-file.md +++ b/docs/09_tutorials/03_create-an-abi-file.md @@ -1,7 +1,10 @@ --- -content_title: How to Write an ABI File +content_title: Create an ABI File --- +## Overview + +This tutorial provides instructions on how to create an ABI file. [[warning]] | As of v1.2.0, the eosio.wasmsdk was decoupled from the core repository. This change has introduced an eosio-cpp regression where the legacy eosio-abigen is no longer bundled with eosio-cpp. Until a new ABI generator is introduced, you will need to hand-write your ABI files. diff --git a/docs/09_tutorials/index.md b/docs/09_tutorials/index.md index 4d428089f4..95c7f23191 100644 --- a/docs/09_tutorials/index.md +++ b/docs/09_tutorials/index.md @@ -5,3 +5,4 @@ link_text: Tutorials - [Binary Extension](01_binary-extension.md) - [ABI Variants](02_abi-variants.md) +- [Create An ABI File](03_create-an-abi-file.md) From 57084945b64698cd9ef020acfeaba343c0750bd6 Mon Sep 17 00:00:00 2001 From: iamveritas Date: Wed, 14 Apr 2021 14:12:43 +0300 Subject: [PATCH 8/9] updates based on code review --- .../01_compile-a-contract-via-cli.md | 2 +- .../10_compile/02_how-to-configure-cmake.md | 2 +- .../03_compiling-contracts-with-cmake.md | 2 +- ...to_restrict_access_to_an_action_by_user.md | 2 +- .../kv_map/10_how-to-use-kv-map.md | 20 +++++++++++++++---- .../kv_map/30_how-to-upsert-into-kv-map.md | 8 ++++---- .../kv_map/40_how-to-delete-from-kv-map.md | 6 +++--- .../kv_map/50_how-to-iterate-kv-map.md | 10 ++++------ .../kv_map/70_how-to-find-in-kv-map.md | 6 +++--- .../90_how-to-allow-users-to-pay-kv-map.md | 16 +++++++-------- .../kv_table/10_how-to-use-kv-table.md | 4 ++-- .../20_how-to-create-indexes-kv-table.md | 12 +++++------ .../30_how-to-upsert-into-kv-table.md | 6 +++--- .../40_how-to-delete-from-kv-table.md | 6 +++--- .../kv_table/50_how-to-iterate-kv-table.md | 8 ++++---- .../60_how-to-check-a-record-kv-table.md | 6 +++--- .../kv_table/70_how-to-find-in-kv-table.md | 6 +++--- .../80_how-to-query-range-in-kv-table.md | 6 +++--- .../90_how-to-allow-users-to-pay-kv-table.md | 8 ++++---- ...0_how-to-create-and-use-action-wrappers.md | 20 +++++++++---------- .../60_how-to-return-values-from-actions.md | 8 ++++---- 21 files changed, 87 insertions(+), 77 deletions(-) diff --git a/docs/06_how-to-guides/10_compile/01_compile-a-contract-via-cli.md b/docs/06_how-to-guides/10_compile/01_compile-a-contract-via-cli.md index efd2773736..2014a1c326 100644 --- a/docs/06_how-to-guides/10_compile/01_compile-a-contract-via-cli.md +++ b/docs/06_how-to-guides/10_compile/01_compile-a-contract-via-cli.md @@ -4,7 +4,7 @@ content_title: How to compile a smart contract via CLI ## Overview -This how-to guide provides instructions how to compile a smart contract using the command line interface (CLI). +This guide provides instructions how to compile a smart contract using the command line interface (CLI). ## Before you begin diff --git a/docs/06_how-to-guides/10_compile/02_how-to-configure-cmake.md b/docs/06_how-to-guides/10_compile/02_how-to-configure-cmake.md index 12b68f0ebb..db9511dc1b 100644 --- a/docs/06_how-to-guides/10_compile/02_how-to-configure-cmake.md +++ b/docs/06_how-to-guides/10_compile/02_how-to-configure-cmake.md @@ -4,7 +4,7 @@ content_title: How to configure CMake ## Overview -This how-to guide provides instructions how to configure CMake. +This guide provides instructions how to configure CMake. ## Before you begin diff --git a/docs/06_how-to-guides/10_compile/03_compiling-contracts-with-cmake.md b/docs/06_how-to-guides/10_compile/03_compiling-contracts-with-cmake.md index eb0314f097..612c0e3425 100644 --- a/docs/06_how-to-guides/10_compile/03_compiling-contracts-with-cmake.md +++ b/docs/06_how-to-guides/10_compile/03_compiling-contracts-with-cmake.md @@ -4,7 +4,7 @@ content_title: How to compile a smart contract with CMake ## Overview -This how-to guide provides instructions on how to compile a smart contract with CMake. +This guide provides instructions on how to compile a smart contract with CMake. ## Before you begin diff --git a/docs/06_how-to-guides/20_authorization/how_to_restrict_access_to_an_action_by_user.md b/docs/06_how-to-guides/20_authorization/how_to_restrict_access_to_an_action_by_user.md index 2910c27cfd..e26e72f46d 100644 --- a/docs/06_how-to-guides/20_authorization/how_to_restrict_access_to_an_action_by_user.md +++ b/docs/06_how-to-guides/20_authorization/how_to_restrict_access_to_an_action_by_user.md @@ -5,7 +5,7 @@ link_text: How To Perform Authorization Checks ## Overview -This how-to guide provides instructions how to perform authorization checks in a smart contract. +This guide provides instructions how to perform authorization checks in a smart contract. ## Before you begin diff --git a/docs/06_how-to-guides/30_key-value-api/kv_map/10_how-to-use-kv-map.md b/docs/06_how-to-guides/30_key-value-api/kv_map/10_how-to-use-kv-map.md index 470f7d2e22..616ebc3d09 100644 --- a/docs/06_how-to-guides/30_key-value-api/kv_map/10_how-to-use-kv-map.md +++ b/docs/06_how-to-guides/30_key-value-api/kv_map/10_how-to-use-kv-map.md @@ -7,17 +7,29 @@ link_text: "How-To Use Key-Value Map" This how-to demonstrates how to define and use a `Key-Value Map` (`kv map`) in a smart contract. -To accomplish this task use `eosio::kv::map` template class, specify the name for the map object instantiated, the type of the key, and the type for the values stored for each key. The types used for the key and the values can be any standard type, or a user defined type. +To accomplish this task do the following: + +1. Instantiate an object of type `eosio::kv::map`. +2. Specify the name for the instantiated `eosio::kv::map` object. +3. Specify the type for the map's key. +4. Specify the type for the values stored for each key. +5. The key and the values types can be of any standard type or a user defined type. + +## Reference + +See the following code reference: + +* The [`kv::map`](https://developers.eos.io/manuals/eosio.cdt/latest/classeosio_1_1kv_1_1map) class. ## Before you begin -Complete the following prerequisites: +Make sure you have the following prerequisites in place: * An EOSIO development environment, for details consult the [Get Started Guide](https://developers.eos.io/welcome/latest/getting-started-guide/index) * A smart contract named `smrtcontract` * A user defined type named `person`, which defines the data stored in the map -Refer to the following possible implementation for your starting point: +Refer to the following reference implementation for your starting point: `smartcontract.hpp file` @@ -41,7 +53,7 @@ class [[eosio::contract]] smartcontract : public eosio::contract { Complete the following steps to define the `my_map_t` type, based on the `eosio::kv::map`, which stores objects of type `person` with unique keys of type `int` and instantiate a map object of type `my_map_t`: * Define the `my_map_t` type based on `eosio::kv::map`. -* Specify `"kvmap"_n`, which is an `eosio::name`, as the first parameter, to name for the map object. +* Specify `"kvmap"_n`, which is an `eosio::name`, as the first parameter, to name the map object. * Specify `int` as the second parameter to give the type of the unique keys. * Specify `person` as the third parameter to give the type of the values stored in the map with each key. * Declare and instantiate, as a private data member, an instance of the type `my_map_t`, and name it `my_map`. diff --git a/docs/06_how-to-guides/30_key-value-api/kv_map/30_how-to-upsert-into-kv-map.md b/docs/06_how-to-guides/30_key-value-api/kv_map/30_how-to-upsert-into-kv-map.md index be19c9554d..87447effd0 100644 --- a/docs/06_how-to-guides/30_key-value-api/kv_map/30_how-to-upsert-into-kv-map.md +++ b/docs/06_how-to-guides/30_key-value-api/kv_map/30_how-to-upsert-into-kv-map.md @@ -9,14 +9,14 @@ This how-to provides instructions to upsert into `Key-Value Map` (`kv map`). Ups ## Before you begin -Complete the following prerequisites: +Make sure you have the following prerequisites in place: -* Install EOSIO development environment, for details consult the [Get Started Guide](https://developers.eos.io/welcome/latest/getting-started-guide/index) +* An EOSIO development environment, for details consult the [Get Started Guide](https://developers.eos.io/welcome/latest/getting-started-guide/index) * A smart contract named `smrtcontract` * A user defined type named `person`, which defines the data stored in the map * A `kv map` object, name `my_map`, which stores objects of type `person`, with unique keys of type `int` -Refer to the following possible implementation for your starting point: +Refer to the following reference implementation for your starting point: `smartcontract.hpp file` @@ -49,7 +49,7 @@ Complete the following steps to insert a new `person` object with a given ID, if 2. Create an instance of the `person` class, named `person_upsert`, based on the input parameters: `account_name`, `first_name` and `last_name`. 3. Use the `[]` operator defined for the `kv::map` type, and set the newly created `person_upsert` object as the value for the `id` key. -Refer to the following possible implementation to insert a new `person` object, and then update it, in the `kv map`: +Refer to the following reference implementation to insert a new `person` object, and then update it, in the `kv map`: `smartcontract.hpp file` diff --git a/docs/06_how-to-guides/30_key-value-api/kv_map/40_how-to-delete-from-kv-map.md b/docs/06_how-to-guides/30_key-value-api/kv_map/40_how-to-delete-from-kv-map.md index 5cd727e298..aeb31cc58a 100644 --- a/docs/06_how-to-guides/30_key-value-api/kv_map/40_how-to-delete-from-kv-map.md +++ b/docs/06_how-to-guides/30_key-value-api/kv_map/40_how-to-delete-from-kv-map.md @@ -9,14 +9,14 @@ This how-to provides instructions to delete from `Key-Value Map` (`kv map`) base ## Before you begin -Complete the following prerequisites: +Make sure you have the following prerequisites in place: * An EOSIO development environment, for details consult the [Get Started Guide](https://developers.eos.io/welcome/latest/getting-started-guide/index) * A smart contract named `smrtcontract` * A user defined type named `person`, which defines the data stored in the map * A `kv map` object, name `my_map`, which stores objects of type `person`, with unique keys of type `int` -Refer to the following possible implementation for your starting point: +Refer to the following reference implementation for your starting point: `smartcontract.hpp file` @@ -50,7 +50,7 @@ Complete the following steps to delete a `person` object with a given ID from th 3. If the `person` with the give ID is found use the `erase()` function defined for the `kv::map`, with the given ID as parameter, to erase the person object from the map. 4. If the `person` with the given ID is not found print an informative error message. -Refer to the following possible implementation to delete a `person` object from the `kv map`: +Refer to the following reference implementation to delete a `person` object from the `kv map`: `smartcontract.hpp file` diff --git a/docs/06_how-to-guides/30_key-value-api/kv_map/50_how-to-iterate-kv-map.md b/docs/06_how-to-guides/30_key-value-api/kv_map/50_how-to-iterate-kv-map.md index c9c5e31d8a..48a6307da9 100644 --- a/docs/06_how-to-guides/30_key-value-api/kv_map/50_how-to-iterate-kv-map.md +++ b/docs/06_how-to-guides/30_key-value-api/kv_map/50_how-to-iterate-kv-map.md @@ -9,14 +9,14 @@ This how-to provides instructions to iterate through a `Key-Value Map` (`kv map` ## Before you begin -Complete the following prerequisites: +Make sure you have the following prerequisites in place: * An EOSIO development environment, for details consult the [Get Started Guide](https://developers.eos.io/welcome/latest/getting-started-guide/index) * A smart contract named `smrtcontract` * A user defined type named `person`, which defines the data stored in the map * A `kv map` object, name `my_map`, which stores objects of type `person`, with unique keys of type `int`. -Refer to the following possible implementation for your starting point: +Refer to the following reference implementation for your starting point: `smartcontract.hpp file` @@ -43,12 +43,10 @@ class [[eosio::contract]] smartcontract : public eosio::contract { ## Procedure -Complete the following steps to implement an action that is iterating through the first N `person` objects in `kv map` and prints their first and last names: +Complete the following steps to implement an action which iterates through the first N `person` objects in the `kv map` and prints their first and last names: 1. Create a new action `iterate`, which takes as an input parameter the number of iterations to be executed. -2. - -Refer to the following possible implementation to implement an action that is iterating through the first `iterations_count` objects in `my_map` and prints their first and last names: +2. Refer to the following reference implementation to implement an action which iterates through the first `iterations_count` objects in `my_map` and prints their first and last names: `smartcontract.hpp file` diff --git a/docs/06_how-to-guides/30_key-value-api/kv_map/70_how-to-find-in-kv-map.md b/docs/06_how-to-guides/30_key-value-api/kv_map/70_how-to-find-in-kv-map.md index 6d8b78fcef..ad3ffc4cd6 100644 --- a/docs/06_how-to-guides/30_key-value-api/kv_map/70_how-to-find-in-kv-map.md +++ b/docs/06_how-to-guides/30_key-value-api/kv_map/70_how-to-find-in-kv-map.md @@ -9,14 +9,14 @@ This how-to provides instructions to find an object in `Key-Value Map` (`kv map` ## Before you begin -Complete the following prerequisites: +Make sure you have the following prerequisites in place: * An EOSIO development environment, for details consult the [Get Started Guide](https://developers.eos.io/welcome/latest/getting-started-guide/index) * A smart contract named `smrtcontract` * A user defined type named `person`, which defines the data stored in the map * A `kv map` object, name `my_map`, which stores objects of type `person`, with unique keys of type `int`. -Refer to the following possible implementation for your starting point: +Refer to the following reference implementation for your starting point: `smartcontract.hpp file` @@ -48,7 +48,7 @@ Complete the following steps to find a `person` object with a given ID: 1. Create a new action in your contract, named `delete`, which takes as input parameters the person ID. 2. Use the `find()` function defined for the `kv::map` type, with the give ID as parameter, to find the `person` with the given ID as unique key. -Refer to the following possible implementation to find `person` object with a given ID as unique key: +Refer to the following reference implementation to find `person` object with a given ID as unique key: `smartcontract.hpp file` diff --git a/docs/06_how-to-guides/30_key-value-api/kv_map/90_how-to-allow-users-to-pay-kv-map.md b/docs/06_how-to-guides/30_key-value-api/kv_map/90_how-to-allow-users-to-pay-kv-map.md index fc2b5336c1..ba5943fa1e 100644 --- a/docs/06_how-to-guides/30_key-value-api/kv_map/90_how-to-allow-users-to-pay-kv-map.md +++ b/docs/06_how-to-guides/30_key-value-api/kv_map/90_how-to-allow-users-to-pay-kv-map.md @@ -1,20 +1,20 @@ --- -content_title: How-To Allow Users to Pay for Key-Value Map Resources -link_text: "How-To Allow Users to Pay for Key-Value Map Resources" +content_title: How-To Create An Action Which Requires The User To Pay +link_text: "How-To Create An Action Which Requires The User To Pay" --- ## Overview -This how-to provides instructions to allow users to pay for the resources needed to store data in a `Key-Value Map` (`kv map`). +This guide provides instructions which show you how to create an action which requires the user to pay for the resources needed to store data in a `Key-Value Map` (`kv map`). -Complete the following prerequisites: +Make sure you have the following prerequisites in place: * An EOSIO development environment, for details consult the [Get Started Guide](https://developers.eos.io/welcome/latest/getting-started-guide/index) * A smart contract named `smrtcontract` * A user defined type named `person`, which defines the data stored in the map * A `kv map` object, name `my_map`, which stores objects of type `person`, with unique keys of type `int`. -Refer to the following possible implementation for your starting point: +Refer to the following reference implementation for your starting point: `smartcontract.hpp file` @@ -41,13 +41,13 @@ class [[eosio::contract]] smartcontract : public eosio::contract { ## Procedure -Complete the following steps to allow the payer for the resources needed to store the `person` object in the `my_map` object, to be the person account which is stored. +Complete the following steps to create an action which requires the `person`'s account, which is stored in the map, to pay for the resources needed to store the `person` object in the `my_map` object. 1. Create a new action in your contract, named `upsert`, which takes as input parameters the person `id`, an `account_name`, a `first_name` and a `last_name`. 2. Create an instance of the `person` class, named `person_upsert`, based on the input parameters: `account_name`, `first_name` and `last_name`. 3. Use the `[]` operator defined for the `kv::map` type. Pass as the input parameter for the `[]` operator an `std::pair` instance with its first parameter the unique `id` and the second parameter the account which is paying for the resources `account_name`. -Refer to the following possible implementation to insert a new `person` object, and then update it, in the `kv map`: +Refer to the following reference implementation to insert a new `person` object, and then update it, in the `kv map`: `smartcontract.hpp file` @@ -104,7 +104,7 @@ void smartcontract::upsert( ## Summary -In conclusion, the above instructions show how to allow users to pay for the resources needed to store data in a `Key-Value Map` (`kv map`). +In conclusion, the above instructions show how to require the user to pay for the resources needed to store data in a `Key-Value Map` (`kv map`). ## Next Steps diff --git a/docs/06_how-to-guides/30_key-value-api/kv_table/10_how-to-use-kv-table.md b/docs/06_how-to-guides/30_key-value-api/kv_table/10_how-to-use-kv-table.md index 94ada5b62b..60516007aa 100644 --- a/docs/06_how-to-guides/30_key-value-api/kv_table/10_how-to-use-kv-table.md +++ b/docs/06_how-to-guides/30_key-value-api/kv_table/10_how-to-use-kv-table.md @@ -14,13 +14,13 @@ To accomplish this task, define the user type which will be stored in the `kv ta ## Before you begin -Complete the following prerequisites: +Make sure you have the following prerequisites in place: * An EOSIO development environment, for details consult the [Get Started Guide](https://developers.eos.io/welcome/latest/getting-started-guide/index). * A smart contract named `smrtcontract`. * A user defined type named `person`, which defines the data stored in the table. -Refer to the following possible implementation for your starting point: +Refer to the following reference implementation for your starting point: `smartcontract.hpp file` diff --git a/docs/06_how-to-guides/30_key-value-api/kv_table/20_how-to-create-indexes-kv-table.md b/docs/06_how-to-guides/30_key-value-api/kv_table/20_how-to-create-indexes-kv-table.md index b83ebe676b..1da41d3cb0 100644 --- a/docs/06_how-to-guides/30_key-value-api/kv_table/20_how-to-create-indexes-kv-table.md +++ b/docs/06_how-to-guides/30_key-value-api/kv_table/20_how-to-create-indexes-kv-table.md @@ -19,7 +19,7 @@ The `KV_NAMED_INDEX` macro and the `eosio::kv::table::index` template class are ## Before you begin -Complete the following prerequisites: +Make sure you have the following prerequisites in place: * An EOSIO development environment, for details consult the [Get Started Guide](https://developers.eos.io/welcome/latest/getting-started-guide/index) * A smart contract named `smrtcontract` @@ -31,7 +31,7 @@ Complete the following prerequisites: * `last_name`, * `personal_id`. -Refer to the following possible implementation for your starting point: +Refer to the following reference implementation for your starting point: `smartcontract.hpp file` @@ -61,7 +61,7 @@ class [[eosio::contract]] smrtcontract : public contract { 3. Pass the name of the property for which the index is defined as the second parameter. 4. Call `init()` of the base class in the constructor of `address_table` type and pass the contract name as the first parameter and the primary index defined previously as the second parameter. -Refer to the following possible implementation of a unique index on property `account_name` using macro `KV_NAMED_INDEX`: +Refer to the following reference implementation of a unique index on property `account_name` using macro `KV_NAMED_INDEX`: `smartcontract.hpp file` @@ -86,7 +86,7 @@ class [[eosio::contract]] smrtcontract : public contract { 2. Pass the name of the index as the first parameter. The parameter must be a qualified `eosio:name`. See documentation for the [eosio name restrictions](https://developers.eos.io/welcome/latest/glossary/index#account-name). 3. Pass the reference to the property for which the index is defined, `&person::personal_id`, as the second parameter. -Refer to the following possible implementation of a unique index on property `personal_id` using `eosio::kv::table::index` template class: +Refer to the following reference implementation of a unique index on property `personal_id` using `eosio::kv::table::index` template class: `smartcontract.hpp file` @@ -115,7 +115,7 @@ class [[eosio::contract]] smrtcontract : public contract { The property used for the second parameter must be of template type `std::tuple`. The first parameter must be the type of the property indexed non-uniquely, in our case the type `std::string` is used because `first_name` is the property indexed non-uniquely. And the last parameter of the tuple type must be the type of a property name which is unique. In our case the type `eosio::name` is used because property `account_name` is unique. Multiple properties can be indexed non-uniquely as well. In this case the first parameters types correspond to the properties being indexed. And, as previously already mentioned, the last parameter correspond to the type of a property name which is unique. -Refer to the following possible implementation of a non-unique index on property `account_name` using macro `KV_NAMED_INDEX`: +Refer to the following reference implementation of a non-unique index on property `account_name` using macro `KV_NAMED_INDEX`: `smartcontract.hpp file` @@ -149,7 +149,7 @@ class [[eosio::contract]] smrtcontract : public contract { The property used for the second parameter must be of template type `std::tuple`. The first parameter must be the type of the property indexed non-uniquely, in our case the type `std::string` is used because `first_name` is the property indexed non-uniquely. And the last parameter of the tuple type must be the type of a property name which is unique. In our case the type `eosio::name` is used because property `account_name` is unique. Multiple properties can be indexed non-uniquely as well. In this case the first parameters types correspond to the properties being indexed. And, as previously already mentioned, the last parameter correspond to the type of a property name which is unique. -Refer to the following possible implementation of a non-unique index on property `last_name` using `eosio::kv::table::index` template class: +Refer to the following reference implementation of a non-unique index on property `last_name` using `eosio::kv::table::index` template class: `smartcontract.hpp file` diff --git a/docs/06_how-to-guides/30_key-value-api/kv_table/30_how-to-upsert-into-kv-table.md b/docs/06_how-to-guides/30_key-value-api/kv_table/30_how-to-upsert-into-kv-table.md index 9e0bfe7ea3..f9cda5a238 100644 --- a/docs/06_how-to-guides/30_key-value-api/kv_table/30_how-to-upsert-into-kv-table.md +++ b/docs/06_how-to-guides/30_key-value-api/kv_table/30_how-to-upsert-into-kv-table.md @@ -14,14 +14,14 @@ Use the method `put` defined by the `eosio::kv::table` type to accomplish this t ## Before you begin -Complete the following prerequisites: +Make sure you have the following prerequisites in place: * An EOSIO development environment, for details consult the [Get Started Guide](https://developers.eos.io/welcome/latest/getting-started-guide/index) * A smart contract named `smrtcontract` * A user defined type named `person`, which defines the data stored in the table * A `kv table` type which stores objects of type `person`, named `address_table`. The primary index of the `kv table` is defined based on the `person::account_name` property. -Refer to the following possible implementation for your starting point: +Refer to the following reference implementation for your starting point: `smartcontract.hpp file` @@ -57,7 +57,7 @@ Complete the following steps to insert a new `person` object, and then update it 2. In the `upsert` action access the instance of `address_table` by declaring a local variable of `address_table` type. 3. And then call the `put` method of the `address_table` and pass to it a newly created `person` object based on the action’s input parameters. -Refer to the following possible implementation to insert a new `person` object, and then update it, in the `kv table`: +Refer to the following reference implementation to insert a new `person` object, and then update it, in the `kv table`: `smartcontract.hpp file` diff --git a/docs/06_how-to-guides/30_key-value-api/kv_table/40_how-to-delete-from-kv-table.md b/docs/06_how-to-guides/30_key-value-api/kv_table/40_how-to-delete-from-kv-table.md index 5f21c20ecf..37f9e37f58 100644 --- a/docs/06_how-to-guides/30_key-value-api/kv_table/40_how-to-delete-from-kv-table.md +++ b/docs/06_how-to-guides/30_key-value-api/kv_table/40_how-to-delete-from-kv-table.md @@ -14,14 +14,14 @@ Use the method `erase` defined by the `eosio::kv::table` type to accomplish this ## Before you begin -Complete the following prerequisites: +Make sure you have the following prerequisites in place: * An EOSIO development environment, for details consult the [Get Started Guide](https://developers.eos.io/welcome/latest/getting-started-guide/index) * A smart contract named `smrtcontract` * A user defined type named `person`, which defines the data stored in the table * A `kv table` type which stores objects of type `person`, named `address_table`. The primary index of the `kv table` is defined based on the `person::account_name` property. -Refer to the following possible implementation for your starting point: +Refer to the following reference implementation for your starting point: `smartcontract.hpp file` @@ -57,7 +57,7 @@ Complete the following steps to delete a `person` object from `address_table`: 2. In the `delete` action access the instance of `address_table` by declaring a local variable of `address_table` type. 3. Call the `erase` method of the `address_table` and pass to it the primary key for the object which is deleted. If you try to erase an object which is not present in the `kv table` no error will be raised. -Refer to the following possible implementation to delete a `person` object from `address_table`: +Refer to the following reference implementation to delete a `person` object from `address_table`: `smartcontract.hpp file` diff --git a/docs/06_how-to-guides/30_key-value-api/kv_table/50_how-to-iterate-kv-table.md b/docs/06_how-to-guides/30_key-value-api/kv_table/50_how-to-iterate-kv-table.md index 38cb5ace6d..0e4575def4 100644 --- a/docs/06_how-to-guides/30_key-value-api/kv_table/50_how-to-iterate-kv-table.md +++ b/docs/06_how-to-guides/30_key-value-api/kv_table/50_how-to-iterate-kv-table.md @@ -14,7 +14,7 @@ Use the `iterator` defined by the `eosio::kv::table::index` class to accomplish ## Before you begin -Complete the following prerequisites: +Make sure you have the following prerequisites in place: * An EOSIO development environment, for details consult the [Get Started Guide](https://developers.eos.io/welcome/latest/getting-started-guide/index). * A smart contract named `smrtcontract`. @@ -27,7 +27,7 @@ Complete the following prerequisites: * `personal_id`. * A unique index, named `account_name_uidx`, defined on the `account_name` property.. -Refer to the following possible implementation for your starting point: +Refer to the following reference implementation for your starting point: `smartcontract.hpp file` @@ -57,7 +57,7 @@ class [[eosio::contract]] smrtcontract : public contract { ## Procedure -Complete the following steps to implement an action that is iterating through the first N `person` objects in `address_table` and prints their first and last names: +Complete the following steps to implement an action which iterates through the first N `person` objects in `address_table` and prints their first and last names: 1. Create a new action `iterate`, which takes as an input parameter the number of iterations to be executed. 2. In the `iterate` action access the instance of `address_table` by declaring a local variable of `address_table` type. @@ -65,7 +65,7 @@ Complete the following steps to implement an action that is iterating through th 4. Use the iterator `value` to access the current value of the iterator. 5. And then increment the iterator until the first N `person` objects stored in `address_table` are visited. -Refer to the following possible implementation to implement an action that is iterating through the first N `person` objects in `address_table` and prints their first and last names: +Refer to the following reference implementation to implement an action which iterates through the first N `person` objects in `address_table` and prints their first and last names: `smartcontract.hpp` diff --git a/docs/06_how-to-guides/30_key-value-api/kv_table/60_how-to-check-a-record-kv-table.md b/docs/06_how-to-guides/30_key-value-api/kv_table/60_how-to-check-a-record-kv-table.md index 6f4d33104f..58da59df1a 100644 --- a/docs/06_how-to-guides/30_key-value-api/kv_table/60_how-to-check-a-record-kv-table.md +++ b/docs/06_how-to-guides/30_key-value-api/kv_table/60_how-to-check-a-record-kv-table.md @@ -14,7 +14,7 @@ Use the method `exists` defined by the `eosio::kv::table::index` class to accom ## Before you begin -Complete the following prerequisites: +Make sure you have the following prerequisites in place: * An EOSIO development environment, for details consult the [Get Started Guide](https://developers.eos.io/welcome/latest/getting-started-guide/index). * A smart contract named `smrtcontract`. @@ -27,7 +27,7 @@ Complete the following prerequisites: * `personal_id`. * A unique index, named `account_name_uidx`, defined on the `account_name` property.. -Refer to the following possible implementation for your starting point: +Refer to the following reference implementation for your starting point: `smartcontract.hpp file` @@ -63,7 +63,7 @@ Complete the following steps to implement an action that is verifying whether a 2. In the `verify` action access the instance of `address_table` by declaring a local variable of `address_table` type. 3. Call the `exists()` method of the `account_name` index defined in the `kv table` class and pass the account name of the person to be verified. -Refer to the following possible implementation to implement an action that is verifying whether a particular `person` identified by its `account_name` exists in the `address_table`: +Refer to the following reference implementation to implement an action that is verifying whether a particular `person` identified by its `account_name` exists in the `address_table`: `smartcontract.hpp` diff --git a/docs/06_how-to-guides/30_key-value-api/kv_table/70_how-to-find-in-kv-table.md b/docs/06_how-to-guides/30_key-value-api/kv_table/70_how-to-find-in-kv-table.md index 6192a387c6..d365c73cb8 100644 --- a/docs/06_how-to-guides/30_key-value-api/kv_table/70_how-to-find-in-kv-table.md +++ b/docs/06_how-to-guides/30_key-value-api/kv_table/70_how-to-find-in-kv-table.md @@ -14,7 +14,7 @@ Use the method `find()` defined by the `eosio::kv::table::index` class to accom ## Before you begin -Complete the following prerequisites: +Make sure you have the following prerequisites in place: * An EOSIO development environment, for details consult the [Get Started Guide](https://developers.eos.io/welcome/latest/getting-started-guide/index). * A smart contract named `smrtcontract`. @@ -27,7 +27,7 @@ Complete the following prerequisites: * `personal_id`. * A unique index, named `account_name_uidx`, defined on the `account_name` property.. -Refer to the following possible implementation for your starting point: +Refer to the following reference implementation for your starting point: `smartcontract.hpp file` @@ -64,7 +64,7 @@ Complete the following steps to implement an action to find a particular `person 3. Call the `find` method of the `account_name` index defined in the table and pass the account name of the person to be verified. 4. Check if the `person` was found and return it back to the caller; if person was not found return an empty `person` object. -Refer to the following possible implementation to implement an action to find a particular `person` identified by the `account_name` in the `address_table` and returns the person back to the caller: +Refer to the following reference implementation to implement an action to find a particular `person` identified by the `account_name` in the `address_table` and returns the person back to the caller: `smartcontract.hpp` diff --git a/docs/06_how-to-guides/30_key-value-api/kv_table/80_how-to-query-range-in-kv-table.md b/docs/06_how-to-guides/30_key-value-api/kv_table/80_how-to-query-range-in-kv-table.md index 852797ad53..d7f632b276 100644 --- a/docs/06_how-to-guides/30_key-value-api/kv_table/80_how-to-query-range-in-kv-table.md +++ b/docs/06_how-to-guides/30_key-value-api/kv_table/80_how-to-query-range-in-kv-table.md @@ -14,7 +14,7 @@ Use the method `range` defined by the `eosio::kv::table::index` class to accompl ## Before you begin -Complete the following prerequisites: +Make sure you have the following prerequisites in place: * An EOSIO development environment, for details consult the [Get Started Guide](https://developers.eos.io/welcome/latest/getting-started-guide/index). * A smart contract named `smrtcontract`. @@ -28,7 +28,7 @@ Complete the following prerequisites: * A unique index, named `account_name_uidx`, defined on the `account_name` property.. * A non-unique index defined on the `last_name` property, named `last_name_idx`. -Refer to the following possible implementation for your starting point: +Refer to the following reference implementation for your starting point: `smartcontract.hpp file` @@ -70,7 +70,7 @@ Complete the following steps to implement an action to retrieve a list of person 2. The second parameter is a person object with its account name equal to `the maximum possible value for an account name` and its last name the same value to filter by the persons in the `address_table`. 3. Return back to the caller the list of persons the `range()` function returns. -Refer to the following possible implementation to implement an action to retrieve a list of persons with the same name from `address_table` and return it back to the caller: +Refer to the following reference implementation to implement an action to retrieve a list of persons with the same name from `address_table` and return it back to the caller: `smartcontract.hpp` diff --git a/docs/06_how-to-guides/30_key-value-api/kv_table/90_how-to-allow-users-to-pay-kv-table.md b/docs/06_how-to-guides/30_key-value-api/kv_table/90_how-to-allow-users-to-pay-kv-table.md index 3824fcb20e..448c5d039e 100644 --- a/docs/06_how-to-guides/30_key-value-api/kv_table/90_how-to-allow-users-to-pay-kv-table.md +++ b/docs/06_how-to-guides/30_key-value-api/kv_table/90_how-to-allow-users-to-pay-kv-table.md @@ -5,7 +5,7 @@ link_text: "How-To Allow Users to Pay for Key-Value Table Resources" ## Overview -This how-to provides instructions to allow users to pay for the resources needed to store data in a `Key-Value Table` (`kv table`). +This guide provides instructions which show you how to allow users to pay for the resources needed to store data in a `Key-Value Table` (`kv table`). [[caution | Alpha version]] | `Key-Value Table` is designated as `alpha` and should not be used in production code. @@ -14,14 +14,14 @@ Use the method `put` defined by the `eosio::kv::table` type to accomplish this t ## Before you begin -Complete the following prerequisites: +Make sure you have the following prerequisites in place: * An EOSIO development environment, for details consult the [Get Started Guide](https://developers.eos.io/welcome/latest/getting-started-guide/index) * A smart contract named `smrtcontract` * A user defined type named `person`, which defines the data stored in the table * A `kv table` type which stores objects of type `person`, named `address_table`. The primary index of the `kv table` is defined based on the `person::account_name` property. -Refer to the following possible implementation for your starting point: +Refer to the following reference implementation for your starting point: `smartcontract.hpp file` @@ -57,7 +57,7 @@ Complete the following steps to allow a specific account name to be the payer fo 2. In the `upsert` action access the instance of `address_table` belonging to this contract by declaring a local variable of `address_table` type and pass the contract name as paramter. 3. And then call the `put` method of the `address_table` and pass to it a newly created `person` object based on the action’s input parameters and the payer account name. -Refer to the following possible implementation to allow a specific account name to be the payer for the resources needed to store a person object in the `kv table`: +Refer to the following reference implementation to allow a specific account name to be the payer for the resources needed to store a person object in the `kv table`: `smartcontract.hpp file` diff --git a/docs/06_how-to-guides/50_how-to-create-and-use-action-wrappers.md b/docs/06_how-to-guides/50_how-to-create-and-use-action-wrappers.md index 8c337f83b8..cce2bca91c 100644 --- a/docs/06_how-to-guides/50_how-to-create-and-use-action-wrappers.md +++ b/docs/06_how-to-guides/50_how-to-create-and-use-action-wrappers.md @@ -5,17 +5,23 @@ link_text: "How to create and use action wrappers" ## Overview -This how-to guide provides instructions on how to create and use an action wrapper in a smart contract. +This guide provides instructions on how to create and use an action wrapper in a smart contract. + +## Code Reference + +See the following code reference guide for action wrapper: + +* [eosio::action_wrapper](../structeosio_1_1action__wrapper). ## Before you begin -Complete the following prerequisites: +Make sure you have the following prerequisites in place: * An EOSIO development environment, for details consult the [Get Started Guide](https://developers.eos.io/welcome/latest/getting-started-guide/index). * A smart contract named `multi_index_example`, defined in file `multi_index_example.hpp`. * An action `mod` which modifies the integer value `n` stored for row with key `user`. -Refer to the following possible implementation for your starting point: +Refer to the following reference implementation for your starting point: ```cpp class [[eosio::contract]] multi_index_example : public contract { @@ -25,15 +31,9 @@ class [[eosio::contract]] multi_index_example : public contract { } ``` -## Code Reference - -See the following code reference guide for action wrapper: - -* [eosio::action_wrapper](../structeosio_1_1action__wrapper). - ## Procedure -Complete the following steps to create and use action wrapper in the smart contract: +Complete the following steps to create and use `mod_action` action wrapper for the existing `mod` action in the smart contract: 1. [Define the action wrapper](#1-define-the-action-wrapper) 2. [Use the action wrapper](#2-use-the-action-wrapper) diff --git a/docs/06_how-to-guides/60_how-to-return-values-from-actions.md b/docs/06_how-to-guides/60_how-to-return-values-from-actions.md index 40ae679320..6a5c60cf4a 100644 --- a/docs/06_how-to-guides/60_how-to-return-values-from-actions.md +++ b/docs/06_how-to-guides/60_how-to-return-values-from-actions.md @@ -10,13 +10,13 @@ In order to accomplish this, use the `return` statement and pass the desired ret ## Before you begin -Complete the following prerequisites: +Make sure you have the following prerequisites in place: * An EOSIO development environment, for details consult the [Get Started Guide](https://developers.eos.io/welcome/latest/getting-started-guide/index). * A smart contract, let’s call it `smrtcontract`, which builds without error. * An action, let’s call it `checkwithrv`, from which you want to return a value of a user defined type `action_response`. -Refer to the following possible implementation for your starting point: +Refer to the following reference implementation for your starting point: ```cpp struct action_response @@ -38,7 +38,7 @@ class [[eosio::contract]] smrtcontract : public contract { Complete the following steps to return an instance of `action_response` from the `checkwithrv` action: -1. Create an instance of `action_response` C++ defined structure. +1. Create an instance of the `action_response` C++ user defined structure. 2. Initialize its data members based on the action’s business logic. 3. Use `return` statement and pass as a parameter the instance created and initialized in previous steps. @@ -75,7 +75,7 @@ The following options are available when you complete the procedure: * Use other means (e.g. programmatically) to send the `checkwithrv` action to the smart contract and observe the returned value in the action trace. [[info | Returned values from actions availability]] -The returned values from actions are only available to the clients sending the action via the RPC API. Currently, there is no support for an inline action to be able to use the return value, because inline actions don't execute synchronously. +The action return values are only available to clients sending the action via the RPC API. Currently, there is no support for an inline action to be able to use the return value, because inline actions don't execute synchronously. ## Summary From 6ed716efae7127697c372a1178f716b390ee2458 Mon Sep 17 00:00:00 2001 From: iamveritas Date: Wed, 14 Apr 2021 14:16:31 +0300 Subject: [PATCH 9/9] updates on the payer how to --- .../kv_table/90_how-to-allow-users-to-pay-kv-table.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/06_how-to-guides/30_key-value-api/kv_table/90_how-to-allow-users-to-pay-kv-table.md b/docs/06_how-to-guides/30_key-value-api/kv_table/90_how-to-allow-users-to-pay-kv-table.md index 448c5d039e..bfe8d133f6 100644 --- a/docs/06_how-to-guides/30_key-value-api/kv_table/90_how-to-allow-users-to-pay-kv-table.md +++ b/docs/06_how-to-guides/30_key-value-api/kv_table/90_how-to-allow-users-to-pay-kv-table.md @@ -1,11 +1,11 @@ --- -content_title: How-To Allow Users to Pay for Key-Value Table Resources -link_text: "How-To Allow Users to Pay for Key-Value Table Resources" +content_title: How-To Create An Action Which Requires The User To Pay +link_text: "How-To Create An Action Which Requires The User To Pay" --- ## Overview -This guide provides instructions which show you how to allow users to pay for the resources needed to store data in a `Key-Value Table` (`kv table`). +This guide provides instructions which show you how to create an action which requires the user to pay for the resources needed to store data in a `Key-Value Table` (`kv table`). [[caution | Alpha version]] | `Key-Value Table` is designated as `alpha` and should not be used in production code. @@ -51,7 +51,7 @@ class [[eosio::contract]] smrtcontract : public contract { ## Procedure -Complete the following steps to allow a specific account name to be the payer for the resources needed to store a person object in the `kv table`: +Complete the following steps to allow the `payer` account, to be the payer for the resources needed to store a person object in the `kv table`: 1. Create a new action `upsert` in your smart contact class, which takes as input parameters an `account name, a first name, a last name, a personal id` which define a person data, and an `account name` for the payer. 2. In the `upsert` action access the instance of `address_table` belonging to this contract by declaring a local variable of `address_table` type and pass the contract name as paramter. @@ -109,7 +109,7 @@ void smrtcontract::upsert( ## Summary -In conclusion, the above instructions show how to pay for the resources needed to store data in a `Key-Value Table` (`kv table`). +In conclusion, the above instructions show how to create an action which requires the user to pay for the resources needed to store data in a `Key-Value Table` (`kv table`). ## Next Steps