/// <summary> /// Generate a create asset transaction /// </summary> /// <param name="asset">The asset infomation</param> /// <param name="trans">The blockchain infomation</param> /// <param name="message">The message for the transaction(have no affect to the assect)</param> /// <param name="decimals">A value of 0 represents an asset that is not divisible, /// while a value of 1 represents an asset that is divisible into tenths and so on, i.e, /// the number of digits to display after the decimal place when displaying the asset. /// This value must be between 0 and 19</param> /// <returns>transaction</returns> public static Transaction GetCreateAssetTransaction(AssetParams asset, TransactionParams trans, string message = "", int decimals = 0) { ValidateAsset(asset); // assetDecimals is not exist in api, so set as zero in this version var tx = Transaction.CreateAssetCreateTransaction(new Address(asset.Creator), trans.Fee, trans.LastRound, trans.LastRound + 1000, Encoding.UTF8.GetBytes(message), trans.GenesisID, new Digest(trans.Genesishashb64), asset.Total, decimals, (bool)asset.Defaultfrozen, asset.Unitname, asset.Assetname, asset.Url, Convert.FromBase64String(asset.Metadatahash), new Address(asset.Managerkey), new Address(asset.Reserveaddr), new Address(asset.Freezeaddr), new Address(asset.Clawbackaddr)); Account.SetFeeByFeePerByte(tx, trans.Fee); return(tx); }
/// <summary> /// Initializes a new instance of the <see cref="Asset" /> class. /// </summary> /// <param name="assetIndex">AssetIndex is the unique asset identifier (required).</param> /// <param name="assetParams">assetParams (required).</param> public Asset(ulong?assetIndex = default(ulong?), AssetParams assetParams = default(AssetParams)) { // to ensure "assetIndex" is required (not null) if (assetIndex == null) { throw new InvalidDataException("assetIndex is a required property for Asset and cannot be null"); } else { this.AssetIndex = assetIndex; } // to ensure "assetParams" is required (not null) if (assetParams == null) { throw new InvalidDataException("assetParams is a required property for Asset and cannot be null"); } else { this.AssetParams = assetParams; } }
private static void ValidateAsset(AssetParams asset) { if (asset.Creator is null || asset.Creator == "") { throw new ArgumentException("The sender must be specified."); }
/// <summary> /// Generate an asset config transaction /// </summary> /// <param name="sender">The sender of the transaction, should be the manager of the asset.</param> /// <param name="assetId">Asset ID</param> /// <param name="asset">Asset infomation</param> /// <param name="trans">The blockchain infomation</param> /// <param name="message">The message for the transaction(have no affect to the assect)</param> /// <returns>transaction</returns> public static Transaction GetConfigAssetTransaction(Address sender, ulong?assetId, AssetParams asset, TransactionParams trans, string message = "") { ValidateAsset(asset); //sender must be manager var tx = Transaction.CreateAssetConfigureTransaction(sender, 1, trans.LastRound, trans.LastRound + 1000, Encoding.UTF8.GetBytes(message), trans.GenesisID, new Digest(trans.Genesishashb64), assetId, new Address(asset.Managerkey), new Address(asset.Reserveaddr), new Address(asset.Freezeaddr), new Address(asset.Clawbackaddr), false); Account.SetFeeByFeePerByte(tx, trans.Fee); return(tx); }
/// <summary> /// Initializes a new instance of the <see cref="AssetConfigTransactionType" /> class. /// </summary> /// <param name="id">AssetID is the asset being configured (or empty if creating).</param> /// <param name="_params">_params.</param> public AssetConfigTransactionType(ulong?id = default(ulong?), AssetParams _params = default(AssetParams)) { this.Id = id; this.Params = _params; }