How to interact with EOS smart contract with Cleos and Scatter

Trong Dinh Thai Hoang
Jun 25 · 3 min read

This is part 2 of the EOS series. If you still not have EOS account, please follow part 1: thttps://medium.com/@trongdth/how-to-create-an-eos-account-and-use-scatter-to-manage-it-4232058f0b08

In this post, I will use BlockPass Smart Contract as a sample.

Introduction BlockPass:

The only password management app that stores your data on EOS blockchain. All you need to do is use BlockPass. By using your own private key, your data are safe and never lost.

Features:
- Work in offline mode.
- Auto-sync to Blockchain.
- Add/remove your password by one touch.
- Can interact with multi-chain (Jungle TestNet, Kylin TestNet)

1. Clone + build BlockPass Smart Contract:

I’ve committed .abi and .wasm file for you. If you want to build it, here are the following steps:

git clone https://github.com/mroom-software/blockpass-smart-contract.git

cd EOS/blockpass

mkdir build

cd build

cmake ../

make

cp blockpass.abi blockpass.wasm ../

2. Deploy BlockPass Smart Contract:

cleos -u {eos_api_endpoint} set contract {contract_name} {path_to_eos_blockpass} -p {account_name}@active

Ex: cleos -u https://api-kylin.eosasia.one set contract trongdthdapp /Users/trong_pro/Workplace/MroomSoftware/blockpass/blockpass-smart-contract/EOS/blockpass -p trongdthdapp@active

3. Interact with BlockPass Smart Contract:

Basically, BlockPass Smart Contract has 2 main methods: add and del

* add method *

add method

owner: account name will store data.

data: all passwords information of the owner.

timestamp: epoch time in seconds

* del method *

del method

owner: account name who keeps the data.

Use Cleos:

cleos -u https://api-kylin.eosasia.one push action trongdthdapp add ‘{“owner”: “trongdthdapp”, “data”: “”, “timestamp”: 1561449436}’ -p trongdthdapp@active

Use Scatter:

Choose Scatter
Log into `trongdthdapp` successfully
  • Search trongdthdapp account and choose Contractthen. You will see something like this
Contract `trongdthdapp`
  • Choose Actions and fill your data in add method and press Push Transaction
Fill data to add method

Reference:

  1. https://developers.eos.io/eosio-cleos/docs
  2. https://www.eosdocs.io/resources/apiendpoints/

Notes: If you have any problem need my help, don’t hesitate to contact me at trongdinh@mroomsoft.com. Thanks and see u in next article.

Trong Dinh Thai Hoang

Written by

I’m a peaceful person who wants to make friend with people around the world.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade