Common objects and functions

Abstract classes

Classes:

BaseWeb3Client

Web3 client reference implementation.

BaseContractMethod

Reference implementation of class defining smart contract method.

BaseContract

Reference implementation of class defining smart contract.

class matic.abstracts.BaseWeb3Client(provider: Any)[source]

Bases: abc.ABC

Web3 client reference implementation.

Methods:

get_contract

Obtain a contract from deployment address and ABI dictionary.

read

Perform a reading (non-modifying) operation.

write

Perform a writing (modifying) operation.

estimate_gas

Estimate gas amount for transaction.

get_transaction_count

Get amount of transactions in specified block for given address.

get_transaction

Obtain transaction object by hash.

get_transaction_receipt

Get receipt for transaction.

get_block

Get block (with raw transaction data) by hash or number.

get_block_with_transaction

Get block (with decoded transaction data) by hash or number.

get_root_hash

Get root hash for two blocks.

send_rpc_request

Perform arbitrary RPC request.

encode_parameters

Encode ABI parameters according to schema.

decode_parameters

Decode binary data to ABI parameters according to schema.

etherium_sha3

Calculate solidity keccak hash of given values (encoded as types).

Attributes:

gas_price

Current gas price.

chain_id

Current chain id.

abstract get_contract(address: eth_typing.evm.HexAddress, abi: Any) matic.abstracts.BaseContract[source]

Obtain a contract from deployment address and ABI dictionary.

abstract read(config: matic.json_types.ITransactionRequestConfig, return_transaction: bool = False) Any[source]

Perform a reading (non-modifying) operation.

abstract write(config: matic.json_types.ITransactionRequestConfig, private_key: Optional[str] = None, return_transaction: bool = False) matic.json_types.ITransactionWriteResult[source]

Perform a writing (modifying) operation.

abstract property gas_price: int

Current gas price.

abstract estimate_gas(config: matic.json_types.ITransactionRequestConfig) int[source]

Estimate gas amount for transaction.

abstract property chain_id: int

Current chain id.

abstract get_transaction_count(address: eth_typing.evm.HexAddress, block_number: Any) int[source]

Get amount of transactions in specified block for given address.

abstract get_transaction(transaction_hash: bytes) matic.json_types.ITransactionData[source]

Obtain transaction object by hash.

abstract get_transaction_receipt(transaction_hash: bytes) matic.json_types.ITransactionReceipt[source]

Get receipt for transaction.

abstract get_block(block_hash_or_block_number: Union[Literal['latest', 'earliest', 'pending'], eth_typing.evm.BlockNumber, eth_typing.evm.Hash32, eth_typing.encoding.HexStr, hexbytes.main.HexBytes, int]) matic.json_types.IBlock[source]

Get block (with raw transaction data) by hash or number.

abstract get_block_with_transaction(block_hash_or_block_number: Union[Literal['latest', 'earliest', 'pending'], eth_typing.evm.BlockNumber, eth_typing.evm.Hash32, eth_typing.encoding.HexStr, hexbytes.main.HexBytes, int]) matic.json_types.IBlockWithTransaction[source]

Get block (with decoded transaction data) by hash or number.

get_root_hash(start_block: int, end_block: int) bytes[source]

Get root hash for two blocks.

abstract send_rpc_request(method: web3.types.RPCEndpoint, params: Iterable[Any]) web3.types.RPCResponse[source]

Perform arbitrary RPC request.

abstract encode_parameters(params: Sequence[Any], types: Sequence[str]) bytes[source]

Encode ABI parameters according to schema.

abstract decode_parameters(encoded: bytes, types: Sequence[Any]) Sequence[Any][source]

Decode binary data to ABI parameters according to schema.

abstract etherium_sha3(types: Iterable[str], values: Iterable[Any]) bytes[source]

Calculate solidity keccak hash of given values (encoded as types).

class matic.abstracts.BaseContractMethod(address: eth_typing.evm.HexAddress, method: Any)[source]

Bases: abc.ABC

Reference implementation of class defining smart contract method.

Methods:

read

Perform a read operation.

write

Perform a write operation.

estimate_gas

Estimate gas for given transaction.

encode_abi

Encode args according to method ABI and prepend the selector.

abstract read(tx: Optional[matic.json_types.ITransactionRequestConfig] = None, return_transaction: bool = False) Any[source]

Perform a read operation.

This does not sign a transaction and does not affect the chain.

abstract write(tx: matic.json_types.ITransactionRequestConfig, private_key: Optional[str] = None, return_transaction: bool = False) matic.json_types.ITransactionWriteResult[source]

Perform a write operation.

Transaction is signed (with given PK), affects the chain.

abstract estimate_gas(tx: matic.json_types.ITransactionRequestConfig) int[source]

Estimate gas for given transaction.

Warning

This method may fail if your transaction is invalid or cannot be executed.

abstract encode_abi() bytes[source]

Encode args according to method ABI and prepend the selector.

class matic.abstracts.BaseContract(address: eth_typing.evm.HexAddress)[source]

Bases: abc.ABC

Reference implementation of class defining smart contract.

Methods:

method

Obtain a method object by name and call arguments.

abstract method(method_name: str, *args: Any) matic.abstracts.BaseContractMethod[source]

Obtain a method object by name and call arguments.

Constants

Data:

MAX_AMOUNT

Max transaction amount.

MATIC_TOKEN_ADDRESS_ON_POLYGON

MATIC token address on polygon network.

Classes:

POSLogEventSignature

Signatures of different transfer kinds for POS bridge.

PlasmaLogEventSignature

Signatures of different withdrawal kinds for plasma bridge.

matic.constants.MAX_AMOUNT: Final = 115792089237316195423570985008687907853269984665640564039457584007913129639935

Max transaction amount.

matic.constants.MATIC_TOKEN_ADDRESS_ON_POLYGON: Final = '0x0000000000000000000000000000000000001010'

MATIC token address on polygon network.

final class matic.constants.POSLogEventSignature[source]

Bases: object

Signatures of different transfer kinds for POS bridge.

Attributes:

ERC_20_TRANSFER

Transfer of ERC-20 token.

ERC_721_TRANSFER

Transfer of ERC-721 token.

ERC_1155_TRANSFER

Transfer of ERC-1155 token.

ERC_721_BATCH_TRANSFER

Batch transfer of ERC-721 token.

ERC_1155_BATCH_TRANSFER

Batch transfer of ERC-1155 token.

ERC_721_TRANSFER_WITH_METADATA

Transfer of ERC-721 token with metadata.

STATE_SYNCED_EVENT

StateSynced event signature.

ERC_20_TRANSFER: Final = b'\xdd\xf2R\xad\x1b\xe2\xc8\x9bi\xc2\xb0h\xfc7\x8d\xaa\x95+\xa7\xf1c\xc4\xa1\x16(\xf5ZM\xf5#\xb3\xef'

Transfer of ERC-20 token.

ERC_721_TRANSFER: Final = b'\xdd\xf2R\xad\x1b\xe2\xc8\x9bi\xc2\xb0h\xfc7\x8d\xaa\x95+\xa7\xf1c\xc4\xa1\x16(\xf5ZM\xf5#\xb3\xef'

Transfer of ERC-721 token.

ERC_1155_TRANSFER: Final = b'\xc3\xd5\x81h\xc5\xaes\x97s\x1d\x06=[\xbf=exTBsC\xf4\xc0\x83$\x0fz\xac\xaa-\x0fb'

Transfer of ERC-1155 token.

ERC_721_BATCH_TRANSFER: Final = b'\xf8q\x89k\x17\xe9\xcbzd\x94\x1cb\xc1\x88\xa4\xf5\xc6!\xb8h\x00\xe3\xd1TR\xec\xe0\x1c\xe5`s\xdf'

Batch transfer of ERC-721 token.

ERC_1155_BATCH_TRANSFER: Final = b'J9\xdc\x06\xd4\xc0\xdb\xc6Kp\xaf\x90\xfdi\x8a#:Q\x8a\xa5\xd0~Y]\x98;\x8c\x05&\xc8\xf7\xfb'

Batch transfer of ERC-1155 token.

ERC_721_TRANSFER_WITH_METADATA: Final = b'\xf9I\x15\xc6\xd1\xfdR\x1c\xee\x855\x929"t\x80\xc7\xe8wm|\xaf\x1f\xc3\xba\xca\xd5\xc2i\xb6j\x14'

Transfer of ERC-721 token with metadata.

STATE_SYNCED_EVENT: Final = b'\x10?\xed\x9d\xb6^\xac\x19\xc4\xd8p\xf4\x9a\xb7R\x0f\xe0;\x99\xf1\x83\x8eY\x96\xca\xf4~\x9eC0\x83\x92'

StateSynced event signature.

final class matic.constants.PlasmaLogEventSignature[source]

Bases: object

Signatures of different withdrawal kinds for plasma bridge.

Attributes:

ERC_20_WITHDRAW_EVENT_SIG

Withdrawal of ERC-20 token event signature.

ERC_721_WITHDRAW_EVENT_SIG

Withdrawal of ERC-721 token event signature.

ERC_20_WITHDRAW_EVENT_SIG = b'\xeb\xff&\x02\xb3\xf4h%\x9e\x1e\x99\xf6\x13\xfe\xd6i\x1f:e&\xef\xfen\xf3\xe7h\xbaz\xe7\xa3lO'

Withdrawal of ERC-20 token event signature.

ERC_721_WITHDRAW_EVENT_SIG = b'\x9b\x1b\xfa\x7f\xa9\xeeB\n\x16\xe1$\xf7\x94\xc3Z\xc9\xf9\x04r\xac\xc9\x91@\xeb/dG\xc7\x14\xca\xd8\xeb'

Withdrawal of ERC-721 token event signature.

Exceptions

Exceptions:

MaticException

Base exception class for this library.

AllowedOnRootException

The action is allowed only on root token.

AllowedOnChildException

The action is allowed only on child token.

ProofAPINotSetException

Proof api is not set.

BurnTxNotCheckPointedException

Burn transaction has not been checkpointed as yet.

EIP1559NotSupportedException

The chain doesn't support EIP-1559.

NullSpenderAddressException

Please provide spender address.

exception matic.exceptions.MaticException[source]

Bases: Exception

Base exception class for this library.

exception matic.exceptions.AllowedOnRootException[source]

Bases: matic.exceptions.MaticException

The action is allowed only on root token.

exception matic.exceptions.AllowedOnChildException[source]

Bases: matic.exceptions.MaticException

The action is allowed only on child token.

exception matic.exceptions.ProofAPINotSetException[source]

Bases: matic.exceptions.MaticException

Proof api is not set.

exception matic.exceptions.BurnTxNotCheckPointedException[source]

Bases: matic.exceptions.MaticException

Burn transaction has not been checkpointed as yet.

exception matic.exceptions.EIP1559NotSupportedException[source]

Bases: matic.exceptions.MaticException

The chain doesn’t support EIP-1559.

exception matic.exceptions.NullSpenderAddressException[source]

Bases: matic.exceptions.MaticException

Please provide spender address.

TypedDict s and dataclass es

Classes:

ConfigWithFrom

Configuration dictionary with (not required) key "from" (type str) and any other keys.

ITransactionRequestConfig

Transaction config - an actual configuration used to interact with chain.

ITransactionOption

Transaction config: this can be passed as option to almost all methods.

IAllowanceTransactionOption

Transaction config for approve/allowance methods.

IExitTransactionOption

Transaction config for withdraw_exit_* operations.

ITransactionData

Transaction parameters that can be obtained from blockchain.

NeighbourClientConfig

Configuration for parent/child of Web3SideChainClient.

IBaseClientConfig

Configuration for Web3SideChainClient.

IPOSClientConfig

Configuration for POS client.

IPlasmaClientConfig

Configuration for plasma bridge client.

IBaseBlock

Base block parameters.

IBlock

Block with raw transactions (bytes).

IBlockWithTransaction

Block with decoded transactions.

IPOSContracts

Return type of get_pos_contracts parameter of matic.pos.pos_token.POSToken.

IPlasmaContracts

Return type of get_helper_contracts parameter of matic.plasma.plasma_token.PlasmaToken.

IRootBlockInfo

Root block info (used in proofs).

ITransactionWriteResult

Interface for result of process_write method.

ILog

Log data.

IEventLog

Event logs (can occur in transaction receipts).

ITransactionReceipt

Transaction receipt format used internally.

CheckpointedBlock

Block info obtained from API to construct a proof.

IReceiptProof

Receipt proof.

class matic.json_types.ConfigWithFrom

Bases: dict, object

Configuration dictionary with (not required) key “from” (type str) and any other keys.

from: typing_extensions.NotRequired[eth_typing.evm.HexAddress]
class matic.json_types.ITransactionRequestConfig[source]

Bases: matic.json_types.ConfigWithFrom

Transaction config - an actual configuration used to interact with chain.

to: eth_typing.evm.HexAddress

Transaction recipient.

value: int

MATIC (ETH) amount to send.

gas_limit: int

Upper limit of gas allowed to be spent during transaction execution.

gas_price: int

Upper limit of gas price.

data: bytes

Data to send.

nonce: int

Transaction nonce (number of previously sent transactions).

chain_id: int

Chain id (5 for Goerli).

chain: str

Chain name.

hardfork: str

Hard fork (London, Byzantium, Istanbul, …).

max_fee_per_gas: int

ERP-1159 fee specification.

max_priority_fee_per_gas: int

ERP-1159 fee specification.

type: Optional[eth_typing.encoding.HexStr]

Transaction type.

from: typing_extensions.NotRequired[eth_typing.evm.HexAddress]
class matic.json_types.ITransactionOption[source]

Bases: matic.json_types.ITransactionRequestConfig

Transaction config: this can be passed as option to almost all methods.

return_transaction: typing_extensions.NotRequired[bool]

Skip writing step and return prepared transaction.

from: typing_extensions.NotRequired[eth_typing.evm.HexAddress]
to: eth_typing.evm.HexAddress

Transaction recipient.

value: int

MATIC (ETH) amount to send.

gas_limit: int

Upper limit of gas allowed to be spent during transaction execution.

gas_price: int

Upper limit of gas price.

data: bytes

Data to send.

nonce: int

Transaction nonce (number of previously sent transactions).

chain_id: int

Chain id (5 for Goerli).

chain: str

Chain name.

hardfork: str

Hard fork (London, Byzantium, Istanbul, …).

max_fee_per_gas: int

ERP-1159 fee specification.

max_priority_fee_per_gas: int

ERP-1159 fee specification.

type: Optional[eth_typing.encoding.HexStr]

Transaction type.

class matic.json_types.IAllowanceTransactionOption[source]

Bases: matic.json_types.ITransactionOption, matic.json_types.ITransactionRequestConfig

Transaction config for approve/allowance methods.

spender_address: typing_extensions.NotRequired[eth_typing.evm.HexAddress]

Address of spender.

spender - third-party user or a smart contract which can transfer your token on your behalf.

from: typing_extensions.NotRequired[eth_typing.evm.HexAddress]
to: eth_typing.evm.HexAddress

Transaction recipient.

value: int

MATIC (ETH) amount to send.

gas_limit: int

Upper limit of gas allowed to be spent during transaction execution.

gas_price: int

Upper limit of gas price.

data: bytes

Data to send.

nonce: int

Transaction nonce (number of previously sent transactions).

chain_id: int

Chain id (5 for Goerli).

chain: str

Chain name.

hardfork: str

Hard fork (London, Byzantium, Istanbul, …).

max_fee_per_gas: int

ERP-1159 fee specification.

max_priority_fee_per_gas: int

ERP-1159 fee specification.

type: Optional[eth_typing.encoding.HexStr]

Transaction type.

return_transaction: typing_extensions.NotRequired[bool]

Skip writing step and return prepared transaction.

class matic.json_types.IExitTransactionOption[source]

Bases: matic.json_types.ITransactionOption, matic.json_types.ITransactionRequestConfig

Transaction config for withdraw_exit_* operations.

burn_event_signature: typing_extensions.NotRequired[bytes]

Signature in case you need to adjust default used.

from: typing_extensions.NotRequired[eth_typing.evm.HexAddress]
to: eth_typing.evm.HexAddress

Transaction recipient.

value: int

MATIC (ETH) amount to send.

gas_limit: int

Upper limit of gas allowed to be spent during transaction execution.

gas_price: int

Upper limit of gas price.

data: bytes

Data to send.

nonce: int

Transaction nonce (number of previously sent transactions).

chain_id: int

Chain id (5 for Goerli).

chain: str

Chain name.

hardfork: str

Hard fork (London, Byzantium, Istanbul, …).

max_fee_per_gas: int

ERP-1159 fee specification.

max_priority_fee_per_gas: int

ERP-1159 fee specification.

type: Optional[eth_typing.encoding.HexStr]

Transaction type.

return_transaction: typing_extensions.NotRequired[bool]

Skip writing step and return prepared transaction.

class matic.json_types.ITransactionData(transaction_hash: bytes, nonce: int, block_hash: bytes | None, block_number: int | None, transaction_index: int | None, from_: eth_typing.evm.HexAddress, to: Optional[eth_typing.evm.HexAddress], value: int, gas_price: int, gas: int, input: eth_typing.encoding.HexStr)[source]

Bases: object

Transaction parameters that can be obtained from blockchain.

transaction_hash: bytes

Hash of transaction.

nonce: int

Transaction nonce.

block_hash: bytes | None

Hash of a block where transaction was included.

block_number: int | None

Number of a block where transaction was included.

transaction_index: int | None

Index of a transaction in the block.

from_: eth_typing.evm.HexAddress

Sender.

to: Optional[eth_typing.evm.HexAddress]

Recipient.

value: int

Transferred token amount.

gas_price: int

Actual gas price.

gas: int

Gas amount used.

input: eth_typing.encoding.HexStr

Input data.

class matic.json_types.NeighbourClientConfig[source]

Bases: dict, object

Configuration for parent/child of Web3SideChainClient.

provider: Any

Web3 provider to use.

default_config: matic.json_types.ConfigWithFrom

Any required configuration (must include “from” key).

class matic.json_types.IBaseClientConfig[source]

Bases: dict, object

Configuration for Web3SideChainClient.

network: str

Network to connect to - ‘testnet’ or ‘mainnet’.

version: str

Network version - ‘mumbai’ or ‘v1’.

parent: typing_extensions.NotRequired[matic.json_types.NeighbourClientConfig]

Parent chain configuration.

child: typing_extensions.NotRequired[matic.json_types.NeighbourClientConfig]

Child chain configuration.

class matic.json_types.IPOSClientConfig[source]

Bases: matic.json_types.IBaseClientConfig

Configuration for POS client.

root_chain_manager: typing_extensions.NotRequired[eth_typing.evm.HexAddress]

Root chain manager address.

root_chain: typing_extensions.NotRequired[eth_typing.evm.HexAddress]

Root chain address.

erc_1155_mintable_predicate: typing_extensions.NotRequired[eth_typing.evm.HexAddress]

Mintable predicate for ERC-1155 token address.

network: str

Network to connect to - ‘testnet’ or ‘mainnet’.

version: str

Network version - ‘mumbai’ or ‘v1’.

parent: typing_extensions.NotRequired[matic.json_types.NeighbourClientConfig]

Parent chain configuration.

child: typing_extensions.NotRequired[matic.json_types.NeighbourClientConfig]

Child chain configuration.

class matic.json_types.IPlasmaClientConfig[source]

Bases: matic.json_types.IBaseClientConfig

Configuration for plasma bridge client.

deposit_manager: typing_extensions.NotRequired[Optional[eth_typing.evm.HexAddress]]

Deposit manager address.

withdraw_manager: typing_extensions.NotRequired[Optional[eth_typing.evm.HexAddress]]

Withdraw manager address.

registry: typing_extensions.NotRequired[Optional[eth_typing.evm.HexAddress]]

Registry address.

root_chain: typing_extensions.NotRequired[Optional[eth_typing.evm.HexAddress]]

Root chain address.

erc_20_predicate: typing_extensions.NotRequired[Optional[eth_typing.evm.HexAddress]]

Predicate address for ERC-20 tokens.

erc_721_predicate: typing_extensions.NotRequired[Optional[eth_typing.evm.HexAddress]]

Predicate address for ERC-721 tokens.

network: str

Network to connect to - ‘testnet’ or ‘mainnet’.

version: str

Network version - ‘mumbai’ or ‘v1’.

parent: typing_extensions.NotRequired[matic.json_types.NeighbourClientConfig]

Parent chain configuration.

child: typing_extensions.NotRequired[matic.json_types.NeighbourClientConfig]

Child chain configuration.

class matic.json_types.IBaseBlock(size: int, difficulty: int, total_difficulty: int, number: int, hash: bytes, parent_hash: bytes, nonce: int, gas_limit: int, gas_used: int, timestamp: int, logs_bloom: bytes, transactions_root: bytes, state_root: bytes, receipts_root: bytes, miner: bytes, extra_data: bytes, uncles: Sequence[bytes], sha3_uncles: bytes, base_fee_per_gas: Optional[int] = None)[source]

Bases: object

Base block parameters.

size: int

Block size.

difficulty: int

Block difficulty - how hard it was to mine it.

total_difficulty: int

Accumulated sum of all block difficulties till this one (inclusive).

number: int

Block number.

hash: bytes

Block hash.

parent_hash: bytes

Hash of parent block.

nonce: int

Block nonce.

gas_limit: int

TOtal block gas limit.

gas_used: int

Used amount of gas.

timestamp: int

Moment when the block got mined.

logs_bloom: bytes

Binary representtion of logs Bloom filter.

transactions_root: bytes

Transactions trie root.

state_root: bytes

State trie root.

receipts_root: bytes

Receipts trie root.

miner: bytes

Miner signature.

extra_data: bytes

Any extra binary data that was attached to the block.

uncles: Sequence[bytes]

Blocks that got mined at the same time as this one (similar to orphan blocks).

sha3_uncles: bytes

Hashes of uncles.

base_fee_per_gas: int | None = None

Minimal fee per gas unit in block.

class matic.json_types.IBlock(size: int, difficulty: int, total_difficulty: int, number: int, hash: bytes, parent_hash: bytes, nonce: int, gas_limit: int, gas_used: int, timestamp: int, logs_bloom: bytes, transactions_root: bytes, state_root: bytes, receipts_root: bytes, miner: bytes, extra_data: bytes, uncles: typing.Sequence[bytes], sha3_uncles: bytes, base_fee_per_gas: typing.Optional[int] = None, transactions: typing.Sequence[bytes] = <factory>)[source]

Bases: matic.json_types.IBaseBlock

Block with raw transactions (bytes).

transactions: Sequence[bytes]

Encoded (binary) transactions data.

class matic.json_types.IBlockWithTransaction(size: int, difficulty: int, total_difficulty: int, number: int, hash: bytes, parent_hash: bytes, nonce: int, gas_limit: int, gas_used: int, timestamp: int, logs_bloom: bytes, transactions_root: bytes, state_root: bytes, receipts_root: bytes, miner: bytes, extra_data: bytes, uncles: typing.Sequence[bytes], sha3_uncles: bytes, base_fee_per_gas: typing.Optional[int] = None, transactions: typing.Sequence[matic.json_types.ITransactionData] = <factory>)[source]

Bases: matic.json_types.IBaseBlock

Block with decoded transactions.

transactions: Sequence[matic.json_types.ITransactionData]

Decoded (dict-formatted) transactions data.

class matic.json_types.IPOSContracts(root_chain_manager: RootChainManager, exit_util: ExitUtil[IPOSClientConfig])[source]

Bases: object

Return type of get_pos_contracts parameter of matic.pos.pos_token.POSToken.

root_chain_manager: RootChainManager

Root chain manager.

exit_util: ExitUtil[IPOSClientConfig]

Helper class instance for building exit data.

class matic.json_types.IPlasmaContracts(deposit_manager: DepositManager, registry: RegistryContract, exit_util: ExitUtil[IPlasmaClientConfig], withdraw_manager: WithdrawManager)[source]

Bases: object

Return type of get_helper_contracts parameter of matic.plasma.plasma_token.PlasmaToken.

deposit_manager: DepositManager

Deposit manager instance.

registry: RegistryContract

Registry contract instance.

exit_util: ExitUtil[IPlasmaClientConfig]

Helper class instance for building exit data.

withdraw_manager: WithdrawManager

Withdraw manager instance.

class matic.json_types.IRootBlockInfo(start: int, end: int, header_block_number: int)[source]

Bases: object

Root block info (used in proofs).

start: int

Block start number.

end: int

Block end number.

header_block_number: int

Header block number - root block number in which child block exist.

class matic.json_types.ITransactionWriteResult[source]

Bases: abc.ABC

Interface for result of process_write method.

abstract property transaction_hash: bytes

Get hash of executed transaction.

abstract property transaction_config: matic.json_types.ITransactionRequestConfig

Get transaction parameters.

property receipt: matic.json_types.ITransactionReceipt

Property for convenient access to receipt.

abstract get_receipt(timeout: int = Ellipsis) matic.json_types.ITransactionReceipt[source]

Get receipt (wait max timeout seconds).

class matic.json_types.ILog(address: eth_typing.evm.HexAddress, data: str, topics: Sequence[bytes], log_index: int, transaction_hash: bytes, transaction_index: int, block_hash: bytes, block_number: int, removed: bool)[source]

Bases: object

Log data.

address: eth_typing.evm.HexAddress

Log address.

data: str

Hashed log data (0x hex string).

topics: Sequence[bytes]

List of binary topics values.

log_index: int

Index of log in the sequence.

transaction_hash: bytes

Hash of transaction this log is attached to.

transaction_index: int

Index of transaction this log is attached to.

block_hash: bytes

Hash of the block that includes transaction this log is attached to.

block_number: int

Number of the block that includes transaction this log is attached to.

removed: bool

Whether this log was removed.

class matic.json_types.IEventLog(event: str, address: bytes, return_values: Any, log_index: int, transaction_hash: bytes, transaction_index: int, block_hash: bytes, block_number: int, raw: Optional[matic.json_types._RawLogData] = None)[source]

Bases: object

Event logs (can occur in transaction receipts).

event: str

Event name.

address: bytes

Event address.

return_values: Any

Event return values.

log_index: int

Index of log in the sequence.

transaction_hash: bytes

Hash of transaction this log is attached to.

transaction_index: int

Index of transaction this log is attached to.

block_hash: bytes

Hash of the block that includes transaction this log is attached to.

block_number: int

Number of the block that includes transaction this log is attached to.

raw: matic.json_types._RawLogData | None = None

Raw event data.

class matic.json_types.ITransactionReceipt(transaction_hash: bytes, transaction_index: int, block_hash: bytes, block_number: int, from_: eth_typing.encoding.HexStr, to: eth_typing.encoding.HexStr, contract_address: typing.Optional[eth_typing.evm.ChecksumAddress], cumulative_gas_used: int, gas_used: int, logs_bloom: bytes, root: typing.Optional[eth_typing.encoding.HexStr], type: eth_typing.encoding.HexStr, status: typing.Optional[bool] = None, logs: typing.Sequence[matic.json_types.ILog] = <factory>, events: dict[str, matic.json_types.IEventLog] = <factory>)[source]

Bases: object

Transaction receipt format used internally.

transaction_hash: bytes

Hash of transaction this log is attached to.

transaction_index: int

Index of transaction this log is attached to.

block_hash: bytes

Hash of the block that includes transaction this log is attached to.

block_number: int

Number of the block that includes transaction this log is attached to.

from_: eth_typing.encoding.HexStr

Sender address.

to: eth_typing.encoding.HexStr

Recipient address.

contract_address: Optional[eth_typing.evm.ChecksumAddress]

Address of the contract transaction interacts with.

cumulative_gas_used: int

Total cumulative amount of gas used.

gas_used: int

Total amount of gas used.

logs_bloom: bytes

Binary logs Bloom filter representation.

root: Optional[eth_typing.encoding.HexStr]

Transaction root (hex string).

type: eth_typing.encoding.HexStr

0x).

Type

Transaction type (hex string

status: bool | None = None

0 on failure, 1 on success.

Type

Transaction status

logs: Sequence[matic.json_types.ILog]

Logs data.

events: dict[str, matic.json_types.IEventLog]

Events data.

class matic.json_types.CheckpointedBlock(start: int, end: int, header_block_number: int, block_number: int, proposer: eth_typing.encoding.HexStr, root: eth_typing.encoding.HexStr, created_at: int, message: str)[source]

Bases: matic.json_types.IRootBlockInfo

Block info obtained from API to construct a proof.

header_block_number: int

Header block number.

block_number: int

Number of a block.

start: int

Block start.

end: int

Block end.

proposer: eth_typing.encoding.HexStr

Block proposer address.

root: eth_typing.encoding.HexStr

Block root.

created_at: int

Block creation timestamp.

message: str

Message attached to the block.

class matic.json_types.IReceiptProof[source]

Bases: dict, object

Receipt proof.

block_hash: bytes

Hash of the block.

parent_nodes: list[tuple[bytes, bytes]]

List of all parent nodes in raw form.

root: bytes

Receipt root.

path: bytes

Path obtained with trie.

value: bytes

Trie node value.

Services

Data:

DEFAULT_ABI_STORE_URL

Default url of ABI store.

DEFAULT_PROOF_API_URL

Default url of proof API.

Functions:

get_abi

Get ABI dict for contract.

get_address

Fetch dictionary with addresses of contracts deployed on network.

get_block_included

Get block information by number.

get_proof

Get proof from API.

matic.services.DEFAULT_ABI_STORE_URL: str = 'https://static.matic.network/network'

Default url of ABI store. Can be altered if needed.

matic.services.DEFAULT_PROOF_API_URL: str = ''

Default url of proof API. Must be set to use fast proofs.

matic.services.get_abi(network: str, version: str, bridge_type: str, contract_name: str, base_url: Optional[str] = None) dict[str, Any][source]

Get ABI dict for contract.

matic.services.get_address(network: str, version: str, base_url: Optional[str] = None) dict[str, Any][source]

Fetch dictionary with addresses of contracts deployed on network.

matic.services.get_block_included(network: str, block_number: int, base_url: Optional[str] = None) matic.json_types.CheckpointedBlock[source]

Get block information by number.

matic.services.get_proof(network: str, start: int, end: int, block_number: int, base_url: Optional[str] = None) bytes[source]

Get proof from API.