Repository: ethereum/web3.py

Issue:
ContractConstructor.buildTransaction() adds invalid "to" into transaction
* Version: 4.2.0
* Python: 3.6
* OS: linux


### What was wrong?

When I want to deploy a contract, and I use ContractConstructor.buildTransaction() to create the bytecode data first, it returns a dictionary with a correct data, but there is a field added: `'to': b''`. Later when I use web3.personal.sendTransaction to actually send this, it fails because of this "to" field, with an error: `TypeError: Address b'' must be provided as a string`

```python
contract_constructor = web3.eth.contract(
	abi=contract_interface['abi'],
	bytecode=contract_interface['bin']
).constructor()
transaction = {
	'from': wallet_address,
	'gasPrice': web3.eth.gasPrice
}
transaction['gas'] = contract_constructor.estimateGas(transaction)
transaction = contract_constructor.buildTransaction(transaction)
web3.personal.sendTransaction(transaction, password)
```
Result:
```
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.6/dist-packages/web3/personal.py", line 30, in sendTransaction
    [transaction, passphrase],
  File "/usr/local/lib/python3.6/dist-packages/web3/manager.py", line 103, in request_blocking
    response = self._make_request(method, params)
  File "/usr/local/lib/python3.6/dist-packages/web3/manager.py", line 86, in _make_request
    return request_func(method, params)
  File "/usr/local/lib/python3.6/dist-packages/web3/middleware/gas_price_strategy.py", line 18, in middleware
    return make_request(method, params)
  File "/usr/local/lib/python3.6/dist-packages/web3/middleware/formatting.py", line 21, in middleware
    response = make_request(method, formatted_params)
  File "/usr/local/lib/python3.6/dist-packages/web3/middleware/attrdict.py", line 18, in middleware
    response = make_request(method, params)
  File "/usr/local/lib/python3.6/dist-packages/web3/middleware/formatting.py", line 23, in middleware
    response = make_request(method, params)
  File "/usr/local/lib/python3.6/dist-packages/web3/middleware/normalize_errors.py", line 9, in middleware
    result = make_request(method, params)
  File "/usr/local/lib/python3.6/dist-packages/web3/middleware/validation.py", line 45, in middleware
    return make_request(method, params)
  File "/usr/local/lib/python3.6/dist-packages/web3/middleware/formatting.py", line 20, in middleware
    formatted_params = formatter(params)
  File "cytoolz/functoolz.pyx", line 236, in cytoolz.functoolz.curry.__call__
  File "cytoolz/functoolz.pyx", line 232, in cytoolz.functoolz.curry.__call__
  File "/usr/local/lib/python3.6/dist-packages/eth_utils/functional.py", line 22, in inner
    return callback(fn(*args, **kwargs))
  File "/usr/local/lib/python3.6/dist-packages/web3/utils/formatters.py", line 43, in apply_formatter_at_index
    yield formatter(item)
  File "cytoolz/functoolz.pyx", line 236, in cytoolz.functoolz.curry.__call__
  File "cytoolz/functoolz.pyx", line 232, in cytoolz.functoolz.curry.__call__
  File "/usr/local/lib/python3.6/dist-packages/web3/utils/rpc_abi.py", line 59, in apply_abi_formatters_to_dict
    [data[field] for field in fields],
  File "cytoolz/functoolz.pyx", line 236, in cytoolz.functoolz.curry.__call__
  File "cytoolz/functoolz.pyx", line 232, in cytoolz.functoolz.curry.__call__
  File "/usr/local/lib/python3.6/dist-packages/web3/utils/abi.py", line 464, in map_abi_data
    return pipe(data, *pipeline)
  File "cytoolz/functoolz.pyx", line 589, in cytoolz.functoolz.pipe
  File "cytoolz/functoolz.pyx", line 565, in cytoolz.functoolz.c_pipe
  File "cytoolz/functoolz.pyx", line 236, in cytoolz.functoolz.curry.__call__
  File "cytoolz/functoolz.pyx", line 232, in cytoolz.functoolz.curry.__call__
  File "/usr/local/lib/python3.6/dist-packages/web3/utils/abi.py", line 496, in data_tree_map
    return recursive_map(map_to_typed_data, data_tree)
  File "/usr/local/lib/python3.6/dist-packages/web3/utils/decorators.py", line 35, in wrapped
    wrapped_val = to_wrap(*args)
  File "/usr/local/lib/python3.6/dist-packages/web3/utils/formatters.py", line 117, in recursive_map
    items_mapped = map_collection(recurse, data)
  File "/usr/local/lib/python3.6/dist-packages/web3/utils/formatters.py", line 104, in map_collection
    return datatype(map(func, collection))
  File "/usr/local/lib/python3.6/dist-packages/web3/utils/formatters.py", line 116, in recurse
    return recursive_map(func, item)
  File "/usr/local/lib/python3.6/dist-packages/web3/utils/decorators.py", line 35, in wrapped
    wrapped_val = to_wrap(*args)
  File "/usr/local/lib/python3.6/dist-packages/web3/utils/formatters.py", line 118, in recursive_map
    return func(items_mapped)
  File "/usr/local/lib/python3.6/dist-packages/web3/utils/abi.py", line 493, in map_to_typed_data
    return ABITypedData(func(*elements))
  File "/usr/local/lib/python3.6/dist-packages/web3/utils/normalizers.py", line 42, in wrapper
    modified = to_wrap(abi_type, data)
  File "/usr/local/lib/python3.6/dist-packages/web3/utils/normalizers.py", line 121, in abi_address_to_hex
    validate_address(data)
  File "/usr/local/lib/python3.6/dist-packages/web3/utils/validation.py", line 112, in validate_address
    raise TypeError('Address {} must be provided as a string'.format(value))
TypeError: Address b'' must be provided as a string
```

The network is Rinkeby if it matters at all.

### How can it be fixed?

From what I understand, the "to" field is not expected at all, when we are talking about contract deployment. If I manually remove the "to" field from the returned transaction dictionary, it then gets sent correctly without any issues. My suggestion is that ContractConstructor.buildTransaction() should not add the "to" field to the returned dictionary at all.
Here is my dirty hack:
```python
transaction = contract_constructor.buildTransaction(transaction)
transaction.pop('to')
web3.personal.sendTransaction(transaction, password)
```
Result:
```
HexBytes('0xfe853016685e6038cf318a581a6431896e152730f64301dcf2a3c18c5da187a1')
```


Discussion:

Resolving patch:
diff --git a/web3/middleware/pythonic.py b/web3/middleware/pythonic.py
--- a/web3/middleware/pythonic.py
+++ b/web3/middleware/pythonic.py
@@ -279,6 +279,7 @@ def to_hexbytes(num_bytes, val, variable_length=False):
         ),
         'personal_sign': apply_formatter_at_index(text_if_str(to_hex), 0),
         'personal_ecRecover': apply_formatter_at_index(text_if_str(to_hex), 0),
+        'personal_sendTransaction': apply_formatter_at_index(transaction_param_formatter, 0),
         # Snapshot and Revert
         'evm_revert': apply_formatter_at_index(integer_to_hex, 0),
     },


Test patch: