Skip to main content

Smart Contract Interactions using clio

Overview

In the article you’ll learn how to execute actions on a contract with the clio tool. It guides you through inserting and updating records, checking updates, and testing out behavior on unauthorized change attempt.

Prerequisites

clio create account sysio jack $PUBLIC_KEY -p sysio@active 
clio create account sysio nick $PUBLIC_KEY -p sysio@active

Steps

Step 1: Insert a record

First, let’s have Jack insert or update his own record.

clio push action company upsertemp '["jack", "Jack Sparrow", "[email protected]", "active"]' -p jack@active

Output:

create-record

You could use block explorer to inspect the table and the transactions.

be-table-check

Step 2: Perfom an update

Next, we update Jack’s record,

clio push action company upsertemp '["jack", "Jack Nicholson", "[email protected]", "active"]' -p jack@active

Output:

update-record

Post-Action Check:

• Inspect Logs to ensure the update was executed. • Inspect Table to see Jack’s updated record.

Step 3: Retrieve all users

clio push action company getallemp '{}' -p jack@active

Ouput:

retrieve-records

Step 4: Attempt unauthorized transaction

clio push action company upsertemp '["nick", "Nick Fury", "[email protected]", "active"]' -p jack@active

This should fail since Jack should not be able to add records for other users because the contract enforces proper authorization via require_auth().

unauthorized

To insert Nick's record execute the following command:

clio push action company upsertemp '["nick", "Nick Fury", "[email protected]", "active"]' -p nick@active