Repository: ethereum/web3.py

Issue:
When default account is set, it should be used instead of the coinbase
- Version: 3.1.0
- Python: 2.7/3.4/3.5
- OS: osx/linux/win
### What was wrong?

https://github.com/pipermerriam/web3.py/blob/master/web3/contract.py#L437 should use `self.web3.eth.defaultAccount` instead of `self.web3.eth.coinbase`
#### Cute Animal Picture

![Cute animal picture](https://upload.wikimedia.org/wikipedia/commons/5/58/Domestic_duck_in_Venezuela.jpg)



Discussion:

Resolving patch:
diff --git a/web3/contract.py b/web3/contract.py
--- a/web3/contract.py
+++ b/web3/contract.py
@@ -434,7 +434,7 @@ def transact(self, transaction=None):
 
         if self.address is not None:
             transact_transaction.setdefault('to', self.address)
-        transact_transaction.setdefault('from', self.web3.eth.coinbase)
+        transact_transaction.setdefault('from', self.web3.eth.defaultAccount)
 
         if 'to' not in transact_transaction:
             if isinstance(self, type):


Test patch:
diff --git a/tests/contracts/test_contract_transact_interface.py b/tests/contracts/test_contract_transact_interface.py
--- a/tests/contracts/test_contract_transact_interface.py
+++ b/tests/contracts/test_contract_transact_interface.py
@@ -63,20 +63,33 @@ def test_transacting_with_contract_with_arguments(web3_tester,
     assert final_value - initial_value == 5
 
 
-def test_transacting_with_contract_with_string_argument(web3_tester, string_contract):
-    # eth_abi will pass as raw bytes, no encoding
-    # unless we encode ourselves
-    txn_hash = string_contract.transact().setValue(force_bytes("ÄLÄMÖLÖ"))
-    txn_receipt = web3_tester.eth.getTransactionReceipt(txn_hash)
-    assert txn_receipt is not None
+def test_deploy_when_default_account_is_different_than_coinbase(web3_tester,
+                                                                wait_for_transaction,
+                                                                STRING_CONTRACT):
+    web3_tester.eth.defaultAccount = web3_tester.eth.accounts[1]
+    assert web3_tester.eth.defaultAccount != web3_tester.eth.coinbase
 
-    final_value = string_contract.call().getValue()
+    StringContract = web3_tester.eth.contract(**STRING_CONTRACT)
 
-    assert force_bytes(final_value) == force_bytes("ÄLÄMÖLÖ")
+    deploy_txn = StringContract.deploy(args=["Caqalai"])
+    wait_for_transaction(web3_tester, deploy_txn)
+    txn_after = web3_tester.eth.getTransaction(deploy_txn)
+    assert txn_after['from'] == web3_tester.eth.defaultAccount
 
 
-def test_transacting_with_contract_with_string_argument(web3_tester, string_contract):
+def test_transact_when_default_account_is_different_than_coinbase(web3_tester,
+                                                                  wait_for_transaction,
+                                                                  math_contract):
+    web3_tester.eth.defaultAccount = web3_tester.eth.accounts[1]
+    assert web3_tester.eth.defaultAccount != web3_tester.eth.coinbase
 
+    txn_hash = math_contract.transact().increment()
+    wait_for_transaction(web3_tester, txn_hash)
+    txn_after = web3_tester.eth.getTransaction(txn_hash)
+    assert txn_after['from'] == web3_tester.eth.defaultAccount
+
+
+def test_transacting_with_contract_with_string_argument(web3_tester, string_contract):
     # eth_abi will pass as raw bytes, no encoding
     # unless we encode ourselves
     txn_hash = string_contract.transact().setValue(force_bytes("ÄLÄMÖLÖ"))