AgentNFT
AgentNFT is an extension of the Agency main contract and is fully ERC721 compatible. Users may only hold 1 NFT at a time. The NFT contract handles most of the business logic, with transfers directed back to the main contract's transfer function. Transferring agents can only be done via the AgentNFT contract.
supportsInterface
Checks if the contract supports a given interface. Interface identification is specified in ERC-165.
Parameters:
interfaceID
bytes4
Interface ID to check.
Return Values:
None
bool
True if the contract supports the interface.
tokenURI
Retrieves metadata for a specified token ID, including owner, tier, birth, and parent details from the Agency
contract, and calls_tokenURI
.
Parameters:
tokenId
uint
ID of the token.
Return Values:
None
string
Token URI.
_tokenURI
Internal function to construct the token URI. It constructs an SVG image with this information and encodes it into Base64. The resulting Base64 string is embedded in a JSON format, forming the final URI. This URI provides detailed information for displaying the NFT, such as name, description, and image, serving external applications or services.
Parameters:
tokenId
uint
ID of the token.
parent
uint
ID of the parent.
tier
uint
Tier of the agent.
birth
uint
Timestamp of the agent's creation.
Return Values:
output
string
Token URI.
totalSupply
Returns the total number of tokens.
Return Values:
None
uint
Total supply of tokens.
balanceOf
Returns the balance of tokens for a given owner.
Parameters:
owner
address
Address of the token owner.
Return Values:
balance
uint
Token balance of the owner.
ownerOf
Returns the owner of a given token.
Parameters:
tokenId
uint
ID of the token.
Return Values:
owner
address
Owner address of the token.
onMint
Invoked by the Agency
contract during the minting of a new token, its sole purpose is to emit the Transfer event.
Parameters:
user
address
Address of the user receiving the token.
tokenId
uint
ID of the minted token.
safeTransferFrom
Safely transfers a token from one address to another. This function simply calls the other safeTransferFrom
with the bytes data ''
.
Parameters:
from
address
Address of the sender.
to
address
Address of the receiver.
tokenId
uint
ID of the token.
approve
Approves an address to manage the specified token.
Parameters:
to
address
Address to be approved.
tokenId
uint
ID of the token.
setApprovalForAll
Sets or revokes approval for an operator to manage all tokens of the sender.
Parameters:
operator
address
Address of the operator.
approved
bool
Approval status.
transferFrom
Transfers a token from one address to another.
Parameters:
from
address
Address of the sender.
to
address
Address of the receiver.
tokenId
uint
ID of the token.
_isContract
Internal function to check if an address is a contract. It checks if the provided address corresponds to a smart contract by examining its bytecode size. It returns true
if the size is greater than zero; otherwise, it returns false
.
Parameters:
account
address
Address to check.
Return Values:
None
bool
True if the address is a contract.
safeTransferFrom
Facilitates the secure transfer of an ERC721 token from one address (from
) to another (to
). It invokes the internal _transferFrom
function, updating token ownership. If the recipient (to
) is a smart contract, it checks whether it implements the IERC721Receiver
interface. If implemented, it calls the onERC721Received
function, ensuring the expected selector is returned. Any deviation or failure is appropriately handled, providing robust and safe token transfers in ERC721-compliant contracts.
Parameters:
from
address
Address of the sender.
to
address
Address of the receiver.
tokenId
uint
ID of the token.
data
bytes
Additional data.
Last updated