iota_sdk.client.client
ClientError Objects
class ClientError(Exception)
client error
Client Objects
class Client(NodeCoreAPI, NodeIndexerAPI, HighLevelAPI, ClientUtils)
__init__
def __init__(nodes: Optional[str | List[str]] = None,
primary_node: Optional[str] = None,
primary_pow_node: Optional[str] = None,
permanode: Optional[str] = None,
ignore_node_health: Optional[bool] = None,
api_timeout: Optional[timedelta] = None,
node_sync_interval: Optional[timedelta] = None,
remote_pow_timeout: Optional[timedelta] = None,
tips_interval: Optional[int] = None,
quorum: Optional[bool] = None,
min_quorum_size: Optional[int] = None,
quorum_threshold: Optional[int] = None,
user_agent: Optional[str] = None,
local_pow: Optional[bool] = None,
fallback_to_local_pow: Optional[bool] = None,
pow_worker_count: Optional[int] = None,
client_handle=None)
Initialize the IOTA Client.
Parameters
- nodes: string or array of string
A single Node URL or an array of URLs. - primary_node: string
Node which will be tried first for all requests. - primary_pow_node: string
Node which will be tried first when using remote PoW, even before the primary_node. - permanode: string
Permanode URL. - ignore_node_health: bool
If the node health should be ignored. - api_timeout: datetime.timedelta
Timeout for API requests. - node_sync_interval: datetime.timedelta
Interval in which nodes will be checked for their sync status and the NetworkInfo gets updated. - remote_pow_timeout: datetime.timedelta
Timeout when sending a block that requires remote proof of work. - tips_interval: int
Tips request interval during PoW in seconds. - quorum: bool
If node quorum is enabled. Will compare the responses from multiple nodes and only returns the response ifquorum_threshold
% of the nodes return the same one. - min_quorum_size: int
Minimum amount of nodes required for request when quorum is enabled. - quorum_threshold: int
% of nodes that have to return the same response so it gets accepted. - user_agent: string
The User-Agent header for requests. - local_pow: bool
Local proof of work. - fallback_to_local_pow: bool
Fallback to local proof of work if the node doesn't support remote PoW. - pow_worker_count: int
The amount of threads to be used for proof of work.
build_alias_output
def build_alias_output(alias_id: HexStr,
unlock_conditions: List[UnlockCondition],
amount: Optional[int] = None,
native_tokens: Optional[List[NativeToken]] = None,
state_index: Optional[int] = None,
state_metadata: Optional[str] = None,
foundry_counter: Optional[int] = None,
features: Optional[List[Feature]] = None,
immutable_features: Optional[List[Feature]] = None)
Build an AliasOutput.
Parameters
- alias_id: string
Hex encoded alias id - unlock_conditions: array of UnlockCondition
The unlock conditions for this output - amount: int
Amount of base token - native_tokens: array of NativeToken
The native token to add to the output - state_index: int
Index of the state - state_metadata: string
Hex encoded state metadata - foundry_counter: int
Counter of foundry outputs created - features: array of Feature
Features for this outputs - immutable_features: array of Feature
Immutable features
Returns
Output as dict
build_basic_output
def build_basic_output(unlock_conditions: List[UnlockCondition],
amount: Optional[int] = None,
native_tokens: Optional[List[NativeToken]] = None,
features: Optional[List[Feature]] = None)
Build a BasicOutput.
Parameters
- unlock_conditions: array of UnlockCondition
The unlock conditions for this output - amount: int
Amount of base token - native_tokens: array of NativeToken
The native token to add to the output - features: array of Feature
Features for this outputs
Returns
Output as dict
build_foundry_output
def build_foundry_output(serial_number: int,
token_scheme: TokenScheme,
unlock_conditions: List[UnlockCondition],
amount: Optional[int] = None,
native_tokens: Optional[List[NativeToken]] = None,
features: Optional[List[Feature]] = None,
immutable_features: Optional[List[Feature]] = None)
Build a FoundryOutput.
Parameters
- serial_number: int
The serial number of the foundry - token_scheme: TokenScheme
The Token scheme. Currently only a simple scheme is supported - unlock_conditions: array of UnlockCondition
The unlock conditions for this output - amount: int
Amount of base token - native_tokens: array of NativeToken
The native token to add to the output - features: array of Feature
Features for this outputs - immutable_features: array of Feature
Immutable features
Returns
Output as dict
build_nft_output
def build_nft_output(nft_id: HexStr,
unlock_conditions: List[UnlockCondition],
amount: Optional[int] = None,
native_tokens: Optional[List[NativeToken]] = None,
features: Optional[List[Feature]] = None,
immutable_features: Optional[List[Feature]] = None)
Build an NftOutput.
Parameters
- nft_id: string
Hex encoded nft id - unlock_conditions: array of UnlockCondition
The unlock conditions for this output - amount: int
Amount of base token - native_tokens: array of NativeToken
The native tokens to add to the output - features: array of Feature
Features for this outputs - immutable_features: array of Feature
Immutable features
Returns
Output as dict
build_and_post_block
def build_and_post_block(secret_manager=None,
account_index: Optional[int] = None,
coin_type: Optional[int] = None,
custom_remainder_address: Optional[str] = None,
data: Optional[HexStr] = None,
initial_address_index: Optional[int] = None,
input_range_start: Optional[int] = None,
input_range_end: Optional[int] = None,
inputs: Optional[List[Dict[str, Any]]] = None,
output: Optional[Dict[str, Any]] = None,
outputs: Optional[List[Any]] = None,
tag: Optional[HexStr] = None)
Build and post a block.
Parameters
- account_index: int
Account Index - coin_type: int
Coin type. The CoinType enum can be used - custom_remainder_address: string
Address to send the remainder funds to - data: str
Hex encoded data - initial_address_index: int
Initial address index - input_range_start: int
Start of the input range - input_range_end: int
End of the input range - inputs: Array of Inputs
Inputs to use - output: SendAmountParams
Address and amount to send to - outputs: Array of Outputs
Outputs to use - tag: string
Hex encoded tag
Returns
Block as dict
get_node
def get_node() -> Dict[str, Any]
Get a node candidate from the healthy node pool.
get_network_info
def get_network_info() -> Dict[str, Any]
Gets the network related information such as network_id and min_pow_score.
get_network_id
def get_network_id() -> int
Gets the network id of the node we're connecting to.
get_bech32_hrp
def get_bech32_hrp() -> str
Returns the bech32_hrp.
get_min_pow_score
def get_min_pow_score() -> int
Returns the min pow score.
get_tips_interval
def get_tips_interval() -> int
Returns the tips interval.
get_local_pow
def get_local_pow() -> bool
Returns if local pow should be used or not.
get_fallback_to_local_pow
def get_fallback_to_local_pow() -> bool
Get fallback to local proof of work timeout.
unhealthy_nodes
def unhealthy_nodes() -> List[Dict[str, Any]]
Returns the unhealthy nodes.
prepare_transaction
def prepare_transaction(secret_manager=None, options=None)
Prepare a transaction for signing.
sign_transaction
def sign_transaction(secret_manager, prepared_transaction_data)
Sign a transaction.
submit_payload
def submit_payload(payload)
Submit a payload in a block.