xian-network / xian-contracting

A subset of Python for developing smart contracts on the Xian Network
https://linktr.ee/xiannetwork
GNU General Public License v3.0
48 stars 1 forks source link

as_dict function for hashes #9

Closed crosschainer closed 7 months ago

crosschainer commented 7 months ago

This is the example contract:

balances = Hash(default_value=0)

@construct
def seed(vk: str):
    balances['boi'] = 111_111_111
    balances['bob'] = 100_000
    balances['bob', 'down'] = 100_000

@export
def holders():
    return balances.as_dict()

When calling holders()

It will return a dict copy {'boi': 111111111, 'bob': 100000}

which then can be looped through. for example for airdrops