// NFT version internal bool MintToken(string symbol, StorageContext storage, Chain chain, Address target, BigInteger tokenID) { if (!TokenExists(symbol)) { return(false); } var tokenInfo = GetTokenInfo(symbol); if (tokenInfo.Flags.HasFlag(TokenFlags.Fungible)) { return(false); } var supply = new SupplySheet(symbol, chain, this); if (!supply.Mint(storage, 1, tokenInfo.MaxSupply)) { return(false); } var ownerships = new OwnershipSheet(symbol); if (!ownerships.Give(storage, target, tokenID)) { return(false); } EditNFTLocation(symbol, tokenID, chain.Address, target); return(true); }
internal bool MintTokens(string symbol, StorageContext storage, BalanceSheet balances, SupplySheet supply, Address target, BigInteger amount) { if (!TokenExists(symbol)) { return(false); } var tokenInfo = GetTokenInfo(symbol); if (!tokenInfo.Flags.HasFlag(TokenFlags.Fungible)) { return(false); } if (amount <= 0) { return(false); } if (tokenInfo.IsCapped) { if (!supply.Mint(amount)) { return(false); } } if (!balances.Add(storage, target, amount)) { return(false); } EditTokenSupply(symbol, amount); return(true); }
internal bool MintTokens(string symbol, StorageContext storage, Chain chain, Address target, BigInteger amount) { if (!TokenExists(symbol)) { return(false); } var tokenInfo = GetTokenInfo(symbol); if (!tokenInfo.Flags.HasFlag(TokenFlags.Fungible)) { return(false); } if (amount <= 0) { return(false); } var supply = new SupplySheet(symbol, chain, this); if (!supply.Mint(storage, amount, tokenInfo.MaxSupply)) { return(false); } var balances = new BalanceSheet(symbol); if (!balances.Add(storage, target, amount)) { return(false); } return(true); }
internal bool MintTokens(RuntimeVM runtimeVM, string symbol, Address target, BigInteger amount) { if (!TokenExists(symbol)) { return(false); } var tokenInfo = GetTokenInfo(symbol); if (!tokenInfo.Flags.HasFlag(TokenFlags.Fungible)) { return(false); } if (amount <= 0) { return(false); } var supply = new SupplySheet(symbol, runtimeVM.Chain, this); if (!supply.Mint(runtimeVM.ChangeSet, amount, tokenInfo.MaxSupply)) { return(false); } var balances = new BalanceSheet(symbol); if (!balances.Add(runtimeVM.ChangeSet, target, amount)) { return(false); } var tokenTriggerResult = SmartContract.InvokeTrigger(runtimeVM, tokenInfo.Script, TokenContract.TriggerMint, target, amount); if (!tokenTriggerResult) { return(false); } var accountScript = this.LookUpAddressScript(target); var accountTriggerResult = SmartContract.InvokeTrigger(runtimeVM, accountScript, AccountContract.TriggerMint, target, amount); if (!accountTriggerResult) { return(false); } return(true); }
// NFT version internal bool MintToken(RuntimeVM runtimeVM, string symbol, Address target, BigInteger tokenID) { if (!TokenExists(symbol)) { return(false); } var tokenInfo = GetTokenInfo(symbol); if (tokenInfo.Flags.HasFlag(TokenFlags.Fungible)) { return(false); } var supply = new SupplySheet(symbol, runtimeVM.Chain, this); if (!supply.Mint(runtimeVM.ChangeSet, 1, tokenInfo.MaxSupply)) { return(false); } var ownerships = new OwnershipSheet(symbol); if (!ownerships.Give(runtimeVM.ChangeSet, target, tokenID)) { return(false); } var tokenTriggerResult = SmartContract.InvokeTrigger(runtimeVM, tokenInfo.Script, TokenContract.TriggerMint, target, tokenID); if (!tokenTriggerResult) { return(false); } var accountScript = this.LookUpAddressScript(target); var accountTriggerResult = SmartContract.InvokeTrigger(runtimeVM, accountScript, AccountContract.TriggerMint, target, tokenID); if (!accountTriggerResult) { return(false); } EditNFTLocation(symbol, tokenID, runtimeVM.Chain.Address, target); return(true); }