ลองรันโปรแกรม หลังจาก pip install smartpy แล้ว
# SmartPy Code
import smartpy as sp
class StoreValue(sp.Contract):
def __init__(self, value):
self.init(storedValue = value)
@sp.entry_point
def replace(self, value):
self.data.storedValue = value
@sp.entry_point
def double(self):
self.data.storedValue *= 2
@sp.add_test(name = "StoreValue")
def test():
scenario = sp.test_scenario()
scenario.h1("Store Value")
contract = StoreValue(1)
scenario += contract
scenario += contract.replace(2)
scenario += contract.double()
มี error ว่า "py1101.py", line 4, in
class StoreValue(sp.Contract):
AttributeError: module 'smartpy' has no attribute 'Contract'
เลยไปลองเล่นในเวบ https://smartpy.io/ แล้วไปที่ online editor
แล้วเลือกตัวอย่างเป็น template calculator แล้วลอง test run
ได้ผลลัพธ์บางอย่าง ต้องลองต่อไป