Old CodeBlockLabs
VPS Recomendation
  • Home
  • 🌹Social Media
  • 🚰Testnet Faucet List
  • 🚰Mainnet Faucet List
  • 🔥Mainnet
    • Akash
    • Arcadia (Paw)
      • Installation
      • RPC Command
      • CLI
      • Fast Sync
    • Arkhadian
      • Installation
      • Update
      • Useful Commands
    • Banano
      • Installation
      • Node Configuration
      • RPC Command
      • CLI
      • Useful Command
    • DO Network
      • Install & Update
      • RPC Documentation
    • Kadena
      • Installation
      • Mining
    • Massa
      • Installation
    • Newrl
      • Installation
      • Useful Command
      • Update
    • Q Blockchain
      • Installation
      • Block stuck?
    • RaiblocksOne
      • Installation
      • Update
      • RPC Command
    • Raicoin
      • Installation
    • SGE
      • Installation
      • Update
      • Useful Commands
  • 💎Testnet
    • 0G Labs
      • Installation
      • Useful Commands
    • 5ire Chain
      • Installation
      • WASM Contract Deployment
    • Avail
      • Installation
    • BEVM
      • Installation
        • Docker
        • Binary
    • Blockx
      • Installation
      • Useful Commands
      • Incentivized Task
    • Elys
      • Installation
      • Useful Commands
    • Empeiria
      • Installation
      • Snapshot
      • Useful Commands
        • Wallet Management
        • Validator Management
        • Node Management
        • Governance
    • Impact Protocol
      • Installation
    • Erbie (wormholes)
      • Installation
      • RPC Documentation
      • Debug
    • Inery
      • Installation
      • Create Token
      • Value Contract
      • IneryCRUD
      • IneryPHP
      • Snapshots
    • Mantra
      • Installation
      • Useful commands
    • Naruno
      • Baklava Testnet
    • Nolus Protocol
      • Installation
      • Update
      • Snapshots
      • Relayer
      • Useful Commands
    • Noria
      • Installation
      • Update
      • State Sync
      • Useful Commands
    • Nibiru
      • Installation
      • Update
      • Useful Commands
    • Nulink
      • Installation
    • Ojo Network
      • Installation
      • Update
      • Useful Commands
    • PowerLoom
      • Pretest Task
    • The Power
      • Installation
    • Transformers Chain
      • Install & Update
      • RPC Documentation
  • âš¡VPS Provider
    • Contabo
      • Links To Provider
      • Promotion / Coupon
    • Vultr
      • Link To Provider
      • Promotion / Coupon
  • 😇solution
    • Docker
    • EVM Wallet by PrivateKey
    • Multiple Go
Powered by GitBook
On this page
  • Update Dependencies
  • Unlock Wallet
  • Download Inery.cdt Tools Binary & Setup Path
  • Create Contract
  • Compile Contract
  • Push Transaction Example
  • Create new data
  • Read data
  • Update data
  • Delete data
  1. Testnet
  2. Inery

Value Contract

Update Dependencies

sudo apt update -y && sudo apt upgrade -y
sudo apt install -y make bzip2 automake libbz2-dev libssl-dev doxygen graphviz libgmp3-dev \
autotools-dev libicu-dev python2.7 python2.7-dev python3 python3-dev \
autoconf libtool curl zlib1g-dev sudo ruby libusb-1.0-0-dev \
libcurl4-gnutls-dev pkg-config patch llvm-7-dev clang-7 vim-common jq libncurses5 git

Unlock Wallet

cline wallet unlock -n YourWalletName

Download Inery.cdt Tools Binary & Setup Path

git clone https://github.com/inery-blockchain/inery.cdt
export PATH=$PATH:$HOME/inery.cdt/bin/

Create Contract

sudo nano inrcrud_contract.cpp

use code below as an example contract

#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;
 };

then CTRL + X , then Y, enter.

Compile Contract

//create new folder for compiling
mkdir inrcrud

//move contract to the folder
mv inrcrud_contract.cpp inrcrud/inrcrud.cpp

//go to compiling folder
cd inrcrud

//compile contract
inery-cpp -abigen -o inrcrud.wasm inrcrud.cpp

//set contract to your account
cline set contract AccountName $HOME/inrcrud -p AccountName --json

Push Transaction Example

Create new data

cline push action AccountName create '[1, AccountName, "My first Value Contract Record"]' -p AccountName -j

Read data

cline push action AccountName read [1] -p AccountName -j

Update data

cline push action AccountName update '[ 1,  "My first Record Modified"]' -p AccountName -j

Delete data

cline push action AccountName destroy [1] -p AccountName
PreviousCreate TokenNextIneryCRUD

Last updated 2 years ago

💎