Skip to content

Instantly share code, notes, and snippets.

View shwetalsoni's full-sized avatar
👩‍💻

Shwetal Soni shwetalsoni

👩‍💻
View GitHub Profile
# 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
@shwetalsoni
shwetalsoni / TezosDeveloperHub.py
Last active July 11, 2022 21:37
Tezos Developer Hub smart contract
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
)
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,
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
# 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)