# Task 3 Inery Testnet

By [mirror.megumii.eth](https://paragraph.com/@megumii) · 2022-10-08

---

> Create Your Contract
> --------------------

_Official Docs_

[https://docs.inery.io/docs/category/tutorials/](https://docs.inery.io/docs/category/tutorials/)

*   **Download Tools**
    

`git clone https://github.com/inery-blockchain/inery.cdt`

*   **Export** `inery.cdt`
    

`nano ~/.bashrc`

Lalu paste ini kedalam file `.bashrc` taruh saja paling bawah

`export PATH="$PATH:/root/inery.cdt/bin"`

Dan simpan `CTRL+X` `Y` `Enter`

*   **Buat directory** `inrcrud`
    

`mkdir inrcrud`

*   **Pindah directory**
    

`cd inrcrud cd; source .bashrc; cd -`

*   **Buat file baru** `inrcrud.cpp`
    

`nano inrcrud.cpp`

*   **Copy semua code ini, dan paste kedalam file** `inrcrud.cpp`
    

`#include <inery/inery.hpp> #include <inery/print.hpp> #include <string> using namespace inery; using std::string; class [[inery::contract]] inrcrud : public inery::contract { public: using inery::contract::contract; [[inery::action]] void create( uint64_t id, name user, string data ) { records recordstable( _self, id ); auto existing = recordstable.find( id ); check( existing == recordstable.end(), "record with that ID already exists" ); check( data.size() <= 256, "data has more than 256 bytes" ); recordstable.emplace( _self, [&]( auto& s ) { s.id = id; s.owner = user; s.data = data; }); print( "Hello, ", name{user} ); print( "Created with data: ", data ); } [[inery::action]] void read( uint64_t id ) { records recordstable( _self, id ); auto existing = recordstable.find( id ); check( existing != recordstable.end(), "record with that ID does not exist" ); const auto& st = *existing; print("Data: ", st.data); } [[inery::action]] void update( uint64_t id, string data ) { records recordstable( _self, id ); auto st = recordstable.find( id ); check( st != recordstable.end(), "record with that ID does not exist" ); recordstable.modify( st, get_self(), [&]( auto& s ) { s.data = data; }); print("Data: ", data); } [[inery::action]] void destroy( uint64_t id ) { records recordstable( _self, id ); auto existing = recordstable.find( id ); check( existing != recordstable.end(), "record with that ID does not exist" ); const auto& st = *existing; recordstable.erase( st ); print("Record Destroyed: ", id); } private: struct [[inery::table]] record { uint64_t id; name owner; string data; uint64_t primary_key()const { return id; } }; typedef inery::multi_index<"records"_n, record> records; };`

Lalu simpan

*   **Setelah itu, Compile**
    

`inery-cpp inrcrud.cpp -o inrcrud.wasm`

![](https://storage.googleapis.com/papyrus_images/ef6d7b0498b611662719f487926cda31.png)

Cek menggunakan command `ls` apakah sudah generate file `inrcrud.abi` `inrcrud.wasm` atau belum

![](https://images.mirror-media.xyz/publication-images/drprvu41JfFiryq8GLx28.png?height=37&width=339 "null")

*   **Unlock wallet**
    

`cline wallet unlock -n NamaWallet`

*   **Lalu hubungkan akun mu Crud Contract**
    

`cline set contract NamaAkun ./ --json`

_Simpan semua_ `“block_num”` _dari transaksi mu, untuk mengecek di explorer nantinya_

![](https://images.mirror-media.xyz/publication-images/OVX07D0xN-tFxP5nsLwAA.png?height=448&width=743 "null")![Gunakan block_num untuk cek di explorer](https://images.mirror-media.xyz/publication-images/pomQo3exvZo5nbBrQyCBf.jpg?height=1002&width=1080 "null")

*   **Selanjutnya create contract**
    

`cline push action NamaAkun create '[1, "NamaAkun", "The First Contract by me"]' -p NamaAkun --json`

![](https://images.mirror-media.xyz/publication-images/3o1RUANeaA4pKve0-cJpL.png?height=324&width=833 "null")![Gunakan block_num untuk cek di explorer ](https://images.mirror-media.xyz/publication-images/vZoHDFfpGcoowXsIer8-_.jpg?height=960&width=1080 "null")

*   **Coba untuk read contract**
    

`cline push action NamaAkun read [1] -p NamaAkun --json`

![](https://images.mirror-media.xyz/publication-images/8WavMcSOukJyOve9t_134.png?height=724&width=762 "null")![Gunakan block_num untuk cek di explorer](https://images.mirror-media.xyz/publication-images/vISuawo-V7qtP-oJKv-Sb.jpg?height=854&width=1080 "null")

*   **Ubah data contract**
    

`cline push action NamaAkun update '[ 1, "First Modify to my Contract"]' -p NamaAkun --json`

![](https://images.mirror-media.xyz/publication-images/oiA2LnCV2ZhQzolYhpg5f.png?height=270&width=728 "null")![Gunakan block_num untuk cek di explorer](https://images.mirror-media.xyz/publication-images/ETRsqKowXwtnejRT3ygJC.jpg?height=906&width=1080 "null")

*   **Lakukan update data beberapa kali**
    

`cline push action NamaAkun update '[ 1, "Bebas Isi Apapun Disini"]' -p NamaAkun --json`

_Karena task nya disuruh push some transaction, jadi jangan cuma update sekali_

![](https://images.mirror-media.xyz/publication-images/vmWj6x4f050ypxTcKFU43.jpg?height=742&width=1079 "null")![Gunakan block_num untuk cek di explorer](https://images.mirror-media.xyz/publication-images/7UF_FFxIsKfGWNhlMWmVt.jpg?height=953&width=1080 "null")

*   **Create Token menggunakan** `ID` **yang berbeda**
    

`cline push action NamaAkun create '["2", "NamaAkun", "1000000.0000 YUHUU"]' -p NamaAkun --json`

![](https://images.mirror-media.xyz/publication-images/fg2wLfXUhtMA9ebYrbXbA.png?height=297&width=724 "null")![Gunakan block_num untuk cek di explorer](https://images.mirror-media.xyz/publication-images/SupeIqTcn5c4PYTyK1FOO.jpg?height=986&width=1080 "null")

*   **Cobalah untuk mencetak beberapa token sepeti task 2**
    

`cline push action NamaAkun issue '["2", "NamaAkun", "1000000.0000 YUHUU", "YO!"]' -p NamaAkun --json`

Akan muncul error karena tidak ada fungsi `issue` didalam contract dan juga tidak dapat di transfer

![](https://images.mirror-media.xyz/publication-images/_JnLosvTy67n8SZgK_xvf.png?height=59&width=959 "null")

*   **Langkah terakhir, cobalah untuk menghapus token di ID 2. Ini bisa dihapus karena ada fungsi** `destoy` **didalam contract**
    

`cline push action NamaAkun destroy [2] -p NamaAkun --json`

![](https://images.mirror-media.xyz/publication-images/AvmIVZM6a1IlFyRDKTC9v.png?height=240&width=642 "null")![ILANG](https://images.mirror-media.xyz/publication-images/51yCgXX-YNOe8tC6R-cQ6.jpg?height=1146&width=1080 "null")

UDAH
----

Kalo ngga di approve ku update lagi kapan-kapan💜

[https://megumii.tez.page](https://megumii.tez.page)

[collect://](collect://)

[subscribe://](subscribe://)

---

*Originally published on [mirror.megumii.eth](https://paragraph.com/@megumii/task-3-inery-testnet)*
