Request form
Cookbook may introduce a token in the future. Share and contribute to be eligible for future airdrops.
close icon
relevant tag icon
Farcaster Name Registry
copy icon
Farcaster.xyz
• version 1.0.0
ERC721
Social
Registry

Farcaster Name Registry

NameRegistry enables any ETH address to claim a Farcaster Name (fname). A name is a * rentable ERC-721 that can be registered for one year by paying a fee. On expiry, the * owner has 30 days to renew the name by paying a fee, or it is placed in a dutch * auction. The NameRegistry starts in a trusted mode where only a trusted caller can * register an fname and can move to an untrusted mode where any address can register an * fname. The Registry implements a recovery system which allows the custody address to * nominate a recovery address that can transfer the fname to a new address after a delay.

*Visit desktop site to download or deploy

Version

1.0.0

Recent Use

🍞 0x6674 downloaded
🥐 0x5Eb6 downloaded
🥖 0x5Eb6 saved

Last Publish

10/19/2022
Any contract you deploy is yours.
Fully owned and controlled by your wallet.
Documentation
Source Code
initialize(string,string,address,address) :
This function is the initializer for the UUPS token contract. It sets up the token name, symbol, vault, and pool address. It also initializes the ERC721, Pausable, AccessControl, and UUPSUpgradeable contracts. It sets the default admin role to the message sender, sets the vault and pool addresses, sets the initial fee, and sets the trustedOnly flag to true. (autogenerated documentation)
generateCommit(bytes16,address,bytes32,address) :
This function generates a commit hash based on the parameters passed in. It takes a file name (fname), an address to send the file to (to), a secret (secret), and a recovery address (recovery). It then validates the file name using the _validateName() function and then generates a commit hash using the keccak256() function. The commit hash is generated by encoding the parameters passed in and hashing them with keccak256. (autogenerated documentation)
makeCommit(bytes32) :
This function allows a user to make a commit to the contract. It first checks if the user is trusted, and if not, it reverts the transaction. It then checks if the commit is being replayed by comparing the current block timestamp to the timestamp of the commit plus a delay. If the commit is being replayed, the transaction is reverted. Finally, the timestamp of the commit is set to the current block timestamp. (autogenerated documentation)
register(bytes16,address,bytes32,address) :
This function is used to register a domain name on the blockchain. It takes four parameters: a bytes16 fname, an address to, a bytes32 secret, and an address recovery. It first generates a commit using the parameters, then checks if the msg.value is greater than the fee. It then checks if the commit is valid, and if so, it mints a token with the given tokenId. It then sets the expiry of the token to the current block timestamp plus the registration period, and sets the recovery address. Finally, it checks if there is an overpayment and if so, sends it back to the sender. (autogenerated documentation)
trustedRegister(bytes16,address,address,uint256,uint256) :
This function is used to register a new token with a given name (fname) to a given address (to). It also sets a recovery address (recovery) and emits an Invite event with the inviter and invitee details. The function first checks that the caller is authorized and then validates the name of the token. It then mints the token to the given address and sets the expiry date for the token. Finally, it sets the recovery address and emits the Invite event. (autogenerated documentation)
renew(uint256) :
This function allows a user to renew a token that has already been registered. It requires the user to pay a fee, which is stored in the _fee variable. The function then checks to make sure that the token is registered and that it is within the renewal period. If these conditions are met, the expiry date of the token is updated and a Renew event is emitted. Finally, any overpayment is sent back to the user. (autogenerated documentation)
bid(address,uint256,address) :
This function allows a user to bid on a tokenId. It first checks if the tokenId is registered and if the auction has started. It then calculates the price of the bid based on the BID_START_PRICE, BID_PERIOD_DECREASE_UD60X18, and the fee. If the user's bid is less than the calculated price, the bid is reverted. The tokenId is then transferred to the user, the expiryOf the tokenId is updated, and the recoveryOf the tokenId is set. Finally, if there is an overpayment, the overpayment is sent back to the user. (autogenerated documentation)
ownerOf(uint256) :
This function is an override of the ownerOf() function from the ERC721 contract. It checks if the tokenId provided has an expiry timestamp associated with it, and if so, it checks if the current block timestamp is greater than or equal to the expiry timestamp. If so, it reverts the transaction with an Expired() error. If not, it calls the original ownerOf() function from the ERC721 contract to return the address of the owner of the tokenId. (autogenerated documentation)
transferFrom(address,address,uint256) :
This function is used to transfer a token with a given tokenId from one address to another. It first checks if the token has expired by comparing the current block timestamp to the expiry timestamp stored in the expiryOf mapping. If the token has expired, the function will revert. Otherwise, it will call the transferFrom function from the parent contract to complete the transfer. (autogenerated documentation)
safeTransferFrom(address,address,uint256) :
This function is an override of the safeTransferFrom function from the ERC721 contract. It adds an additional check to ensure that the token being transferred has not expired. It does this by checking the expiryOf mapping for the tokenId, which stores the timestamp of when the token expires. If the current block timestamp is greater than or equal to the expiry timestamp, the transfer is reverted. Otherwise, the transfer is allowed to proceed. (autogenerated documentation)
tokenURI(uint256) :
This function takes in a tokenId as an argument and returns a string memory that is the URI of the token. It does this by first converting the tokenId to a bytes16, then validating the name. It then finds the last character index of the bytes16 and creates a new bytes array with the length of the last character index + 1. It then loops through the bytes16 and adds each character to the new bytes array. Finally, it returns a string that is the combination of the BASE_URI, the string of the new bytes array, and ".json". (autogenerated documentation)
_beforeTokenTransfer(address,address,uint256) :
This function is an internal override function that is called before a token transfer is executed. It is used to ensure that the transfer is valid and that the token is not paused. It calls the _beforeTokenTransfer function from the superclass, which performs the necessary checks to ensure that the transfer is valid. (autogenerated documentation)
_afterTokenTransfer(address,address,uint256) :
This function is an internal override of the _afterTokenTransfer function in the ERC721 contract. It is triggered after a token transfer has been completed. It removes the recovery clock and recovery address associated with the tokenId from the mappings. This ensures that the token is no longer associated with any recovery address or clock, and is now owned by the new address. (autogenerated documentation)
changeRecoveryAddress(uint256,address) :
This function allows the owner of a token to change the address associated with the token's recovery. It first checks that the caller is the owner of the token, and then sets the recovery address for the token to the address provided. If a recovery clock was previously set for the token, it is deleted. Finally, an event is emitted to signal that the recovery address has been changed. (autogenerated documentation)
requestRecovery(uint256,address) :
This function allows the owner of a token to request a recovery of the token to a specified address. It first checks that the address to which the token is being recovered is valid, and then checks that the message sender is the recovery owner of the token. It then sets the recovery clock of the token to the current block timestamp, and sets the recovery destination of the token to the specified address. Finally, it emits an event to notify of the recovery request. (autogenerated documentation)
completeRecovery(uint256) :
This function is used to complete a recovery process for a token with a given tokenId. It checks that the current timestamp is greater than the expiry of the token, that the msg.sender is the recoveryOf the token, that the recoveryClock is not 0, and that the current timestamp is greater than the recoveryClock plus the escrow period. If all of these conditions are met, it transfers the token from the owner to the recoveryDestination. (autogenerated documentation)
cancelRecovery(uint256) :
This function allows the owner of a token or the designated recovery address to cancel a recovery process for a token. It first checks that the sender is either the owner of the token or the designated recovery address. If not, it reverts the transaction. It then checks if a recovery process has been initiated for the token. If not, it reverts the transaction. If a recovery process has been initiated, it deletes the recovery clock and emits a CancelRecovery event. (autogenerated documentation)
reclaim(uint256) :
This function allows a Moderator to reclaim a token from an owner and transfer it to a pool. The function first checks if the caller is a Moderator, and if not, it reverts. It then checks if the token is registered, and if not, it reverts. The function then transfers the token from the owner to the pool. Finally, if the current block timestamp is greater than the expiry of the token minus the renewal period, the expiry of the token is set to the current block timestamp plus the renewal period. (autogenerated documentation)
changeTrustedCaller(address) :
This function allows an admin to change the trusted caller address of the contract. It takes an address as an argument and sets the trustedCaller variable to the address provided. It then emits an event to signal that the trusted caller has been changed. (autogenerated documentation)
disableTrustedOnly() :
This function allows an admin to disable the "trustedOnly" setting on the contract. This setting is used to restrict certain functions to only be accessible by trusted users. When the admin calls this function, the "trustedOnly" setting is deleted, and an event is emitted to indicate that the setting has been disabled. (autogenerated documentation)
changeVault(address) :
This function allows an admin to change the address of the vault associated with the contract. It takes in an address as an argument and sets the vault address to the address provided. It also emits an event to notify that the vault address has been changed. (autogenerated documentation)
changePool(address) :
This function allows an admin to change the address of the pool associated with the contract. It takes an address as an argument and sets the pool variable to the address provided. It then emits an event to notify that the pool has been changed. (autogenerated documentation)
changeFee(uint256) :
This function allows the treasurer to change the fee associated with the contract. It takes in a uint256 parameter, _fee, which is the new fee that will be set. The function first checks if the sender has the TREASURER_ROLE, and if not, it reverts the transaction. If the sender does have the TREASURER_ROLE, the fee is set to the new value and an event, ChangeFee, is emitted with the new fee as a parameter. (autogenerated documentation)
withdraw(uint256) :
This function allows a user with the TREASURER_ROLE to withdraw funds from the contract. It first checks that the user has the TREASURER_ROLE, then checks that the contract has enough funds to cover the withdrawal amount. If both of these conditions are met, it calls the vault contract with the withdrawal amount and returns a success or failure status. (autogenerated documentation)
pause() :
This function pauses the contract by setting the paused boolean variable to true. It can only be called by an operator with the OPERATOR_ROLE, and will revert if the caller does not have this role. (autogenerated documentation)
unpause() :
This function allows an operator to unpause the contract. It checks if the caller has the operator role, and if so, calls the internal _unpause() function to unpause the contract. (autogenerated documentation)
_msgSender() :
This function is used to retrieve the address of the sender of a message. It works by calling the _msgSender() function from the ERC2771ContextUpgradeable contract, which returns the address of the sender. (autogenerated documentation)
_msgData() :
This function is an internal view function that is used to retrieve the data associated with a particular message call. It overrides the _msgData() function from the ERC2771ContextUpgradeable contract, which is used to access the data associated with a message call. The function returns the data as a byte array (calldata). (autogenerated documentation)
supportsInterface(bytes4) :
This function checks whether a given interfaceId is supported by the ERC721Upgradeable contract. It does this by calling the supportsInterface() function of the ERC721Upgradeable contract, passing in the interfaceId as an argument. If the interfaceId is supported, the function returns true, otherwise it returns false. (autogenerated documentation)
_authorizeUpgrade(address) :
This function is used to authorize an upgrade of the contract. It checks if the message sender has the ADMIN_ROLE, and if not, it reverts the transaction. This ensures that only authorized users can upgrade the contract. (autogenerated documentation)
_validateName(bytes16) :
This function is used to validate a name that is passed in as a bytes16 parameter. It checks that the name is between 1 and 16 characters long, and that each character is either a lowercase letter, a number, or a hyphen. If any of these conditions are not met, the function will revert with an InvalidName error. (autogenerated documentation)

Get Cookin'
share iconShare

copy iconDownload Source
copy iconnpx cookbookdev i Farcaster-Name-Registry
copy icon

Recent Use

🍞 0x6674 downloaded
🥐 0x5Eb6 downloaded
🥖 0x5Eb6 saved

Last Publish

10/19/2022

Version

1.0.0

Cookbook is free.
Any contract you deploy is yours.
Your contract is owned and controlled by you.