public static bool Deploy() { Runtime.Log("Deploy called"); if (!Runtime.CheckWitness(AppGlobals.FishEffectScriptHash)) { return(false); } BigInteger totalSupply = FishCoinDao.GetTotalSupply(); if (totalSupply != 0) { //Already deployed return(false); } BigInteger maximumSupply = MaxSupplyUnits * DecimalsFactor; FishCoinDao.SetTotalSupply(maximumSupply); UtilityDao.UpdateRandomStep(1); FishCoinDao.UpdateBalance(AppGlobals.FishEffectScriptHash, maximumSupply); Notifier.Transfer(null, AppGlobals.FishEffectScriptHash, maximumSupply); Runtime.Log("Deploy ok"); return(true); }
public static bool Transfer(object[] args) { Runtime.Log("Transfer called"); if (args.Length != 3) { return(false); } byte[] from = (byte[])args[0]; byte[] to = (byte[])args[1]; BigInteger value = (BigInteger)args[2]; if (from.Length == 0) { return(false); } if (to.Length == 0) { return(false); } if (!Runtime.CheckWitness(from)) { return(false); } BigInteger fromBalance = FishCoinDao.BalanceOf(from); BigInteger toBalance = FishCoinDao.BalanceOf(to); if (fromBalance < value) { return(false); } BigInteger finalFromBalance = fromBalance - value; BigInteger finalToBalance = toBalance + value; FishCoinDao.UpdateBalance(from, finalFromBalance); FishCoinDao.UpdateBalance(to, finalToBalance); //Notifier.PublishTransferNotification(from, to, value); Runtime.Log("Transfer ok"); return(true); }