Parity API

The web3.parity object exposes modules that enable you to interact with the JSON-RPC endpoints supported by Parity that are not defined in the standard set of Ethereum JSONRPC endpoints according to EIP 1474.


The following methods are available on the web3.parity.personal namespace.

  • Delegates to personal_listAccounts RPC Method

Returns the list of known accounts.

>>> web3.parity.personal.listAccounts()
web3.parity.importRawKey(self, private_key, passphrase)
  • Delegates to personal_importRawKey RPC Method

Adds the given private_key to the node’s keychain, encrypted with the given passphrase. Returns the address of the imported account.

>>> web3.parity.personal.importRawKey(some_private_key, 'the-passphrase')
web3.parity.newAccount(self, password)
  • Delegates to personal_newAccount RPC Method

Generates a new account in the node’s keychain encrypted with the given passphrase. Returns the address of the created account.

>>> web3.parity.personal.newAccount('the-passphrase')
web3.parity.unlockAccount(self, account, passphrase, duration=None)
  • Delegates to personal_unlockAccount RPC Method

Unlocks the given account for duration seconds. If duration is None then the account will remain unlocked indefinitely. Returns boolean as to whether the account was successfully unlocked.

# Invalid call to personal_unlockAccount on Parity currently returns True, due to Parity bug
>>> web3.parity.personal.unlockAccount('0xd3cda913deb6f67967b99d67acdfa1712c293601', 'wrong-passphrase')
>>> web3.parity.personal.unlockAccount('0xd3cda913deb6f67967b99d67acdfa1712c293601', 'the-passphrase')
web3.parity.sendTransaction(self, transaction, passphrase)
  • Delegates to personal_sendTransaction RPC Method

Sends the transaction.

web3.parity.signTypedData(self, jsonMessage, account, passphrase)
  • Delegates to personal_signTypedData RPC Method

Please note that the jsonMessage argument is the loaded JSON Object and NOT the JSON String itself.

Signs the Structured Data (or Typed Data) with the passphrase of the given account


The web3.parity.shh object exposes methods to interact with the RPC APIs under the shh_` namespace.

Full documentation for Parity-supported endpoints can be found here.


The Whisper protocol is in flux, with incompatible versions supported by different major clients.

Returns the Whisper statistics for diagnostics.

{'memory': 240, 'messages': 0, 'targetMemory': 102485760}, message)
  • Creates a whisper message and injects it into the network for distribution.
  • Parameters:
    • to: The receiver of the message. Can be omitted for a broadcast message. Use one of the following two fields.
      • public: The public key of the recipient.
      • identity: The identity of the recipient key on your local node.
    • from: Asymmetric identity to sign the message with, or null.
    • topics: Array of topics for the message. Should be non-empty.
    • payload: Payload to be encrypted.
    • padding: Optional padding. Up to 2^24 -1 bytes.
    • priority: How many milliseconds to spend doing POW.
    • ttl: Time-to-live (in seconds) of the message before expiry.
  • Returns True if the message was succesfully sent, otherwise False
Shh.newMessageFilter(self, criteria)
  • Return the filter ID that can be used with ShhFilter to poll for new messages that match the set of criteria.
  • Parameters:
    • decryptWith: 32 bytes - Identity of key used for description. Null if listening for broadcasts.
    • from: 64 bytes - If present, only accept messages signed by this key.
    • topics: Array of possible topics (or partial topics). Should be non-empty.
  • Returns the newly created filter id.
>>>web3.parity.shh.newMessageFilter({'topic': '0x12340000', 'privateKeyID': recipient_private})
Shh.deleteMessageFilter(self, filter_id)
  • Deletes a message filter in the node.
  • Returns True if the filter was sucesfully uninstalled, otherwise False
Shh.getMessages(self, filter_id)
  • Retrieve messages that match the filter criteria and are received between the last time this function was called and now.
  • Returns all new messages since the last invocation
    'ttl': 50,
    'timestamp': 1524497850,
    'topics': HexBytes('0x13370000'),
    'payload': HexBytes('0x74657374206d657373616765203a29'),
    'padding': HexBytes('0x50ab643f1b23bc6df1b1532bb6704ad947c2453366754aade3e3597553eeb96119f4f4299834d9989dc4ecc67e6b6470317bb3f7396ace0417fc0d6d2023900d3'),
    'recipient': HexBytes('0x047d36c9e45fa82fcd27d35bc7d2fd41a2e41e512feec9e4b90ee4293ab12dcac'),
Shh.subscribe(self, filter_id)
  • Open a subscription to a filter. Subscription calls are only supported on the websocket transport.
  • Returns True if the filter was sucesfully subscribed to, otherwise False



Shh.unsubscribe(self, filter_id)
  • Close a subscribed filter.
  • Returns True if the filter subscription was sucesfully closed, otherwise False



Asymmetric Keys

  • Generates a new cryptographic identity for the client, and injects it into the known identities for message decryption
  • Returns the new key pair’s identity
Shh.addPrivateKey(self, key)
  • Stores a key pair derived from a private key, and returns its ID.
  • Returns the added key pair’s ID
Shh.getPublicKey(self, id)
  • Returns the public key associated with the key pair.
Shh.getPrivateKey(self, id)
  • Returns the private key associated with the key pair.

Symmetric Keys

  • Generates a random symmetric key and stores it under id, which is then returned. Will be used in the future for session key exchange
  • Returns the new key pair’s identity
Shh.addSymKey(self, key)
  • Stores the key, and returns its ID.
  • Returns the new key pair’s identity
Shh.getSymKey(self, id)
  • Returns the symmetric key associated with the given ID.
  • Returns the public key associated with the key pair
Shh.deleteKey(self, id)
  • Deletes the symmetric key associated with the given ID.
  • Returns True if the key pair was deleted, otherwise False