Example #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MosaicDefinitionTransaction"/> class.
 /// </summary>
 /// <param name="networkType">Type of the network.</param>
 /// <param name="version">The version.</param>
 /// <param name="deadline">The deadline.</param>
 /// <param name="fee">The fee.</param>
 /// <param name="properties">The properties.</param>
 /// <param name="mosaic">The mosaic.</param>
 /// <param name="mosaicLevy">The mosaic levy.</param>
 /// <param name="creator">The creator.</param>
 /// <param name="description">The description.</param>
 /// <exception cref="System.ArgumentNullException">
 /// properties
 /// or
 /// mosaic
 /// or
 /// creator
 /// </exception>
 public MosaicDefinitionTransaction(NetworkType.Types networkType, int version, Deadline deadline, ulong fee, MosaicProperties properties, MosaicId mosaic, MosaicLevy mosaicLevy, PublicAccount creator, string description)
 {
     TransactionType = TransactionTypes.Types.MosaicDefinition;
     Version         = version;
     Deadline        = deadline;
     NetworkType     = networkType;
     Fee             = fee == 0 ? 150000 : fee;
     Properties      = properties ?? throw new ArgumentNullException(nameof(properties));
     Mosaic          = mosaic ?? throw new ArgumentNullException(nameof(mosaic));
     Creator         = creator ?? throw new ArgumentNullException(nameof(creator));
     Description     = description;
     MosaicLevy      = mosaicLevy;
 }
Example #2
0
        public async Task Should_Create_Levy_WithPercentageFee()
        {
            var account  = Fixture.SeedAccount;
            var nonce    = MosaicNonce.CreateRandom();
            var mosaicId = MosaicId.CreateFromNonce(nonce, account.PublicAccount.PublicKey);
            var mosaicDefinitionTransaction = MosaicDefinitionTransaction.Create(
                nonce,
                mosaicId,
                Deadline.Create(),
                MosaicProperties.Create(
                    supplyMutable: true,
                    transferable: true,
                    levyMutable: false,
                    divisibility: 0,
                    duration: 0
                    ),
                Fixture.NetworkType);

            Log.WriteLine($"Going to create mosaic {mosaicDefinitionTransaction.MosaicId.HexId}");
            Log.WriteLine($"{account.PublicAccount.PublicKey}");
            Log.WriteLine($"{account.PublicAccount.Address}");

            var mosaicSupplyChangeTransaction = MosaicSupplyChangeTransaction.Create(
                Deadline.Create(),
                mosaicDefinitionTransaction.MosaicId,
                MosaicSupplyType.INCREASE,
                1000000,
                Fixture.NetworkType);

            var aggregateTransaction = AggregateTransaction.CreateComplete(
                Deadline.Create(),
                new List <Transaction>
            {
                mosaicDefinitionTransaction.ToAggregate(account.PublicAccount),
                mosaicSupplyChangeTransaction.ToAggregate(account.PublicAccount)
            },
                Fixture.NetworkType);

            var signedTransaction = account.Sign(aggregateTransaction, Fixture.GenerationHash);

            Fixture.WatchForFailure(signedTransaction);

            Log.WriteLine($"Going to announce transaction {signedTransaction.Hash}");

            await Fixture.SiriusClient.TransactionHttp.Announce(signedTransaction);

            var recipient = Account.GenerateNewAccount(Fixture.NetworkType);

            var mosaic_Id = new MosaicId(mosaicId.HexId);

            Log.WriteLine($"Mosaic Id: {mosaic_Id.HexId}");
            var mosaicLevy = ModifyMosaicLevyTransaction.Create(
                Deadline.Create(),
                mosaicDefinitionTransaction.MosaicId,
                MosaicLevy.CreateWithPercentageFee(
                    Recipient.From(recipient.Address),
                    mosaicDefinitionTransaction.MosaicId, 200),
                Fixture.NetworkType);
            var signedTransaction_mosaicLevy = account.Sign(mosaicLevy, Fixture.GenerationHash);

            Fixture.WatchForFailure(signedTransaction_mosaicLevy);
            var tx_Levy = Fixture.SiriusWebSocketClient.Listener.ConfirmedTransactionsGiven(account.Address).Take(1).Timeout(TimeSpan.FromSeconds(3000));
            await Fixture.SiriusClient.TransactionHttp.Announce(signedTransaction_mosaicLevy);

            var result_levy = await tx_Levy;

            Log.WriteLine($"Request confirmed with transaction {result_levy.TransactionInfo.Hash}");
        }
Example #3
0
 /// <summary>
 /// Creates a mosaic with a levy.
 /// </summary>
 /// <param name="networkType">Type of the network.</param>
 /// <param name="deadline">The deadline.</param>
 /// <param name="properties">The properties.</param>
 /// <param name="mosaic">The mosaic.</param>
 /// <param name="levy">The levy.</param>
 /// <param name="creator">The creator.</param>
 /// <param name="description">The description.</param>
 /// <returns>MosaicDefinitionTransaction.</returns>
 public static MosaicDefinitionTransaction CreateWithLevy(NetworkType.Types networkType, Deadline deadline, MosaicProperties properties, MosaicId mosaic, MosaicLevy levy, PublicAccount creator, string description)
 {
     return(new MosaicDefinitionTransaction(networkType, 1, deadline, 150000, properties, mosaic, levy, creator, description));
 }
Example #4
0
 public ModifyMosaicLevyTransactionBuilder SetMosaicLevy(MosaicLevy mosaicLevy)
 {
     MosaicLevy = mosaicLevy;
     return(Self());
 }