SmartContractWallet

SmartContractWallet

class SmartContractWallet(**kwargs)

Implements the smartcontractwallet api endpoints.

account_addresses(wallet_name: str, **kwargs) → List[pystratis.core.types.address.Address]

Gets a smart contract account address.

Parameters:
  • wallet_name (str) – The wallet name.
  • **kwargs – Extra keyword arguments.
Returns:

A list of smart contract addresses.

Return type:

List[Address]

Raises:

APIError – Error thrown by node API. See message for details.

address_balance(address: Union[pystratis.core.types.address.Address, str], **kwargs) → pystratis.core.types.money.Money

Gets the balance at a specific wallet address in STRAX (or the sidechain coin).

Parameters:
  • address (Address, str) – The smart contract address being queried.
  • **kwargs – Extra keyword arguments.
Returns:

The smart contract address balance.

Return type:

Money

Raises:

APIError – Error thrown by node API. See message for details.

call(wallet_name: str, fee_amount: Union[pystratis.core.types.money.Money, int, float, decimal.Decimal], password: str, contract_address: Union[pystratis.core.types.address.Address, str], method_name: str, gas_price: int, gas_limit: int, sender: Union[pystratis.core.types.address.Address, str], amount: Union[pystratis.core.types.money.Money, int, float, decimal.Decimal], outpoints: List[pystratis.core.outpoint.Outpoint] = None, account_name: str = 'account 0', parameters: List[str] = None, **kwargs) → pystratis.api.global_responsemodels.buildcontracttransactionmodel.BuildContractTransactionModel

Builds a transaction to call a smart contract method and then broadcasts the transaction to the network.

Parameters:
  • wallet_name (str) – The wallet name.
  • account_name (str, optional) – The wallet name. Default=’account 0’
  • outpoints (List[Outpoint], optional) – A list of the outpoints used to construct the transactation.
  • contract_address (Address, str) – The smart contract address being called.
  • method_name (str) – The method name being called.
  • amount (Money, int, float, Decimal, optional) – The amount being sent.
  • fee_amount (Money, int, float, Decimal) – The fee amount.
  • password (SecretStr) – The password.
  • gas_price (int) – The amount of gas being used in satoshis.
  • gas_limit (int) – The maximum amount of gas that can be used in satoshis.
  • sender (Address, str) – The address of the sending address.
  • parameters (List[Union[SmartContractParameter, str]], optional) – A list of parameters for the smart contract.
  • **kwargs – Extra keyword arguments.
Returns:

A built smart contract transaction.

Return type:

BuildContractTransactionModel

Raises:

APIError – Error thrown by node API. See message for details.

create(wallet_name: str, fee_amount: Union[pystratis.core.types.money.Money, int, float, decimal.Decimal], password: str, contract_code: Union[pystratis.core.types.hexstr.hexstr, str], gas_price: int, gas_limit: int, sender: Union[pystratis.core.types.address.Address, str], amount: Union[pystratis.core.types.money.Money, int, float, decimal.Decimal] = None, outpoints: List[pystratis.core.outpoint.Outpoint] = None, account_name: str = 'account 0', parameters: List[str] = None, **kwargs) → pystratis.core.types.uint256.uint256

Builds a transaction to create a smart contract and then broadcasts the transaction to the network.

Parameters:
  • wallet_name (str) – The wallet name.
  • account_name (str, optional) – The wallet name. Default=’account 0’
  • outpoints (List[Outpoint], optional) – A list of the outpoints used to construct the transactation.
  • amount (Money, int, float, Decimal, optional) – The amount being sent.
  • fee_amount (Money, int, float, Decimal) – The fee amount.
  • password (SecretStr) – The password.
  • contract_code (hexstr, str) – The smart contract code hexstring.
  • gas_price (int) – The amount of gas being used in satoshis.
  • gas_limit (int) – The maximum amount of gas that can be used in satoshis.
  • sender (Address, str) – The address of the sending address.
  • parameters (List[Union[SmartContractParameter, str], optional) – A list of parameters for the smart contract.
  • **kwargs – Extra keyword arguments.
Returns:

The transaction hash.

Return type:

uint256

Raises:

APIError – Error thrown by node API. See message for details.

history(wallet_name: str, address: Union[pystratis.core.types.address.Address, str], skip: int = 0, take: int = None, **kwargs) → List[pystratis.api.smartcontractwallet.responsemodels.contracttransactionitemmodel.ContractTransactionItemModel]

Gets the history of a specific smart contract wallet address.

Parameters:
  • wallet_name (str) – The wallet name.
  • address (Address, str) – The address to query the history.
  • skip (int, optional) – Skip this many items. Default=0.
  • take (int, optional) – Take this many items.
  • **kwargs – Extra keyword arguments.
Returns:

A history of a smart contract wallet address.

Return type:

List[ContractTransactionItemModel]

Raises:

APIError – Error thrown by node API. See message for details.

send_transaction(transaction_hex: Union[pystratis.core.types.hexstr.hexstr, str], **kwargs) → pystratis.api.global_responsemodels.walletsendtransactionmodel.WalletSendTransactionModel

Broadcasts a transaction, which either creates a smart contract or calls a method on a smart contract.

Parameters:
  • transaction_hex (hexstr, str) – The transaction hex string.
  • **kwargs – Extra keyword arguments.
Returns:

Information about the sent transaction.

Return type:

WalletSendTransactionModel

Raises:

APIError – Error thrown by node API. See message for details.

BuildContractTransactionModel

class BuildContractTransactionModel

A pydantic model for building a smart contact transaction.

ContractTransactionItemModel

class ContractTransactionItemModel

A pydantic model representing a contract transaction.

TransactionOutputModel

class TransactionOutputModel

A pydantic model of a transaction output.

WalletSendTransactionModel

class WalletSendTransactionModel

A pydantic model for a send transaction response.