diff --git a/Thirdweb/Thirdweb.RPC/RpcError.cs b/Thirdweb/Thirdweb.RPC/RpcError.cs index 2f43c74..1d98691 100644 --- a/Thirdweb/Thirdweb.RPC/RpcError.cs +++ b/Thirdweb/Thirdweb.RPC/RpcError.cs @@ -9,5 +9,8 @@ public class RpcError [JsonProperty("message")] public string Message { get; set; } + + [JsonProperty("data")] + public object Data { get; set; } } } diff --git a/Thirdweb/Thirdweb.RPC/ThirdwebRPC.cs b/Thirdweb/Thirdweb.RPC/ThirdwebRPC.cs index 93b07cd..6d545d5 100644 --- a/Thirdweb/Thirdweb.RPC/ThirdwebRPC.cs +++ b/Thirdweb/Thirdweb.RPC/ThirdwebRPC.cs @@ -170,7 +170,19 @@ private async Task SendBatchAsync(List batch) { if (rpcResponse.Error != null) { - tcs.SetException(new Exception($"RPC Error for request {rpcResponse.Id}: {rpcResponse.Error.Message}")); + var revertMsg = ""; + if (rpcResponse.Error.Data != null) + { + try + { + revertMsg = new Nethereum.ABI.FunctionEncoding.FunctionCallDecoder().DecodeFunctionErrorMessage(Utils.StringToHex(rpcResponse.Error.Data.ToString())); + } + catch + { + revertMsg = rpcResponse.Error.Data.ToString(); + } + } + tcs.SetException(new Exception($"RPC Error for request {rpcResponse.Id}: {rpcResponse.Error.Message} {revertMsg}")); } else {