Example #1
0
        public JObject ToJson()
        {
            JObject json = new();

            json["script"]      = Script;
            json["state"]       = State;
            json["gasconsumed"] = GasConsumed.ToString();
            if (!string.IsNullOrEmpty(Exception))
            {
                json["exception"] = Exception;
            }
            try
            {
                json["stack"] = new JArray(Stack.Select(p => p.ToJson()));
            }
            catch (InvalidOperationException)
            {
                // ContractParameter.ToJson() may cause InvalidOperationException
                json["stack"] = "error: recursive reference";
            }
            if (!string.IsNullOrEmpty(Tx))
            {
                json["tx"] = Tx;
            }
            return(json);
        }
        public JObject ToJson()
        {
            JObject json = new JObject();

            json["txid"]          = TxId?.ToString();
            json["trigger"]       = Trigger;
            json["vmstate"]       = VMState;
            json["gasconsumed"]   = GasConsumed.ToString();
            json["stack"]         = Stack.Select(q => q.ToJson()).ToArray();
            json["notifications"] = Notifications.Select(q => q.ToJson()).ToArray();
            return(json);
        }