How to interact with EOS smart contract with Cleos and Scatter
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 *
owner: account name will store data.
data: all passwords information of the owner.
timestamp: epoch time in seconds
* 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:
- Go to https://bloks.io/
- Login with
Scatter
- Search
trongdthdapp
account and chooseContract
then. You will see something like this
- Choose
Actions
and fill your data inadd
method and pressPush Transaction
Reference:
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.