RpcSystemAssetTracker/CronContractInvoker.cs
/// <summary>
/// Allows to send system assets using a private key
/// </summary>
/// <param name="jArray">An array of parameters: 
/// [0] MANDATORY; HEX or WIF private key, string
/// [1] MANDATORY; array of objects {"address": string, "amount": decimal}.
//      At least one item is needed to send successful txn
/// [2] OPTIONAL;  asset hash (hex bytes string) or its name (string). Default is CRON 
/// [3] OPTIONAL;  remarks attribute value. Default is null 
/// [4] OPTIONAL;  system fee (decimal) . Default is zero 
/// </param>
/// <returns>an object with txn_hash field containing transaction hash</returns>
Allows to send system assets using a private key
Allows to send system assets using a private key
private JObject SendToMultipleSimple(JArray jArray)
        {
            JObject obj = new JObject();
            var privateKey = jArray[0].AsString().Split(';').Select(x => x.ToBytePrivateKey()).ToArray();
            var arrayTargets = (JArray)jArray[1];
            UInt256 th = (jArray.Count > 2) ? ParseTokenHash(jArray[2].AsString()) : Blockchain.UtilityToken.Hash;
            List<TransactionOutput> targets = new List<TransactionOutput>();
            for (int i = 0; i < arrayTargets.Count; i++)
            {
                JObject jo = arrayTargets[i];
                var addressesTo = jo["address"].AsString();
                var amount = GetDecimal(jo["amount"]);
                var target = new TransactionOutput()
                {
                    ScriptHash = addressesTo.ToScriptHash(),
                    Value = Fixed8.FromDecimal(amount),
                    AssetId = th
                };
                targets.Add(target);
            }
            byte[] bRemarks = (jArray.Count > 3) ? jArray[3].AsString().HexToBytes() : null;
            decimal systemFee = (jArray.Count > 4) ? (decimal)jArray[4].AsNumber() : 0.0m;
            KeyPair[] fromKey = privateKey.Select(x => new KeyPair(x)).ToArray();
            bool b = SendAsset(fromKey, th, targets, bRemarks, systemFee, out string txn_hash);
            obj["txn_hash"] = txn_hash;
            return obj;
        }
private JObject SendToMultipleSimple ( JArray jArray ) { JObject obj = new JObject ( ) ; var privateKey = jArray [ 0 ] . AsString ( ) . Split ( ' ' ) . Select ( x => x . ToBytePrivateKey ( ) ) . ToArray ( ) ; var arrayTargets = ( JArray ) jArray [ 1 ] ; UInt256 th = ( jArray . Count > 2 ) ? ParseTokenHash ( jArray [ 2 ] . AsString ( ) ) : Blockchain . UtilityToken . Hash ; List < TransactionOutput > targets = new List < TransactionOutput > ( ) ; for ( int i = 0 ; i < arrayTargets . Count ; i ++ ) { JObject jo = arrayTargets [ i ] ; var addressesTo = jo [ " " ] . AsString ( ) ; var amount = GetDecimal ( jo [ " " ] ) ; var target = new TransactionOutput ( ) { ScriptHash = addressesTo . ToScriptHash ( ) , Value = Fixed8 . FromDecimal ( amount ) , AssetId = th } ; targets . Add ( target ) ; } byte [ ] bRemarks = ( jArray . Count > 3 ) ? jArray [ 3 ] . AsString ( ) . HexToBytes ( ) : null ; decimal systemFee = ( jArray . Count > 4 ) ? ( decimal ) jArray [ 4 ] . AsNumber ( ) : 0.0m ; KeyPair [ ] fromKey = privateKey . Select ( x => new KeyPair ( x ) ) . ToArray ( ) ; bool b = SendAsset ( fromKey , th , targets , bRemarks , systemFee , out string txn_hash ) ; obj [ " " ] = txn_hash ; return obj ; }
Allows to send system assets using a private key
Allows to send system assets using a private key
an object with txn_hash field containing transaction hash
an object with txn_hash field containing transaction hash
jArray
JArray
An array of parameters:
[0] MANDATORY; HEX or WIF private key, string
[1] MANDATORY; array of objects {"address": string, "amount": decimal}.
At least one item is needed to send successful txn
[2] OPTIONAL;  asset hash (hex bytes string) or its name (string). Default is CRON
[3] OPTIONAL;  remarks attribute value. Default is null
[4] OPTIONAL;  system fee (decimal) . Default is zero
An array of parameters : [ 0 ] MANDATORY ; HEX or WIF private key string [ 1 ] MANDATORY ; array of objects { " address " : string " amount " : decimal } . At least one item is needed to send successful txn [ 2 ] OPTIONAL ; asset hash ( hex bytes string ) or its name ( string ) . Default is CRON [ 3 ] OPTIONAL ; remarks attribute value . Default is null [ 4 ] OPTIONAL ; system fee ( decimal ) . Default is zero