public static bool Transfer(UInt160 from, UInt160 to, BigInteger amount, object data = null) { if (IsPaused()) { Error("System is paused."); return(false); } if (IsBlacklisted(from)) { Error("Argument from is in blacklist."); return(false); } if (IsBlacklisted(to)) { Error("Argument to is in blacklist."); return(false); } if (amount <= 0) { Error("The parameter amount MUST be greater than 0."); return(false); } if (!Runtime.CheckWitness(from)) { Error("No authorization."); return(false); } if (AssetStorage.Get(from) < amount) { Error("Insufficient balance."); return(false); } if (from == to) { return(true); } AssetStorage.Reduce(from, amount); AssetStorage.Increase(to, amount); Transferred(from, to, amount); if (ContractManagement.GetContract(to) != null) { Contract.Call(to, "onPayment", CallFlags.ReadOnly, new object[] { from, amount, data }); } return(true); }
public static bool Burn(UInt160 minterAccount, BigInteger amount) { if (IsPaused()) { Error("System is paused."); return(false); } if (amount <= 0) { Error("The parameter amount MUST be greater than 0."); return(false); } if (!IsMinter() || !Runtime.CheckWitness(minterAccount)) { Error("No authorization."); return(false); } if (IsBlacklisted(minterAccount)) { Error("Argument account is in blacklist."); return(false); } if (AssetStorage.Get(minterAccount) < amount) { Error("Insufficient balance."); return(false); } TotalSupplyStorage.Reduce(amount); TotalBurnStorage.Increase(amount); AssetStorage.Reduce(minterAccount, amount); Transferred(minterAccount, null, amount); return(true); }
public static BigInteger BalanceOf(UInt160 account) => AssetStorage.Get(account);