Client reference¶
-
class
neojsonrpc.client.
Client
(host=None, port=None, tls=False, http_max_retries=None)¶ The NEO JSON-RPC client class.
-
contract
(script_hash)¶ Returns a
ContractWrapper
instance allowing to easily invoke contract functions.This method allows to invoke smart contract functions as if they were Python class instance methods. For example:
>>> contract = client.contract('34af1b6634fcd7cfcff0158965b18601d3837e32') >>> contract.symbol() {...} >>> contract.getBalance('<address>') {...}
Parameters: script_hash (str) – contract script hash Returns: ContractWrapper
objectReturn type: neojsonrpc.client.ContractWrapper
-
classmethod
for_mainnet
()¶ Creates a
Client
instance for use with the NEO Main Net.
-
classmethod
for_testnet
()¶ Creates a
Client
instance for use with the NEO Test Net.
-
get_account_state
(address, **kwargs)¶ Returns the account state information associated with a specific address.
Parameters: address (str) – a 34-bit length address (eg. AJBENSwajTzQtwyJFkiJSv7MAaaMc7DsRz) Returns: dictionary containing the account state information Return type: dict
-
get_asset_state
(asset_id, **kwargs)¶ Returns the asset information associated with a specific asset ID.
Parameters: asset_id (str) – an asset identifier (the transaction ID of the RegistTransaction when the asset is registered) Returns: dictionary containing the asset state information Return type: dict
-
get_best_block_hash
(**kwargs)¶ Returns the hash of the tallest block in the main chain.
Returns: hash of the tallest block in the chain Return type: str
-
get_block
(block_hash, verbose=True, **kwargs)¶ Returns the block information associated with a specific hash value or block index.
Parameters: - block_hash (str or int) – a block hash value or a block index (block height)
- verbose (bool) – a boolean indicating whether the detailed block information should be returned in JSON format (otherwise the block information is returned as an hexadecimal string by the JSON-RPC endpoint)
Returns: dictionary containing the block information (or an hexadecimal string if verbose is set to False)
Return type: dict or str
-
get_block_count
(**kwargs)¶ Returns the number of blocks in the chain.
Returns: number of blocks in the chain Return type: int
-
get_block_hash
(block_index, **kwargs)¶ Returns the hash value associated with a specific block index.
Parameters: block_index (int) – a block index (block height) Returns: hash of the block associated with the considered index Return type: str
-
get_block_sys_fee
(block_index, **kwargs)¶ Returns the system fees associated with a specific block index.
Parameters: block_index (int) – a block index (block height) Returns: system fees of the block, expressed in NeoGas units Return type: str
-
get_connection_count
(**kwargs)¶ Returns the current number of connections for the considered node.
Returns: number of connections for the node Return type: int
-
get_contract_state
(script_hash, **kwargs)¶ Returns the contract information associated with a specific script hash.
Parameters: script_hash (str) – contract script hash Returns: dictionary containing the contract information Return type: dict
-
get_peers
(**kwargs)¶ Returns a list of nodes that the node is currently connected/disconnected from.
Returns: dictionary containing the nodes the current node is connected/disconnected from Return type: dict
-
get_raw_mem_pool
(**kwargs)¶ Returns a list of unconfirmed transactions in memory associated with the node.
Returns: list of unconfirmed transaction hashes Return type: list
-
get_raw_transaction
(tx_hash, verbose=True, **kwargs)¶ Returns detailed information associated with a specific transaction hash.
Parameters: - tx_hash (str) – transaction hash
- verbose (bool) – a boolean indicating whether the detailed transaction information should be returned in JSON format (otherwise the transaction information is returned as an hexadecimal string by the JSON-RPC endpoint)
Returns: dictionary containing the transaction information (or an hexadecimal string if verbose is set to False)
Return type: dict or str
-
get_storage
(script_hash, key, **kwargs)¶ Returns the value stored in the storage of a contract script hash for a given key.
Parameters: - script_hash (str) – contract script hash
- key (str) – key to look up in the storage
Returns: value associated with the storage key
Return type: bytearray
-
get_tx_out
(tx_hash, index, **kwargs)¶ Returns the transaction output information corresponding to a hash and index.
Parameters: - tx_hash (str) – transaction hash
- index (int) – index of the transaction output to be obtained in the transaction (starts from 0)
Returns: dictionary containing the transaction output
Return type: dict
-
get_version
(**kwargs)¶ Returns version information about the current node.
Returns: dictionary containing version information about the current node Return type: dict
-
invoke
(script_hash, params, **kwargs)¶ Invokes a contract with given parameters and returns the result.
It should be noted that the name of the function invoked in the contract should be part of paramaters.
Parameters: - script_hash (str) – contract script hash
- params (list) – list of paramaters to be passed in to the smart contract
Returns: result of the invocation
Return type: dictionary
-
invoke_function
(script_hash, operation, params, **kwargs)¶ Invokes a contract’s function with given parameters and returns the result.
Parameters: - script_hash (str) – contract script hash
- operation (str) – name of the operation to invoke
- params (list) – list of paramaters to be passed in to the smart contract
Returns: result of the invocation
Return type: dictionary
-
invoke_script
(script, **kwargs)¶ Invokes a script on the VM and returns the result.
Parameters: script (str) – script runnable by the VM Returns: result of the invocation Return type: dictionary
-
send_raw_transaction
(hextx, **kwargs)¶ Broadcasts a transaction over the NEO network and returns the result.
Parameters: hextx (str) – hexadecimal string that has been serialized Returns: result of the transaction Return type: bool
-
validate_address
(addr, **kwargs)¶ Validates if the considered string is a valid NEO address.
Parameters: hex (str) – string containing a potential NEO address Returns: dictionary containing the result of the verification Return type: dictionary
-