diff --git a/ethrpc_test.go b/ethrpc_test.go index a004a0a..7c9cd43 100644 --- a/ethrpc_test.go +++ b/ethrpc_test.go @@ -526,10 +526,7 @@ func (s *EthRPCTestSuite) TestSendTransaction() { httpmock.Reset() s.registerResponse(fmt.Sprintf(`"%s"`, result), func(body []byte) { s.methodEqual(body, "eth_sendTransaction") - s.paramsEqual(body, `[{ - "from": "" - }]`) - + s.paramsEqual(body,`[{}]`) }) txid, err = s.rpc.EthSendTransaction(t) diff --git a/types.go b/types.go index b90baee..1af7d63 100644 --- a/types.go +++ b/types.go @@ -41,12 +41,13 @@ type T struct { // MarshalJSON implements the json.Unmarshaler interface. func (t T) MarshalJSON() ([]byte, error) { - params := map[string]interface{}{ - "from": t.From, - } + params := map[string]interface{}{} if t.To != "" { params["to"] = t.To } + if t.From != "" { + params["from"] = t.From + } if t.Gas > 0 { params["gas"] = IntToHex(t.Gas) }