0x5d7bab56…f750sent to0xb7278a61…e575·#24,763,073·view on Etherscan
# { "Depends": "py-genlayer:test" }
from genlayer import *
class Contract(gl.Contract):
shipments: gl.storage.TreeMap[str, str]
def __init__(self):
self.shipments = gl.storage.TreeMap()
@gl.public.write
def register_package(self, package_id: str, destination: str):
import json
data = json.dumps({
"package_id": package_id,
"destination": destination,
"delivered": False,
"verdict": "Pending"
})
self.shipments[package_id] = data
@gl.public.view
def get_shipment(self, package_id: str) -> str:
import json
assert package_id in self.shipments, "Package not found"
return self.shipments[package_id]