SmartContractWallet

SmartContractWallet

class SmartContractWallet(**kwargs)

Implements the smartcontractwallet api endpoints.

account_addresses(wallet_name: str, **kwargs) List[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[Address, str], **kwargs) 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.

history(wallet_name: str, address: Union[Address, str], skip: int = 0, take: Optional[int] = None, **kwargs) List[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.

create(wallet_name: str, fee_amount: Union[Money, int, float, decimal.Decimal], password: str, contract_code: Union[hexstr, str], gas_price: int, gas_limit: int, sender: Union[Address, str], amount: Optional[Union[Money, int, float, decimal.Decimal]] = None, outpoints: Optional[List[Outpoint]] = None, account_name: str = 'account 0', parameters: Optional[List[str]] = None, **kwargs) 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.

call(wallet_name: str, fee_amount: Union[Money, int, float, decimal.Decimal], password: str, contract_address: Union[Address, str], method_name: str, gas_price: int, gas_limit: int, sender: Union[Address, str], amount: Union[Money, int, float, decimal.Decimal], outpoints: Optional[List[Outpoint]] = None, account_name: str = 'account 0', parameters: Optional[List[str]] = None, **kwargs) 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.

send_transaction(transaction_hex: Union[hexstr, str], **kwargs) 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(*, fee: Money, hex: hexstr, message: str = None, success: bool = None, transactionId: uint256 = None)

A pydantic model for building a smart contact transaction.

fee: Money

The transaction fee.

hex: hexstr

The hex serialized transaction.

message: Optional[str]

The build transaction message.

success: Optional[bool]

True if build was successful.

transaction_id: Optional[uint256]

The transaction hash, if build successful.

ContractTransactionItemModel

class ContractTransactionItemModel(*, blockHeight: int, type: ContractTransactionItemType, hash: uint256, to: Address, amount: Money, transactionFee: Money, gasFee: Money)

A pydantic model representing a contract transaction.

block_height: int

The block height of block containing the transaction.

item_type: ContractTransactionItemType

The contract transaction item type.

hash: uint256

The transaction hash.

to_address: Address

The to address of the contact.

amount: Money

The transaction amount.

transaction_fee: Money

The transaction fee.

gas_fee: Money

The transaction’s gas fee.

TransactionOutputModel

class TransactionOutputModel(*, address: Optional[Union[int, Address]] = None, amount: Money, opReturnData: str = None)

A pydantic model of a transaction output.

address: Optional[Union[int, Address]]

The address receiving the output.

amount: Money

The output amount.

op_return_data: Optional[str]

The OP_RETURN data, if present.

WalletSendTransactionModel

class WalletSendTransactionModel(*, transactionId: uint256, outputs: List[TransactionOutputModel])

A pydantic model for a send transaction response.

transaction_id: uint256

The transaction hash.

outputs: List[TransactionOutputModel]

A list of transaction outputs.