Personal API¶
-
class
web3.personal.Personal¶
The web3.personal object exposes methods to interact with the RPC APIs
under the personal_ namespace.
Properties¶
The following properties are available on the web3.personal namespace.
-
web3.personal.listAccounts¶ - Delegates to
personal_listAccountsRPC Method
Returns the list of known accounts.
>>> web3.personal.listAccounts ['0xd3cda913deb6f67967b99d67acdfa1712c293601']
- Delegates to
Methods¶
The following methods are available on the web3.personal namespace.
-
web3.personal.importRawKey(self, private_key, passphrase)¶ - Delegates to
personal_importRawKeyRPC Method
Adds the given
private_keyto the node’s keychain, encrypted with the givenpassphrase. Returns the address of the imported account.>>> web3.personal.importRawKey(some_private_key, 'the-passphrase') ['0xd3cda913deb6f67967b99d67acdfa1712c293601']
- Delegates to
-
web3.personal.newAccount(self, password=None)¶ - Delegates to
personal_newAccountRPC Method
Generates a new account in the node’s keychain encrypted with the given
passphrase. Returns the address of the created account.>>> web3.personal.newAccount('the-passphrase') ['0xd3cda913deb6f67967b99d67acdfa1712c293601']
- Delegates to
-
web3.personal.signAndSendTransaction(self, tx, passphrase)¶ - Delegates to
personal_signAndSendTransactionRPC Method
Signs and sends the given
transactionwithout requiring thefromaccount to be unlocked.passphrasemust be the passphrase for thefromaccount for the providedtransaction.Behaves in the same manner as :py:method::web3.eth.Eth.sendTransaction(transaction).
>>> web3.personal.signAndSendTransaction({'to': '0xd3cda913deb6f67967b99d67acdfa1712c293601', 'from': web3.eth.coinbase, 'value': 12345}, 'the-passphrase') '0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331'
- Delegates to
-
web3.personal.lockAccount(self, account)¶ - Delegates to
personal_lockAccountRPC Method
Locks the given
account.>>> web3.personal.lockAccount('0xd3cda913deb6f67967b99d67acdfa1712c293601')
- Delegates to
-
web3.personal.unlockAccount(self, account, passphrase, duration=None)¶ - Delegates to
personal_unlockAccountRPC Method
Unlocks the given
accountfordurationseconds. IfdurationisNonethen the account will remain unlocked indefinitely. Returns boolean as to whether the account was successfully unlocked.>>> web3.personal.unlockAccount('0xd3cda913deb6f67967b99d67acdfa1712c293601', 'wrong-passphrase') False >>> web3.personal.unlockAccount('0xd3cda913deb6f67967b99d67acdfa1712c293601', 'the-passphrase') True
- Delegates to