Learning SmartX: How to Test a Smart Contract

Learning SmartX: How to Test a Smart Contract


Version 0.1

1. Create a python project

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

Learning SmartX: How to Test a Smart Contract_第1张图片
step 1.png
Learning SmartX: How to Test a Smart Contract_第2张图片
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.

Learning SmartX: How to Test a Smart Contract_第3张图片
compile.png

Step2 - deploy the contract

Input basic information and click the "Deploy" button.

Learning SmartX: How to Test a Smart Contract_第4张图片
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).

Learning SmartX: How to Test a Smart Contract_第5张图片
wallet

2. Add an account

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

Learning SmartX: How to Test a Smart Contract_第6张图片
UI
Learning SmartX: How to Test a Smart Contract_第7张图片
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

Learning SmartX: How to Test a Smart Contract_第8张图片
decrypt private key

3. Test function

Step1 - select network and contract hash

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.

Learning SmartX: How to Test a Smart Contract_第9张图片
test UI

Step3 -run

Execution result will be printed in logs.

Successful execution:

result

你可能感兴趣的:(Learning SmartX: How to Test a Smart Contract)