เริ่มต้นกับ smartpy tezos blockchain ยังงง
ลองรันโปรแกรม หลังจาก 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
ได้ผลลัพธ์บางอย่าง ต้องลองต่อไป

 



Create Date : 29 สิงหาคม 2564
Last Update : 29 สิงหาคม 2564 19:59:17 น.
Counter : 867 Pageviews.

0 comments
ชื่อ : * blog นี้ comment ได้เฉพาะสมาชิก
Comment :
 *ส่วน comment ไม่สามารถใช้ javascript และ style sheet
 

thaiger_u
Location :
  

[ดู Profile ทั้งหมด]
 ฝากข้อความหลังไมค์
 Rss Feed
 Smember
 ผู้ติดตามบล็อก : 3 คน [?]



Dancinga
@ฟรี
โปรแกรมปฏิทิน 2564 - Free android app


@ รับสอน เขียนโปรแกรม Python ระดับมัธยมปลาย
สิงหาคม 2564

1
2
3
4
5
6
7
8
9
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
30
31
 
 
All Blog