1 of 26

PrettiSmart: Visual Interpretation of Smart Contracts via Simulation

Xiaolin Wen1

Tai D. Nguyen2

Yong Wang1

Lun Zhang3

Jun Sun2

2 of 26

2

Smart Contract

Traditional Contract

Sellers

Buyers

Contract

Third Parties

Execution

Smart Contract

Blockchain

Sellers

Buyers

Execution

  • Remove the need for third parties
  • More efficient and accurate
  • Immutable: cannot be altered
  • Code are available on the blockchain

3 of 26

3

Why do we need to visually interpret it?

The source code is available!

Highest Profit!

Zero Risk!

Scam Impossible!

Code is too complex!

No Existing Transactions!

Investors

4 of 26

4

Smart Contract

Source Code

Ethereum Blockchain

Smart Contract

Function Calls (Money Transfers)

Send Money (Internal Transactions)

Change State Variables

Change Balances

5 of 26

5

PrettiSmart

Possible Function Calls

What we do?

Owner

Multiple Users

Cryptocurrency Flows

Balance Changes

-100

F1

-20

F1

-80

F2

+200

F0

State Variable Changes

Variable #

Smart Contract

Investors

6 of 26

6

PrettiSmart

Input

Output

7 of 26

7

PrettiSmart

8 of 26

8

Simulation Overview

provides a visual summary for each simulation, involving the net balances over time and the involved functions

9 of 26

9

Function Summary

shows the statistics of the calls of each function in a simulation.

10 of 26

10

Function Call Details

Function Calls

Money Flows

Net Balance

demonstrates the detailed behaviors of the smart contract after each function call

11 of 26

11

State Variable Changes

Increase

Decrease

shows how the state variables are changing after each function call.

12 of 26

12

Evaluation

Case 1: Interpreting a Gambling Contract

Case 2: Identifying a Fraudulent Smart Contract

13 of 26

13

Evaluation

Case 1: Interpreting a Gambling Contract

14 of 26

14

Evaluation

Case 1: Interpreting a Gambling Contract

15 of 26

15

Evaluation

Case 1: Interpreting a Gambling Contract

16 of 26

16

Evaluation

Case 1: Interpreting a Gambling Contract

17 of 26

17

Evaluation

Case 1: Interpreting a Gambling Contract

F0: enter (send money to contract)

F1: pickWinner (send money to one user)

18 of 26

18

Evaluation

Case 1: Interpreting a Gambling Contract

19 of 26

19

Evaluation

User Interviews with 12 cryptocurrency investors

PrettiSmart is effective and useful for investors to analyze the smart contract’s functionality.

20 of 26

20

Take-away Message

  • Smart contract simulation is more easy to understand than the source code for investors.
  • Visual interpretation of smart contracts is an intuitive way to inform investors of how a smart contract works.

21 of 26

PrettiSmart: Visual Interpretation of Smart Contracts via Simulation

Xiaolin Wen1

Tai D. Nguyen2

Yong Wang1

Lun Zhang3

Jun Sun2

Paper Link

Contact Me!

Code Will Tell: Visual Identification of Ponzi Schemes on Ethereum

PonziLens+: Visualizing Bytecode Actions for Smart Ponzi Scheme Identification

PrettiSmart: Visual Interpretation of Smart Contracts via Simulation

22 of 26

22

Evaluation

Case 1: Interpreting a Gambling Contract

23 of 26

23

Evaluation

Case 2: Identifying a Fraudulent Smart Contract

24 of 26

24

Evaluation

Case 2: Identifying a Fraudulent Smart Contract

F0: buyMessage

25 of 26

25

Evaluation

Case 2: Identifying a Fraudulent Smart Contract

F1: ownerWithdraw

26 of 26

26