put
def put(_owner, _asset, _var, _value, _key = None):Parameters
Example
def mint(info, args):
# The sender must be the admin of the asset
admin = info['sender']
# Arguments for the mint function
receiver_handle = args[0]
amount = int(args[1])
# Ensure the amount is positive
assert amount > 0, "Cannot mint a zero or negative amount."
# Get the current total supply
total_supply = get("ZENT", "total_supply", 0)
new_total_supply = total_supply + amount
# Get the receiver's current balance
receiver_balance = get("ZENT", "balance", 0, receiver_handle)
new_receiver_balance = receiver_balance + amount
# Update the state using put
# The admin (sender) authorizes the change
put(admin, "ZENT", "total_supply", new_total_supply)
put(admin, "ZENT", "balance", new_receiver_balance, receiver_handle)
print(f"Successfully minted {amount} ZENT to {receiver_handle}.")Last updated