Specify and Use Contracts

To specify the contracts to use we only need to declare an alias and the contract address for it. Using this alias we allow for the execution of this contract using Python's dot notation alias.func() .

This contract is specified to the agent using a dictionary:

contracts = {
    "alias_one": "0x1234567",
    "alias_two": "0x1234567",
}

agent = GizaAgent(
    ...,
    contracts=contracts,
)

This way when we want to use a contract within an agent we can easily access it using Python's dot notation, like the following example

with agent.execute() as contracts:
    contracts.alias_one.<the contract function>(...)
    contracts.alias_two.<the contract function>(...)

It is mandatory to used the contracts inside the with statement of the execute() command so contracts are available and loaded.

The contracts must be deployed to be of use.

Also, you are responsible for handling what function to use and the parameters that it needs, as we only provide the abstraction of the execution.

Last updated