public static bool Transfer(byte[] from, byte[] to, BigInteger amount) { if (!ValidateAddress(from) || !ValidateAddress(to)) { throw new Exception("The parameters from and to SHOULD be 20-byte addresses."); } if (amount <= 0) { throw new Exception("The parameter amount MUST be greater than 0."); } if (!IsPayable(to)) { throw new Exception("Receiver cannot receive."); } if (!Runtime.CheckWitness(from) && !from.Equals(ExecutionEngine.CallingScriptHash)) { throw new Exception("No authorization."); } if (AssetStorage.Get(from) < amount) { throw new Exception("Insufficient balance."); } if (amount == 0 || from == to) { return(true); } AssetStorage.Reduce(from, amount); AssetStorage.Increase(to, amount); OnTransfer(from, to, amount); return(true); }
private static readonly byte[] Owner = "NfKA6zAixybBHHpmaPYPDywoqDaKzfMPf9".ToScriptHash(); //Owner Address public static bool Deploy() { if (TotalSupply() != 0) { return(false); } TotalSupplyStorage.Increase(TotalSupplyValue); AssetStorage.Increase(Owner, TotalSupplyValue); OnTransfer(null, Owner, TotalSupplyValue); return(true); }
public static BigInteger BalanceOf(byte[] account) => AssetStorage.Get(account);