Learning SmartX: How to Test a Smart Contract?
At 2018-11-04 By Yue Zhao

1. Create a python project

Select the python language and blank template. Copy the code in OEP4Sample.py to editor.

step 1.png

step 1.png

2. Compile and deploy

Step1 - Clicking the "Compile" button to compile the smart contract. ABI and AVM will be generated and Opcode will be displayed at the bottom.

compile.png

Step2 - deploy the contract

Input basic information and click the "Deploy" button.

info

The Chrome browser will open Cyano wallet automatically and a confirmation of deployment is required .

Note: You can click setting icon in the upper right corner to open setting and then select the network (Main-Net, Test-Net, Private-Net).

wallet

3. Add an account

Input your account private key (hex string) and click the "OK" button.

UI

add account

How to obtain a hex private key

Step1 - copy key, address, salt from .keystore file you download from SmartX

Step2 - use Tool panel to decrypt private key

decrypt private key

4. Test function

Step1 - select network and contract hash

Note: You can also select "other" option and input an existing contract hash.

Step2- select functions, run type, and sign account

Note: your account should have enough balance to guarantee the contract execution.

test UI

Step3 -run

Execution result will be printed in logs.

Successful execution:

result