Skip to content

AgentRegistryCore

_stakeThreshold

struct IStakeSubject.StakeThreshold _stakeThreshold

frontRunningDelay

uint256 frontRunningDelay

AgentCommitted

event AgentCommitted(bytes32 commit)

AgentUpdated

event AgentUpdated(uint256 agentId, address by, string metadata, uint256[] chainIds)

StakeThresholdChanged

event StakeThresholdChanged(uint256 min, uint256 max, bool activated)

FrontRunningDelaySet

event FrontRunningDelaySet(uint256 delay)

onlyOwnerOf

modifier onlyOwnerOf(uint256 agentId)

Checks sender (or metatx signer) is owner of the agent token.

Name Type Description
agentId uint256 ERC1155 token id of the agent.

onlySorted

modifier onlySorted(uint256[] array)

Checks if array of uint256 is sorted from lower (index 0) to higher (array.length -1)

Name Type Description
array uint256[] to check

prepareAgent

function prepareAgent(bytes32 commit) public

Save commit representing an agent to prevent frontrunning of their creation

Name Type Description
commit bytes32 keccak256 hash of the agent creation's parameters

createAgent

function createAgent(uint256 agentId, address owner, string metadata, uint256[] chainIds) public

Agent creation method. Mints an ERC1155 token with the agent id for the owner and stores metadata.

fires _before and _after hooks within the inheritance tree. If front run protection is enabled (disabled by default), it will check if the keccak256 hash of the parameters has been committed in prepareAgent(bytes32).

Name Type Description
agentId uint256 ERC1155 token id of the agent to be created.
owner address address to have ownership privileges in the agent methods.
metadata string IPFS pointer to agent's metadata JSON.
chainIds uint256[] ordered list of chainIds where the agent wants to run.

isCreated

function isCreated(uint256 agentId) public view returns (bool)

Checks if the agentId has been minted.

Name Type Description
agentId uint256 ERC1155 token id of the agent.
Name Type Description
[0] bool true if agentId exists, false otherwise.

updateAgent

function updateAgent(uint256 agentId, string metadata, uint256[] chainIds) public

Updates parameters of an agentId (metadata, image, chain IDs...) if called by the agent owner.

fires _before and _after hooks within the inheritance tree.

Name Type Description
agentId uint256 ERC1155 token id of the agent to be updated.
metadata string IPFS pointer to agent's metadata JSON.
chainIds uint256[] ordered list of chainIds where the agent wants to run.

setStakeThreshold

function setStakeThreshold(struct IStakeSubject.StakeThreshold newStakeThreshold) external

StakeThreshold setter, common to all Agents. Restricted to AGENT_ADMIN_ROLE, emits StakeThresholdChanged

getStakeThreshold

function getStakeThreshold(uint256) public view returns (struct IStakeSubject.StakeThreshold)

stake threshold common for all agents

_isStakedOverMin

function _isStakedOverMin(uint256 subject) internal view returns (bool)

Checks if agent is staked over minimum stake

Name Type Description
subject uint256 agentId
Name Type Description
[0] bool true if agent is staked over the minimum threshold, or staking is not yet enabled (stakeController = 0). false otherwise

setFrontRunningDelay

function setFrontRunningDelay(uint256 delay) external

allows AGENT_ADMIN_ROLE to activate frontrunning protection for agents

Name Type Description
delay uint256 in seconds

_beforeAgentUpdate

function _beforeAgentUpdate(uint256 agentId, string newMetadata, uint256[] newChainIds) internal virtual

hook fired before agent creation or update.

does nothing in this contract.

Name Type Description
agentId uint256 ERC1155 token id of the agent to be created or updated.
newMetadata string IPFS pointer to agent's metadata JSON.
newChainIds uint256[] ordered list of chainIds where the agent wants to run.

_agentUpdate

function _agentUpdate(uint256 agentId, string newMetadata, uint256[] newChainIds) internal virtual

logic for agent update.

emits AgentUpdated, will be extended by child contracts.

Name Type Description
agentId uint256 ERC1155 token id of the agent to be created or updated.
newMetadata string IPFS pointer to agent's metadata JSON.
newChainIds uint256[] ordered list of chainIds where the agent wants to run.

_afterAgentUpdate

function _afterAgentUpdate(uint256 agentId, string newMetadata, uint256[] newChainIds) internal virtual

hook fired after agent creation or update.

emits Router hook.

Name Type Description
agentId uint256 ERC1155 token id of the agent to be created or updated.
newMetadata string IPFS pointer to agent's metadata JSON.
newChainIds uint256[] ordered list of chainIds where the agent wants to run.

_msgSender

function _msgSender() internal view virtual returns (address sender)

Obligatory inheritance dismambiguation of ForwardedContext's _msgSender()

Name Type Description
sender address msg.sender if not a meta transaction, signer of forwarder metatx if it is.

_msgData

function _msgData() internal view virtual returns (bytes)

Obligatory inheritance dismambiguation of ForwardedContext's _msgSender()

Name Type Description
[0] bytes sender msg.data if not a meta transaction, forwarder data in metatx if it is.

__gap

uint256[41] __gap