verbs.sim.BaseAgent#
- class BaseAgent[source]#
Simulation agent interface/base-class
Simulation agents should implement 2 methods:
update
is called each for each agent for each step of the model, should update the state of the agent and return a list of transactions to process in the next block.record
is called at the end of each step, should return data to record over the course of the simulation
Note
Creating an agent does not automatically create a corresponding account im the EVM, this should be created using the
verbs.sim.BaseAgent.deploy()
method, orverbs.envs.EmptyEnv.create_account()
.- deploy(env: EmptyEnvRandom | EmptyEnvGasPriority | ForkEnvRandom | ForkEnvGasPriority, address: bytes, eth: int)[source]#
Assign an address and create an account
Assign this agent an address, and create a corresponding account in the EVM for use by this agent.
- record(env: EmptyEnvRandom | EmptyEnvGasPriority | ForkEnvRandom | ForkEnvGasPriority) Any [source]#
Record the state of the agent
This method is called at the end of each step for all agents. It should return any data to be recorded over the course of the simulation.
- Parameters:
env (
verbs.types.Env
) – Network/EVM that the simulation interacts with.- Returns:
Current recorded state for this agent.
- update(rng: Generator, env: EmptyEnvRandom | EmptyEnvGasPriority | ForkEnvRandom | ForkEnvGasPriority) List[Tuple[bytes, bytes, bytes, bool, int | None, int | None, int | None]] [source]#
Update the state of the agent each step
This method should not directly update the state of the EVM, and changes should be performed by returning a list of
verbs.types.Transaction
. This method can however call the EVM without committing changes to the EVM, for example to retrieve data from contracts.- Parameters:
rng (
numpy.random.Generator
) – Numpy random generator, should be used for any random sampling to ensure determinism of the simulation.env (
verbs.types.Env
) – Network/EVM that the simulation interacts with.
- Returns:
list[Transaction]
– List of transactions to be processed in the next block of the simulation. This can be an empty list if the agent is not submitting any transactions.