This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Run and deploy it at https://smartpy.io/ | |
import smartpy as sp | |
class User(sp.Contract): | |
# Constructor | |
def __init__(self): | |
self.init(userMap = sp.map()) # Initializes a map data structure to store user data with email as key | |
# Entry point to add new user data | |
@sp.entry_point |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import smartpy as sp | |
class TezosDevHub(sp.Contract): | |
def __init__(self, metadata): | |
self.init( | |
all_devs = sp.nat(0), | |
devs = sp.big_map(), | |
metadata = metadata | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import smartpy as sp | |
class Annonicle(sp.Contract): | |
def __init__(self, owner): | |
self.init(user = sp.map(), blog = sp.map(), owner=owner) | |
@sp.entry_point | |
def addUser(self, params): | |
self.data.user[params.publicKey] = sp.record( | |
name = params.name, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import smartpy as sp | |
class StoreValue(sp.Contract): | |
def __init__(self, value): | |
self.init(storedValue = value) | |
@sp.entry_point | |
def replace(self, params): | |
self.data.storedValue = params.value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Tests for the smart contract | |
if "templates" not in __name__: | |
@sp.add_test(name = "StoreValue") | |
def test(): | |
c1 = StoreValue(12) | |
scenario = sp.test_scenario() | |
scenario.h1("Store Value") | |
scenario += c1 | |
scenario += c1.replace(value = 15) | |
scenario.p("Some computation").show(c1.data.storedValue * 12) |