CrossSync Logo

Crossbell

Cross-platform, ring a bell.


Explore the Wiki »

View Website · Join Discord · Report Bug

Docs lint tests checks Mythx Security Analysis codecov

🐳 Introduction

Crossbell is an ownership platform composed of

  1. an EVM-compatible blockchain
  2. a protocol implemented by a set of smart contracts

Specifically, the information generated from social activities will be the initial form of data-ownership by users on Crossbell.

This repository is the implementation of the protocol.

⚙ Development

Install foundry if you don't have one:

# install foundry curl -L https://foundry.paradigm.xyz | bash foundryup

Compile and run tests:

yarn yarn test #run single test function using --match-test forge test --match-test testXXX -vvvvv #run single test contract using --match-contract forge test --match-contract xxxTest -vvvvv #run a group of tests using --match-path forge test --match-path test/... -vvvvv

Deploy:

forge script scripts/Deploy.s.sol:Deploy --private-key $PRIVATE_KEY --broadcast --legacy --rpc-url $RPC_URL --ffi forge script scripts/Deploy.s.sol:Deploy --sig 'sync()' --private-key $PRIVATE_KEY --broadcast --legacy --rpc-url $RPC_URL --ffi

Contents

ERC721

Git Source

Inherits: Context, ERC165, IERC721, IERC721Metadata

Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including the Metadata extension, but not including the Enumerable extension, which is available separately as {ERC721Enumerable}.

State Variables

_name

string private _name;

_symbol

string private _symbol;

_owners

mapping(uint256 => address) private _owners;

_balances

mapping(address => uint256) private _balances;

_tokenApprovals

mapping(uint256 => address) private _tokenApprovals;

_operatorApprovals

mapping(address => mapping(address => bool)) private _operatorApprovals;

Functions

__ERC721_Init

function __ERC721_Init(string calldata name_, string calldata symbol_) internal;

supportsInterface

See {IERC165-supportsInterface}.

function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool);

balanceOf

See {IERC721-balanceOf}.

function balanceOf(address owner) public view virtual override returns (uint256);

ownerOf

See {IERC721-ownerOf}.

function ownerOf(uint256 tokenId) public view virtual override returns (address);

name

See {IERC721Metadata-name}.

function name() public view virtual override returns (string memory);

symbol

See {IERC721Metadata-symbol}.

function symbol() public view virtual override returns (string memory);

tokenURI

See {IERC721Metadata-tokenURI}.

function tokenURI(uint256) public view virtual override returns (string memory);

approve

See {IERC721-approve}.

function approve(address to, uint256 tokenId) public virtual override;

getApproved

See {IERC721-getApproved}.

function getApproved(uint256 tokenId) public view virtual override returns (address);

setApprovalForAll

See {IERC721-setApprovalForAll}.

function setApprovalForAll(address operator, bool approved) public virtual override;

isApprovedForAll

See {IERC721-isApprovedForAll}.

function isApprovedForAll(address owner, address operator) public view virtual override returns (bool);

transferFrom

See {IERC721-transferFrom}.

function transferFrom(address from, address to, uint256 tokenId) public virtual override;

safeTransferFrom

See {IERC721-safeTransferFrom}.

function safeTransferFrom(address from, address to, uint256 tokenId) public virtual override;

safeTransferFrom

See {IERC721-safeTransferFrom}.

function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) public virtual override;

_safeTransfer

*Safely transfers tokenId token from from to to, checking first that contract recipients are aware of the ERC721 protocol to prevent tokens from being forever locked. _data is additional data, it has no specified format and it is sent in call to to. This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. implement alternative mechanisms to perform token transfer, such as signature-based. Requirements:

  • from cannot be the zero address.
  • to cannot be the zero address.
  • tokenId token must exist and be owned by from.
  • If to refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. Emits a {Transfer} event.*
function _safeTransfer(address from, address to, uint256 tokenId, bytes memory _data) internal virtual;

_exists

Returns whether tokenId exists. Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. Tokens start existing when they are minted (_mint), and stop existing when they are burned (_burn).

function _exists(uint256 tokenId) internal view virtual returns (bool);

_isApprovedOrOwner

*Returns whether spender is allowed to manage tokenId. Requirements:

  • tokenId must exist.*
function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool);

_safeMint

*Safely mints tokenId and transfers it to to. Requirements:

  • tokenId must not exist.
  • If to refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. Emits a {Transfer} event.*
function _safeMint(address to, uint256 tokenId) internal virtual;

_safeMint

Same as {xref-ERC721-_safeMint-address-uint256-}[_safeMint], with an additional data parameter which is forwarded in {IERC721Receiver-onERC721Received} to contract recipients.

function _safeMint(address to, uint256 tokenId, bytes memory _data) internal virtual;

_mint

*Mints tokenId and transfers it to to. WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible Requirements:

  • tokenId must not exist.
  • to cannot be the zero address. Emits a {Transfer} event.*
function _mint(address to, uint256 tokenId) internal virtual;

_burn

*Destroys tokenId. The approval is cleared when the token is burned. Requirements:

  • tokenId must exist. Emits a {Transfer} event.*
function _burn(uint256 tokenId) internal virtual;

_transfer

*Transfers tokenId from from to to. As opposed to {transferFrom}, this imposes no restrictions on msg.sender. Requirements:

  • to cannot be the zero address.
  • tokenId token must be owned by from. Emits a {Transfer} event.*
function _transfer(address from, address to, uint256 tokenId) internal virtual;

_approve

Approve to to operate on tokenId Emits a {Approval} event.

function _approve(address to, uint256 tokenId) internal virtual;

_setApprovalForAll

Approve operator to operate on all of owner tokens Emits a {ApprovalForAll} event.

function _setApprovalForAll(address owner, address operator, bool approved) internal virtual;

_checkOnERC721Received

Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. The call is not executed if the target address is not a contract.

function _checkOnERC721Received(address from, address to, uint256 tokenId, bytes memory _data) private returns (bool);

Parameters

NameTypeDescription
fromaddressaddress representing the previous owner of the given token ID
toaddresstarget address that will receive the tokens
tokenIduint256uint256 ID of the token to be transferred
_databytesbytes optional data to send along with the call

Returns

NameTypeDescription
<none>boolbool whether the call correctly returned the expected magic value

_beforeTokenTransfer

*Hook that is called before any token transfer. This includes minting and burning. Calling conditions:

  • When from and to are both non-zero, from's tokenId will be transferred to to.
  • When from is zero, tokenId will be minted for to.
  • When to is zero, from's tokenId will be burned.
  • from and to are never both zero. To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].*
function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual;

_afterTokenTransfer

*Hook that is called after any transfer of tokens. This includes minting and burning. Calling conditions:

  • when from and to are both non-zero.
  • from and to are never both zero. To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].*
function _afterTokenTransfer(address from, address to, uint256 tokenId) internal virtual;

ERC721Enumerable

Git Source

Inherits: ERC721, IERC721Enumerable

State Variables

_ownedTokens

mapping(address => mapping(uint256 => uint256)) private _ownedTokens;

_ownedTokensIndex

mapping(uint256 => uint256) private _ownedTokensIndex;

_allTokens

uint256[] private _allTokens;

_allTokensIndex

mapping(uint256 => uint256) private _allTokensIndex;

Functions

supportsInterface

See {IERC165-supportsInterface}.

function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool);

tokenOfOwnerByIndex

See {IERC721Enumerable-tokenOfOwnerByIndex}.

function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256);

totalSupply

See {IERC721Enumerable-totalSupply}.

function totalSupply() public view virtual override returns (uint256);

tokenByIndex

See {IERC721Enumerable-tokenByIndex}.

function tokenByIndex(uint256 index) public view virtual override returns (uint256);

_beforeTokenTransfer

*Hook that is called before any token transfer. This includes minting and burning. Calling conditions:

  • When from and to are both non-zero, from's tokenId will be transferred to to.
  • When from is zero, tokenId will be minted for to.
  • When to is zero, from's tokenId will be burned.
  • from cannot be the zero address.
  • to cannot be the zero address. To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].*
function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual override;

_addTokenToOwnerEnumeration

Private function to add a token to this extension's ownership-tracking data structures.

function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private;

Parameters

NameTypeDescription
toaddressaddress representing the new owner of the given token ID
tokenIduint256uint256 ID of the token to be added to the tokens list of the given address

_addTokenToAllTokensEnumeration

Private function to add a token to this extension's token tracking data structures.

function _addTokenToAllTokensEnumeration(uint256 tokenId) private;

Parameters

NameTypeDescription
tokenIduint256uint256 ID of the token to be added to the tokens list

_removeTokenFromOwnerEnumeration

Private function to remove a token from this extension's ownership-tracking data structures. Note that while the token is not assigned a new owner, the _ownedTokensIndex mapping is not updated: this allows for gas optimizations e.g. when performing a transfer operation (avoiding double writes). This has O(1) time complexity, but alters the order of the _ownedTokens array.

function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private;

Parameters

NameTypeDescription
fromaddressaddress representing the previous owner of the given token ID
tokenIduint256uint256 ID of the token to be removed from the tokens list of the given address

_removeTokenFromAllTokensEnumeration

Private function to remove a token from this extension's token tracking data structures. This has O(1) time complexity, but alters the order of the _allTokens array.

function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private;

Parameters

NameTypeDescription
tokenIduint256uint256 ID of the token to be removed from the tokens list

LinklistBase

Git Source

Inherits: ERC165

State Variables

_name

string private _name;

_symbol

string private _symbol;

_owners

For compatibility with previous ERC721Enumerable, we need to keep the unused slots for upgradeability.

mapping(uint256 => address) private _owners;

_balances

mapping(address => uint256) private _balances;

_tokenApprovals

mapping(uint256 => address) private _tokenApprovals;

_operatorApprovals

mapping(address => mapping(address => bool)) private _operatorApprovals;

_ownedTokens

mapping(address => mapping(uint256 => uint256)) private _ownedTokens;

_ownedTokensIndex

mapping(uint256 => uint256) private _ownedTokensIndex;

_allTokens

uint256[] private _allTokens;

_allTokensIndex

mapping(uint256 => uint256) private _allTokensIndex;

Functions

_initialize

function _initialize(string calldata name_, string calldata symbol_) internal;

supportsInterface

See {IERC165-supportsInterface}.

function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165) returns (bool);

name

See {IERC721Metadata-name}.

function name() public view returns (string memory);

symbol

See {IERC721Metadata-symbol}.

function symbol() public view returns (string memory);

NFTBase

Git Source

Inherits: ERC721Enumerable

Functions

_initialize

function _initialize(string calldata name, string calldata symbol) internal;

burn

function burn(uint256 tokenId) public virtual;

Contents

IERC20Mintable

Git Source

Functions

mint

function mint(address to, uint256 amount) external;

ILinkModule

Git Source

Functions

initializeLinkModule

function initializeLinkModule(uint256 characterId, uint256 noteId, string calldata name, string calldata symbol) external returns (bytes memory);
function processLink(address to, uint256 characterId, uint256 noteId, bytes calldata data) external;

ILinkModule4Address

Git Source

Functions

initializeLinkModule

function initializeLinkModule(address account, bytes calldata data) external returns (bytes memory);
function processLink(address account, uint256 noteId, bytes calldata data) external;

ILinkModule4Character

Git Source

Functions

initializeLinkModule

function initializeLinkModule(uint256 characterId, bytes calldata data) external returns (bytes memory);
function processLink(address caller, uint256 characterId, bytes calldata data) external;

ILinkModule4ERC721

Git Source

Functions

initializeLinkModule

function initializeLinkModule(address tokenAddress, uint256 tokenId, bytes calldata data) external returns (bytes memory);
function processLink(address account, address tokenAddress, uint256 tokenId, bytes calldata data) external;

ILinkModule4Linklist

Git Source

Functions

initializeLinkModule

function initializeLinkModule(uint256 tokenId, bytes calldata data) external returns (bytes memory);
function processLink(address account, uint256 tokenId, bytes calldata data) external;

ILinkModule4Note

Git Source

Functions

initializeLinkModule

function initializeLinkModule(uint256 characterId, uint256 noteId, bytes calldata data) external returns (bytes memory);
function processLink(address caller, uint256 characterId, uint256 noteId, bytes calldata data) external;

ILinklist

Git Source

Functions

initialize

Initializes the contract.

function initialize(string calldata name_, string calldata symbol_, address web3Entry_) external;

Parameters

NameTypeDescription
name_stringThe name of the token.
symbol_stringThe symbol of the token.
web3Entry_addressThe address of the Web3Entry contract.

mint

Mints a Linklist NFT to the specified character with linkType. This can only be called by web3Entry.

function mint(uint256 characterId, bytes32 linkType) external returns (uint256 tokenId);

Parameters

NameTypeDescription
characterIduint256The character ID to mint to.
linkTypebytes32The type of link.

Returns

NameTypeDescription
tokenIduint256The minted token ID.

burn

Burns a Linklist NFT.

Only web3Entry can burn the Linklist NFT.

function burn(uint256 tokenId) external;

Parameters

NameTypeDescription
tokenIduint256The token ID to burn.

setUri

Sets URI for a linklist.

You can set any URI for your linklist, and the functionality of this URI is undetermined and expandable. One scenario that comes to mind is setting a cover for your liked notes or following list in your bookmarks.

function setUri(uint256 tokenId, string memory uri) external;

Parameters

NameTypeDescription
tokenIduint256The token ID to set URI.
uristringThe new URI to set.

setLinkType

Sets the link type of the linklist NFT.

function setLinkType(uint256 tokenId, bytes32 linkType) external;

Parameters

NameTypeDescription
tokenIduint256The token ID of linklist to set.
linkTypebytes32The link type to set.

addLinkingCharacterId

Adds a linked character to a linklist.

function addLinkingCharacterId(uint256 tokenId, uint256 toCharacterId) external;

Parameters

NameTypeDescription
tokenIduint256The token ID of linklist.
toCharacterIduint256The character ID to link.

removeLinkingCharacterId

Removes a linked character from a linklist.

function removeLinkingCharacterId(uint256 tokenId, uint256 toCharacterId) external;

Parameters

NameTypeDescription
tokenIduint256The token ID of linklist.
toCharacterIduint256The character ID to remove.

addLinkingNote

Adds a linked note to a linklist.

function addLinkingNote(uint256 tokenId, uint256 toCharacterId, uint256 toNoteId) external returns (bytes32);

Parameters

NameTypeDescription
tokenIduint256The token ID of linklist.
toCharacterIduint256The character ID to link.
toNoteIduint256The note ID to link.

Returns

NameTypeDescription
<none>bytes32linkKey The link key.

removeLinkingNote

Removes a linked note from a linklist.

function removeLinkingNote(uint256 tokenId, uint256 toCharacterId, uint256 toNoteId) external;

Parameters

NameTypeDescription
tokenIduint256The token ID of linklist.
toCharacterIduint256The character ID to remove.
toNoteIduint256The note ID to remove.

addLinkingERC721

Adds a linked ERC721 to a linklist.

function addLinkingERC721(uint256 tokenId, address tokenAddress, uint256 erc721TokenId) external returns (bytes32);

Parameters

NameTypeDescription
tokenIduint256The token ID of linklist.
tokenAddressaddressThe address of ERC721 contract.
erc721TokenIduint256The token ID of ERC721.

Returns

NameTypeDescription
<none>bytes32linkKey The link key of ERC721.

removeLinkingERC721

Removes a linked ERC721 from a linklist.

function removeLinkingERC721(uint256 tokenId, address tokenAddress, uint256 erc721TokenId) external;

Parameters

NameTypeDescription
tokenIduint256The token ID of linklist.
tokenAddressaddressThe address of ERC721 contract.
erc721TokenIduint256The token ID of ERC721.

addLinkingAddress

Adds a linked address to a linklist.

function addLinkingAddress(uint256 tokenId, address ethAddress) external;

Parameters

NameTypeDescription
tokenIduint256The token ID of linklist.
ethAddressaddressThe address to link.

removeLinkingAddress

Removes a linked address from a linklist.

function removeLinkingAddress(uint256 tokenId, address ethAddress) external;

Parameters

NameTypeDescription
tokenIduint256The token ID of linklist.
ethAddressaddressThe address to remove.

addLinkingAnyUri

Adds a linked anyURI to a linklist.

function addLinkingAnyUri(uint256 tokenId, string memory toUri) external returns (bytes32);

Parameters

NameTypeDescription
tokenIduint256The token ID of linklist.
toUristringThe anyURI to link.

Returns

NameTypeDescription
<none>bytes32linkKey The link key of anyURI.

removeLinkingAnyUri

Removes a linked anyURI from a linklist.

function removeLinkingAnyUri(uint256 tokenId, string memory toUri) external;

Parameters

NameTypeDescription
tokenIduint256The token ID of linklist.
toUristringThe anyURI to remove.

addLinkingLinklistId

Adds a linked linklist to a linklist.

function addLinkingLinklistId(uint256 tokenId, uint256 linklistId) external;

Parameters

NameTypeDescription
tokenIduint256The token ID of linklist.
linklistIduint256The linklist ID to link.

removeLinkingLinklistId

Removes a linked linklist from a linklist.

function removeLinkingLinklistId(uint256 tokenId, uint256 linklistId) external;

Parameters

NameTypeDescription
tokenIduint256The token ID of linklist.
linklistIduint256The linklist ID to remove.

getLinkingCharacterIds

Returns the linked character IDs of the linklist NFT.

function getLinkingCharacterIds(uint256 tokenId) external view returns (uint256[] memory);

Parameters

NameTypeDescription
tokenIduint256The token ID of linklist to check.

Returns

NameTypeDescription
<none>uint256[]The linked character IDs.

getLinkingCharacterListLength

Returns the length of linked character IDs of the linklist NFT.

function getLinkingCharacterListLength(uint256 tokenId) external view returns (uint256);

Parameters

NameTypeDescription
tokenIduint256The token ID of linklist to check.

Returns

NameTypeDescription
<none>uint256The length of linked character IDs .

getOwnerCharacterId

Returns the character ID who owns the linklist NFT.

function getOwnerCharacterId(uint256 tokenId) external view returns (uint256);

Parameters

NameTypeDescription
tokenIduint256The token ID of linklist to check.

Returns

NameTypeDescription
<none>uint256The character ID who owns the linklist NFT.

getLinkingNotes

Returns the linked notes of the linklist NFT.

function getLinkingNotes(uint256 tokenId) external view returns (DataTypes.NoteStruct[] memory results);

Parameters

NameTypeDescription
tokenIduint256The token ID of linklist to check.

Returns

NameTypeDescription
resultsDataTypes.NoteStruct[]The linked notes.

getLinkingNote

Return the linked note of the linklist NFT by linkKey.

function getLinkingNote(bytes32 linkKey) external view returns (DataTypes.NoteStruct memory);

Parameters

NameTypeDescription
linkKeybytes32The link key of the note.

Returns

NameTypeDescription
<none>DataTypes.NoteStructThe linked note.

getLinkingNoteListLength

Returns the length of linked notes of the linklist NFT.

function getLinkingNoteListLength(uint256 tokenId) external view returns (uint256);

Parameters

NameTypeDescription
tokenIduint256The token ID of linklist to check.

Returns

NameTypeDescription
<none>uint256The length of linked notes.

getLinkingERC721s

Returns the linked ERC721s of the linklist NFT.

function getLinkingERC721s(uint256 tokenId) external view returns (DataTypes.ERC721Struct[] memory results);

Parameters

NameTypeDescription
tokenIduint256The token ID of linklist to check.

Returns

NameTypeDescription
resultsDataTypes.ERC721Struct[]The linked ERC721s.

getLinkingERC721

Return the linked ERC721 of the linklist NFT by linkKey.

function getLinkingERC721(bytes32 linkKey) external view returns (DataTypes.ERC721Struct memory);

Parameters

NameTypeDescription
linkKeybytes32The link key of the ERC721.

Returns

NameTypeDescription
<none>DataTypes.ERC721StructThe linked ERC721.

getLinkingERC721ListLength

Returns the length of linked ERC721s of the linklist NFT.

function getLinkingERC721ListLength(uint256 tokenId) external view returns (uint256);

Parameters

NameTypeDescription
tokenIduint256The token ID of linklist to check.

Returns

NameTypeDescription
<none>uint256The length of linked ERC721s.

getLinkingAddresses

Returns the linked addresses of the linklist NFT.

function getLinkingAddresses(uint256 tokenId) external view returns (address[] memory);

Parameters

NameTypeDescription
tokenIduint256The token ID of linklist to check.

Returns

NameTypeDescription
<none>address[]The linked addresses.

getLinkingAddressListLength

Returns the linked address of the linklist NFT by linkKey.

function getLinkingAddressListLength(uint256 tokenId) external view returns (uint256);

Parameters

NameTypeDescription
tokenIduint256The token ID of linklist to check.

Returns

NameTypeDescription
<none>uint256The length of linked address.

getLinkingAnyUris

Returns the linked anyURIs of the linklist NFT.

function getLinkingAnyUris(uint256 tokenId) external view returns (string[] memory results);

Parameters

NameTypeDescription
tokenIduint256The token ID of linklist to check.

Returns

NameTypeDescription
resultsstring[]The linked anyURIs.

getLinkingAnyUri

Return the linked anyURI of the linklist NFT by linkKey.

function getLinkingAnyUri(bytes32 linkKey) external view returns (string memory);

Parameters

NameTypeDescription
linkKeybytes32The link key of the anyURI.

Returns

NameTypeDescription
<none>stringThe linked anyURI.

getLinkingAnyUriKeys

Returns the length of linked anyURIs of the linklist NFT.

function getLinkingAnyUriKeys(uint256 tokenId) external view returns (bytes32[] memory);

Parameters

NameTypeDescription
tokenIduint256The token ID of linklist to check.

Returns

NameTypeDescription
<none>bytes32[]The length of linked anyURIs.

getLinkingAnyListLength

Returns the length of linked Uris of the linklist NFT.

function getLinkingAnyListLength(uint256 tokenId) external view returns (uint256);

Parameters

NameTypeDescription
tokenIduint256The token ID of linklist to check.

Returns

NameTypeDescription
<none>uint256The length of linked Uris.

getLinkingLinklistIds

Returns the linked linklists of the linklist NFT.

function getLinkingLinklistIds(uint256 tokenId) external view returns (uint256[] memory);

Parameters

NameTypeDescription
tokenIduint256The token ID of linklist to check.

Returns

NameTypeDescription
<none>uint256[]The linked linklists.

getLinkingLinklistLength

Return the length of linked linklist of the linklist NFT.

function getLinkingLinklistLength(uint256 tokenId) external view returns (uint256);

Parameters

NameTypeDescription
tokenIduint256The token ID of linklist to check.

Returns

NameTypeDescription
<none>uint256The length of linked linklist.

getCurrentTakeOver

This function is deprecated..

function getCurrentTakeOver(uint256 tokenId) external view returns (uint256);

getLinkType

Returns the link type of the linklist NFT.

function getLinkType(uint256 tokenId) external view returns (bytes32);

Parameters

NameTypeDescription
tokenIduint256The token ID of linklist to check.

Returns

NameTypeDescription
<none>bytes32The link type.

Uri

Returns the URI of the linklist NFT.

function Uri(uint256 tokenId) external view returns (string memory);

Parameters

NameTypeDescription
tokenIduint256The token ID of linklist to check.

Returns

NameTypeDescription
<none>stringThe URI of the linklist NFT.

characterOwnerOf

Returns the character ID who owns the Linklist NFT.

function characterOwnerOf(uint256 tokenId) external view returns (uint256);

Parameters

NameTypeDescription
tokenIduint256The token ID to check.

Returns

NameTypeDescription
<none>uint256The character ID.

totalSupply

Returns the total supply of the Linklist NFTs.

function totalSupply() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256The total supply of the Linklist NFTs.

balanceOf

Returns the balance of the character.

function balanceOf(uint256 characterId) external view returns (uint256);

Parameters

NameTypeDescription
characterIduint256The character ID to check.

Returns

NameTypeDescription
<none>uint256uint256 The balance of the character.

balanceOf

Returns the balance of the address.

function balanceOf(address account) external view returns (uint256 balance);

Parameters

NameTypeDescription
accountaddressThe address to check.

Returns

NameTypeDescription
balanceuint256The balance of the address.

ownerOf

Returns the owner of the tokenId token.

function ownerOf(uint256 tokenId) external view returns (address);

Parameters

NameTypeDescription
tokenIduint256The token ID to check.

Returns

NameTypeDescription
<none>addressThe owner of the tokenId token.

IMintModule4Note

Git Source

Functions

initializeMintModule

Initialize the MintModule for a specific note.

function initializeMintModule(uint256 characterId, uint256 noteId, bytes calldata data) external returns (bytes memory);

Parameters

NameTypeDescription
characterIduint256The character ID of the note to initialize.
noteIduint256The note ID to initialize.
databytesThe data passed from the user to be decoded.

Returns

NameTypeDescription
<none>bytesbytes The returned data of calling initializeMintModule.

processMint

Processes the mint logic.
Triggered when the mintNote of web3Entry is called, if mint module of note is set.

function processMint(address to, uint256 characterId, uint256 noteId, bytes calldata data) external;

Parameters

NameTypeDescription
toaddressThe receive address of the NFT.
characterIduint256The character ID of the note owner.
noteIduint256The note ID.
databytesThe data passed from the user to be decoded.

IMintNFT

Git Source

Functions

initialize

Initialize the mint nft.

function initialize( uint256 characterId_, uint256 noteId_, address web3Entry_, string calldata name_, string calldata symbol_ ) external;

Parameters

NameTypeDescription
characterId_uint256The character ID of the note to initialize.
noteId_uint256The note ID to initialize.
web3Entry_addressThe address of web3Entry contract.
name_stringThe name to set for this NFT.
symbol_stringThe symbol to set for this NFT.

mint

Mints a note NFT to the specified address. This can only be called by web3Entry, and is called upon note.

function mint(address to) external returns (uint256);

Parameters

NameTypeDescription
toaddressThe address to mint the NFT to.

Returns

NameTypeDescription
<none>uint256uint256 The minted token ID.

setTokenRoyalty

Changes the royalty percentage of specific token ID for secondary sales. Can only be called by character owner of note.

function setTokenRoyalty(uint256 tokenId, address recipient, uint96 fraction) external;

Parameters

NameTypeDescription
tokenIduint256The token ID to set.
recipientaddressThe receive address.
fractionuint96The royalty percentage measured in basis points. Each basis point represents 0.01%.

setDefaultRoyalty

Changes the default royalty percentage for secondary sales. Can only be called by character owner of note.

function setDefaultRoyalty(address recipient, uint96 fraction) external;

Parameters

NameTypeDescription
recipientaddressThe receive address.
fractionuint96The royalty percentage measured in basis points. Each basis point represents 0.01%.

deleteDefaultRoyalty

Deletes the default royalty percentage. Can only be called by character owner of note.

function deleteDefaultRoyalty() external;

originalReceiver

Returns the original receiver of specified NFT.

function originalReceiver(uint256 tokenId) external view returns (address);

Returns

NameTypeDescription
<none>addressThe address of original receiver.

getSourceNotePointer

Returns the source note pointer mapped to this note NFT.

function getSourceNotePointer() external view returns (uint256 characterId, uint256 noteId);

Returns

NameTypeDescription
characterIduint256The character ID.
noteIduint256The note ID.

ITipsWithConfig

Git Source

This is the interface for the TipsWithConfig contract.

Functions

initialize

Initialize the contract, setting web3Entry address.

function initialize(address web3Entry_) external;

Parameters

NameTypeDescription
web3Entry_addressAddress of web3Entry.

setDefaultFeeFraction

Sets the default fee percentage of specific receiver.

The feeReceiver can be a platform account.

function setDefaultFeeFraction(address feeReceiver, uint256 fraction) external;

Parameters

NameTypeDescription
feeReceiveraddressThe fee receiver address.
fractionuint256The percentage measured in basis points. Each basis point represents 0.01%.

setFeeFraction4Character

Sets the fee percentage of specific <receiver, character>.

If this is set, it will override the default fee fraction.

function setFeeFraction4Character(address feeReceiver, uint256 characterId, uint256 fraction) external;

Parameters

NameTypeDescription
feeReceiveraddressThe fee receiver address.
characterIduint256The character ID.
fractionuint256The percentage measured in basis points. Each basis point represents 0.01%.

setTipsConfig4Character

Sets the tips config of specific <fromCharacter, toCharacter>.
Emits a {SetTipsConfig4Character} event.

If the tips config of specific <fromCharacter, toCharacter> is already, it will try to collect the tips first, and then override the tips config.

function setTipsConfig4Character( uint256 fromCharacterId, uint256 toCharacterId, address token, uint256 amount, uint256 startTime, uint256 endTime, uint256 interval, address feeReceiver ) external;

Parameters

NameTypeDescription
fromCharacterIduint256The token ID of character that would send the reward.
toCharacterIduint256The token ID of character that would receive the reward.
tokenaddressThe token address.
amountuint256The amount of token.
startTimeuint256The start time of tips.
endTimeuint256The end time of tips.
intervaluint256The interval of tips.
feeReceiveraddressThe fee receiver address.

cancelTips4Character

Cancels the tips config.
Emits a {CancelTips4Character} event.

It will try to collect the tips first, and then delete the tips config.

function cancelTips4Character(uint256 tipConfigId) external;

Parameters

NameTypeDescription
tipConfigIduint256The tip config ID to cancel.

collectTips4Character

Collects all unredeemed token from the fromCharacter to the toCharacter.
Emits a {CollectTips4Character} event if collects successfully.

It will transfer all unredeemed token from the fromCharacter to the toCharacter.

function collectTips4Character(uint256 tipConfigId) external returns (uint256 collectedAmount);

Parameters

NameTypeDescription
tipConfigIduint256The tip config ID.

Returns

NameTypeDescription
collectedAmountuint256The amount of token collected.

getFeeFraction

Returns the fee percentage of specific <receiver, note>.

It will return the first non-zero value by priority feeFraction4Character and defaultFeeFraction.

function getFeeFraction(address feeReceiver, uint256 characterId) external view returns (uint256);

Parameters

NameTypeDescription
feeReceiveraddressThe fee receiver address.
characterIduint256The character ID .

Returns

NameTypeDescription
<none>uint256fraction The percentage measured in basis points. Each basis point represents 0.01%.

getFeeAmount

Returns how much the fee is owed by <feeFraction, tipAmount>.

function getFeeAmount(address feeReceiver, uint256 characterId, uint256 tipAmount) external view returns (uint256);

Parameters

NameTypeDescription
feeReceiveraddressThe fee receiver address.
characterIduint256The character ID .
tipAmountuint256

Returns

NameTypeDescription
<none>uint256The fee amount.

getTipsConfigId

Return the tips config Id.

function getTipsConfigId(uint256 fromCharacterId, uint256 toCharacterId) external view returns (uint256);

Parameters

NameTypeDescription
fromCharacterIduint256The token ID of character that initiated a reward.
toCharacterIduint256The token ID of character that would receive the reward.

Returns

NameTypeDescription
<none>uint256uint256 Returns tips config ID.

getTipsConfig

Return the tips config.

function getTipsConfig(uint256 tipConfigId) external view returns (TipsConfig memory config);

Parameters

NameTypeDescription
tipConfigIduint256The tip config ID.

getWeb3Entry

Returns the address of web3Entry contract.

function getWeb3Entry() external view returns (address);

Returns

NameTypeDescription
<none>addressThe address of web3Entry contract.

Structs

TipsConfig

struct TipsConfig { uint256 id; uint256 fromCharacterId; uint256 toCharacterId; address token; uint256 amount; uint256 startTime; uint256 endTime; uint256 interval; address feeReceiver; uint256 totalRound; uint256 currentRound; }

ITipsWithFee

Git Source

This is the interface for the TipsWithFee contract.

Functions

initialize

Initializes the TipsWithFee.

function initialize(address web3Entry_, address token_) external;

Parameters

NameTypeDescription
web3Entry_addressAddress of web3Entry.
token_addressAddress of token.

setDefaultFeeFraction

Changes the default fee percentage of specific receiver.

The feeReceiver can be a platform account.

function setDefaultFeeFraction(address feeReceiver, uint256 fraction) external;

Parameters

NameTypeDescription
feeReceiveraddressThe fee receiver address.
fractionuint256The percentage measured in basis points. Each basis point represents 0.01%.

setFeeFraction4Character

Changes the fee percentage of specific <receiver, character>.

If feeFraction4Character is set, it will override the default fee fraction.

function setFeeFraction4Character(address feeReceiver, uint256 characterId, uint256 fraction) external;

Parameters

NameTypeDescription
feeReceiveraddressThe fee receiver address.
characterIduint256The character ID.
fractionuint256The percentage measured in basis points. Each basis point represents 0.01%.

setFeeFraction4Note

Changes the fee percentage of specific <receiver, note>.

If feeFraction4Note is set, it will override feeFraction4Character and the default fee fraction.

function setFeeFraction4Note(address feeReceiver, uint256 characterId, uint256 noteId, uint256 fraction) external;

Parameters

NameTypeDescription
feeReceiveraddressThe fee receiver address.
characterIduint256The character ID .
noteIduint256The note ID .
fractionuint256The percentage measured in basis points. Each basis point represents 0.01%.

getFeeFraction

Returns the fee percentage of specific <receiver, note>.

It will return the first non-zero value by priority feeFraction4Note, feeFraction4Character and defaultFeeFraction.

function getFeeFraction(address feeReceiver, uint256 characterId, uint256 noteId) external view returns (uint256);

Parameters

NameTypeDescription
feeReceiveraddressThe fee receiver address.
characterIduint256The character ID .
noteIduint256The note ID .

Returns

NameTypeDescription
<none>uint256fraction The percentage measured in basis points. Each basis point represents 0.01%.

getFeeAmount

Returns how much the fee is owed by <feeFraction, tipAmount>.

function getFeeAmount(address feeReceiver, uint256 characterId, uint256 noteId, uint256 tipAmount) external view returns (uint256);

Parameters

NameTypeDescription
feeReceiveraddressThe fee receiver address.
characterIduint256The character ID .
noteIduint256The note ID .
tipAmountuint256

Returns

NameTypeDescription
<none>uint256The fee amount.

getWeb3Entry

Returns the address of web3Entry contract.

function getWeb3Entry() external view returns (address);

Returns

NameTypeDescription
<none>addressThe address of web3Entry contract.

getToken

Returns the address of mira token contract.

function getToken() external view returns (address);

Returns

NameTypeDescription
<none>addressThe address of mira token contract.

IWeb3Entry

Git Source

Functions

initialize

Initializes the Web3Entry.

function initialize( string calldata name_, string calldata symbol_, address linklist_, address mintNFTImpl_, address periphery_, address newbieVilla_ ) external;

Parameters

NameTypeDescription
name_stringThe name to set for the web3Entry character NFT.
symbol_stringThe symbol to set for the web3Entry character NFT.
linklist_addressThe address of linklist contract to set.
mintNFTImpl_addressThe address of mintNFTImpl contract to set.
periphery_addressThe address of periphery contract to set.
newbieVilla_addressThe address of newbieVilla contract to set.

createCharacter

This method creates a character with the given parameters to the given address.

function createCharacter(DataTypes.CreateCharacterData calldata vars) external returns (uint256 characterId);

Parameters

NameTypeDescription
varsDataTypes.CreateCharacterDataThe CreateCharacterData struct containing the following parameters: to: The address receiving the character.
handle: The handle to set for the character.
uri: The URI to set for the character metadata.
linkModule: The link module to use, can be the zero address.
linkModuleInitData: The link module initialization data, if any.

setHandle

Sets new handle for a given character.

Owner permission only.

function setHandle(uint256 characterId, string calldata newHandle) external;

Parameters

NameTypeDescription
characterIduint256The character id to set new handle for.
newHandlestringNew handle to set.

setSocialToken

Sets a social token for a given character.

Owner permission only.

function setSocialToken(uint256 characterId, address tokenAddress) external;

Parameters

NameTypeDescription
characterIduint256The characterId to set social token for.
tokenAddressaddressToken address to be set.

setCharacterUri

Sets a new URI for a given character.

function setCharacterUri(uint256 characterId, string calldata newUri) external;

Parameters

NameTypeDescription
characterIduint256The characterId to to be set.
newUristringNew URI to be set.

setPrimaryCharacterId

Sets a given character as primary.

Only character owner can call this function.

function setPrimaryCharacterId(uint256 characterId) external;

Parameters

NameTypeDescription
characterIduint256The character id to to be set.

grantOperatorPermissions

Grant an address as an operator and authorize it with custom permissions.

Every bit in permissionBitMap stands for a corresponding method in Web3Entry. more details in OP.sol.

function grantOperatorPermissions(uint256 characterId, address operator, uint256 permissionBitMap) external;

Parameters

NameTypeDescription
characterIduint256ID of your character that you want to authorize.
operatoraddressAddress to grant operator permissions to.
permissionBitMapuint256Bitmap used for finer grained operator permissions controls.

grantOperatorPermissionsWithSig

Grant an address as an operator and authorize it with custom permissions via signature.

Only character owner can call.

Every bit in permissionBitMap stands for a corresponding method in Web3Entry. more details in OP.sol.

function grantOperatorPermissionsWithSig( uint256 characterId, address operator, uint256 permissionBitMap, DataTypes.EIP712Signature calldata signature ) external;

Parameters

NameTypeDescription
characterIduint256ID of your character that you want to authorize.
operatoraddressAddress to grant operator permissions to.
permissionBitMapuint256Bitmap used for finer grained operator permissions controls.
signatureDataTypes.EIP712SignatureThe EIP712Signature struct containing the character owner's signature.

grantOperators4Note

Grant operators allowlist and blocklist roles of a note.

function grantOperators4Note( uint256 characterId, uint256 noteId, address[] calldata blocklist, address[] calldata allowlist ) external;

Parameters

NameTypeDescription
characterIduint256ID of character that you want to set.
noteIduint256ID of note that you want to set.
blocklistaddress[]blocklist addresses that you want to grant.
allowlistaddress[]allowlist addresses that you want to grant.

setLinklistUri

Sets a new metadataURI for a given link list.

function setLinklistUri(uint256 linkListId, string calldata uri) external;

Parameters

NameTypeDescription
linkListIduint256The linklist id to set for.
uristringThe metadata uri to set.

setLinklistType

Sets a link type for a given linklist.

Emits a {DetachLinklist} event and a {AttachLinklist} event from web3Entry contract..
Emits a {LinkTypeSet} event from linklist contract.
Linklist is the group of all linking objects with the same link type, like "like".
Each character can only have one linklist for each link type.
It will fail if you try to set a link type which is already set for some linklist owned by the same character.

function setLinklistType(uint256 linkListId, bytes32 linkType) external;

Parameters

NameTypeDescription
linkListIduint256The linklist ID to set for.
linkTypebytes32The link type to set.

linkAddress

Links an address with the given parameters.

function linkAddress(DataTypes.linkAddressData calldata vars) external;

Parameters

NameTypeDescription
varsDataTypes.linkAddressDataThe linkAddressData struct containing the linking parameters:
fromCharacterId: The character ID to sponsor a link action.
ethAddress: The address to be linked.
linkType: The link type, like "like", which is a bytes32 format.
data: The data passed to the link module to use, if any.

unlinkAddress

Unlinks an address with the given parameters.

function unlinkAddress(DataTypes.unlinkAddressData calldata vars) external;

Parameters

NameTypeDescription
varsDataTypes.unlinkAddressDataThe unlinkAddressData struct containing the unlinking parameters:
fromCharacterId: The character ID to sponsor a unlink action.
ethAddress: The address to be unlinked.
linkType: The link type, like "like", which is a bytes32 format.

linkCharacter

Links a character with the given parameters.

function linkCharacter(DataTypes.linkCharacterData calldata vars) external;

Parameters

NameTypeDescription
varsDataTypes.linkCharacterDataThe linkCharacterData struct containing the linking parameters:
fromCharacterId: The character ID to sponsor a link action.
toCharacterId: The character ID to be linked.
linkType: The link type, like "follow", which is a bytes32 format.
data: The data passed to the link module to use, if any.

unlinkCharacter

Unlinks a character with the given parameters.

function unlinkCharacter(DataTypes.unlinkCharacterData calldata vars) external;

Parameters

NameTypeDescription
varsDataTypes.unlinkCharacterDataThe unlinkCharacterData struct containing the unlinking parameters: fromCharacterId: The character ID to sponsor a unlink action.
toCharacterId: The character ID to be unlinked.
linkType: The link type, like "follow", which is a bytes32 format.

createThenLinkCharacter

Create a character and then link it.

function createThenLinkCharacter(DataTypes.createThenLinkCharacterData calldata vars) external returns (uint256 characterId);

Parameters

NameTypeDescription
varsDataTypes.createThenLinkCharacterDataThe createThenLinkCharacterData struct containing the parameters:
fromCharacterId: The character ID to sponsor a link action.
to: The address to receive the new character nft.
linkType: The link type, like "follow", which is a bytes32 format.

linkNote

Links a note with the given parameters.

function linkNote(DataTypes.linkNoteData calldata vars) external;

Parameters

NameTypeDescription
varsDataTypes.linkNoteDataThe linkNoteData struct containing the linking parameters:
fromCharacterId: The character ID to sponsor a link action.
toCharacterId: The character ID of note to be linked.
toNoteId: The note ID of note to be linked.
linkType: The link type, like "like", which is a bytes32 format.
data: The data passed to the link module to use, if any.

unlinkNote

UnLinks a note with the given parameters.

function unlinkNote(DataTypes.unlinkNoteData calldata vars) external;

Parameters

NameTypeDescription
varsDataTypes.unlinkNoteDataThe unlinkNoteData struct containing the unlinking parameters:
fromCharacterId: The character ID to sponsor a unlink action.
toCharacterId: The character ID of note to be unlinked.
toNoteId: The note ID of note to be unlinked.
linkType: The link type, like "like", which is a bytes32 format.

linkERC721

Links an ERC721 with the given parameters.

function linkERC721(DataTypes.linkERC721Data calldata vars) external;

Parameters

NameTypeDescription
varsDataTypes.linkERC721DataThe linkERC721Data struct containing the linking parameters:
fromCharacterId: The character ID to sponsor a link action.
tokenAddress: The token address of ERC721 to be linked.
tokenId: The token ID of ERC721 to be linked.
linkType: The link type, like "like", which is a bytes32 format.
data: The data passed to the link module to use, if any.

unlinkERC721

Unlinks an ERC721 with the given parameters.

function unlinkERC721(DataTypes.unlinkERC721Data calldata vars) external;

Parameters

NameTypeDescription
varsDataTypes.unlinkERC721DataThe unlinkERC721Data struct containing the unlinking parameters:
fromCharacterId: The character ID to sponsor a unlink action.
tokenAddress: The token address of ERC721 to be unlinked.
tokenId: The token ID of ERC721 to be unlinked.
linkType: The link type, like "like", which is a bytes32 format.

linkAnyUri

Links any uri with the given parameters.

function linkAnyUri(DataTypes.linkAnyUriData calldata vars) external;

Parameters

NameTypeDescription
varsDataTypes.linkAnyUriDataThe linkAnyUriData struct containing the linking parameters:
fromCharacterId: The character ID to sponsor a link action.
toUri: The uri to be linked.
linkType: The link type, like "like", which is a bytes32 format.
data: The data passed to the link module to use, if any.

unlinkAnyUri

Unlinks any uri with the given parameters.

function unlinkAnyUri(DataTypes.unlinkAnyUriData calldata vars) external;

Parameters

NameTypeDescription
varsDataTypes.unlinkAnyUriDataThe unlinkAnyUriData struct containing the unlinking parameters:
fromCharacterId: The character ID to sponsor a unlink action.
toUri: The uri to be unlinked.
linkType: The link type, like "like", which is a bytes32 format.

Links a linklist with the given parameters.

function linkLinklist(DataTypes.linkLinklistData calldata vars) external;

Parameters

NameTypeDescription
varsDataTypes.linkLinklistDataThe linkLinklistData struct containing the linking parameters:
fromCharacterId: The character ID to sponsor a link action.
toLinkListId: The linklist ID to be linked.
linkType: The link type, like "like", which is a bytes32 format.
data: The data passed to the link module to use, if any.

Unlinks a linklist with the given parameters.

function unlinkLinklist(DataTypes.unlinkLinklistData calldata vars) external;

Parameters

NameTypeDescription
varsDataTypes.unlinkLinklistDataThe unlinkLinklistData struct containing the unlinking parameters:
fromCharacterId: The character ID to sponsor a unlink action.
toLinkListId: The linklist ID to be unlinked.
linkType: The link type, like "like", which is a bytes32 format.

setLinkModule4Character

Sets a link module for a given character.

function setLinkModule4Character(DataTypes.setLinkModule4CharacterData calldata vars) external;

Parameters

NameTypeDescription
varsDataTypes.setLinkModule4CharacterDataThe setLinkModule4CharacterData struct containing the parameters:
characterId: The character ID to set for.
linkModule: The address of link module contract to set.
linkModuleInitData: The data passed to the link module to use, if any.

setLinkModule4Note

Sets a link module for a given note.

function setLinkModule4Note(DataTypes.setLinkModule4NoteData calldata vars) external;

Parameters

NameTypeDescription
varsDataTypes.setLinkModule4NoteDataThe setLinkModule4NoteData struct containing the parameters:
characterId: The character ID to set for.
noteId: The note ID to set for.
linkModule: The address of link module contract to set.
linkModuleInitData: The data passed to the link module to use, if any.

mintNote

Mints an nft with the given note.

function mintNote(DataTypes.MintNoteData calldata vars) external returns (uint256 tokenId);

Parameters

NameTypeDescription
varsDataTypes.MintNoteDataThe MintNoteData struct containing the minting parameters:
characterId: The character ID of the note.
noteId: The note ID of the note.
to: The address to receive the minted nft.
data: The data passed to the mint module to use, if any.

setMintModule4Note

Sets a mint module for the given note.

function setMintModule4Note(DataTypes.setMintModule4NoteData calldata vars) external;

Parameters

NameTypeDescription
varsDataTypes.setMintModule4NoteDataThe setMintModule4NoteData struct containing the setting parameters:
characterId: The character ID of the note.
noteId: The note ID of the note.
mintModule: The address of mint module to set.
mintModuleInitData: The data passed to the mint module to init, if any.

postNote

Posts a note with the given parameters.

function postNote(DataTypes.PostNoteData calldata vars) external returns (uint256 noteId);

Parameters

NameTypeDescription
varsDataTypes.PostNoteDataThe postNoteData struct containing the posting parameters:
characterId: The character ID to post to.
contentUri: The uri to set for the new post.
linkModule: The address of link module to set for the new post.
linkModuleInitData: The data passed to the link module to init, if any.
mintModule: The address of mint module to set for the new post.
mintModuleInitData: The data passed to the mint module to init, if any.

setNoteUri

Set URI for a note.

function setNoteUri(uint256 characterId, uint256 noteId, string calldata newUri) external;

Parameters

NameTypeDescription
characterIduint256The character ID of the note owner.
noteIduint256The ID of the note to set.
newUristringThe new URI.

lockNote

Lock a note and put it into a immutable state where no modifications are allowed. Locked notes are usually assumed as final versions.

function lockNote(uint256 characterId, uint256 noteId) external;

Parameters

NameTypeDescription
characterIduint256The character ID of the note owner.
noteIduint256The ID of the note to lock.

deleteNote

Delete a note.

Deleting a note doesn't essentially mean that the txs or contents are being removed due to the immutability of blockchain itself, but the deleted notes will be tagged as deleted after calling deleteNote.

function deleteNote(uint256 characterId, uint256 noteId) external;

Parameters

NameTypeDescription
characterIduint256The character ID of the note owner.
noteIduint256The ID of the note to delete.

postNote4Character

Posts a note for a given character.

function postNote4Character(DataTypes.PostNoteData calldata vars, uint256 toCharacterId) external returns (uint256 noteId);

Parameters

NameTypeDescription
varsDataTypes.PostNoteDataThe postNoteData struct containing the posting parameters:
characterId: The character ID to post to.
contentUri: The uri to set for the new post.
linkModule: The address of link module to set for the new post.
linkModuleInitData: The data passed to the link module to init, if any.
mintModule: The address of mint module to set for the new post.
mintModuleInitData: The data passed to the mint module to init, if any.
toCharacterIduint256The target character ID.

Returns

NameTypeDescription
noteIduint256The note ID of the new post.

postNote4Address

Posts a note for a given address.

function postNote4Address(DataTypes.PostNoteData calldata vars, address ethAddress) external returns (uint256 noteId);

Parameters

NameTypeDescription
varsDataTypes.PostNoteDataThe postNoteData struct containing the posting parameters:
characterId: The character ID to post to.
contentUri: The uri to set for the new post.
linkModule: The address of link module to set for the new post.
linkModuleInitData: The data passed to the link module to init, if any.
mintModule: The address of mint module to set for the new post.
mintModuleInitData: The data passed to the mint module to init, if any.
ethAddressaddressThe target address.

Returns

NameTypeDescription
noteIduint256The note ID of the new post.

Posts a note for a given linklist.

function postNote4Linklist(DataTypes.PostNoteData calldata vars, uint256 toLinklistId) external returns (uint256 noteId);

Parameters

NameTypeDescription
varsDataTypes.PostNoteDataThe postNoteData struct containing the posting parameters:
characterId: The character ID to post to.
contentUri: The uri to set for the new post.
linkModule: The address of link module to set for the new post.
linkModuleInitData: The data passed to the link module to init, if any.
mintModule: The address of mint module to set for the new post.
mintModuleInitData: The data passed to the mint module to init, if any.
toLinklistIduint256The target linklist.

Returns

NameTypeDescription
noteIduint256The note ID of the new post.

postNote4Note

Posts a note for a given note.

function postNote4Note(DataTypes.PostNoteData calldata vars, DataTypes.NoteStruct calldata note) external returns (uint256 noteId);

Parameters

NameTypeDescription
varsDataTypes.PostNoteDataThe postNoteData struct containing the posting parameters:
characterId: The character ID to post to.
contentUri: The uri to set for the new post.
linkModule: The address of link module to set for the new post.
linkModuleInitData: The data passed to the link module to init, if any.
mintModule: The address of mint module to set for the new post.
mintModuleInitData: The data passed to the mint module to init, if any.
noteDataTypes.NoteStructThe target note struct containing the parameters:
characterId: The character ID of target note.
noteId: The note ID of target note.

Returns

NameTypeDescription
noteIduint256The note ID of the new post.

postNote4ERC721

Posts a note for a given ERC721.

function postNote4ERC721(DataTypes.PostNoteData calldata vars, DataTypes.ERC721Struct calldata erc721) external returns (uint256 noteId);

Parameters

NameTypeDescription
varsDataTypes.PostNoteDataThe postNoteData struct containing the posting parameters:
characterId: The character ID to post to.
contentUri: The uri to set for the new post.
linkModule: The address of link module to set for the new post.
linkModuleInitData: The data passed to the link module to init, if any.
mintModule: The address of mint module to set for the new post.
mintModuleInitData: The data passed to the mint module to init, if any.
erc721DataTypes.ERC721StructThe target ERC721 struct containing the parameters:
tokenAddress: The token address of target ERC721.
erc721TokenId: The token ID of target ERC721.

Returns

NameTypeDescription
noteIduint256The note ID of the new post.

postNote4AnyUri

Posts a note for a given uri.

function postNote4AnyUri(DataTypes.PostNoteData calldata vars, string calldata uri) external returns (uint256 noteId);

Parameters

NameTypeDescription
varsDataTypes.PostNoteDataThe postNoteData struct containing the posting parameters:
characterId: The character ID to post to.
contentUri: The uri to set for the new post.
linkModule: The address of link module to set for the new post.
linkModuleInitData: The data passed to the link module to init, if any.
mintModule: The address of mint module to set for the new post.
mintModuleInitData: The data passed to the mint module to init, if any.
uristringThe target uri(could be an url link).

Returns

NameTypeDescription
noteIduint256The note ID of the new post.

Burns a linklist NFT.

It will burn the linklist NFT and remove the links from a character.

function burnLinklist(uint256 linklistId) external;

Parameters

NameTypeDescription
linklistIduint256The linklist ID to burn.

getOperators

Get operator list of a character. This operator list has only a sole purpose, which is keeping records of keys of operatorsPermissionBitMap. Thus, addresses queried by this function not always have operator permissions. Keep in mind don't use this function to check authorizations!!!

function getOperators(uint256 characterId) external view returns (address[] memory);

Parameters

NameTypeDescription
characterIduint256ID of your character that you want to check.

Returns

NameTypeDescription
<none>address[]All keys of operatorsPermission4NoteBitMap.

getOperatorPermissions

Get permission bitmap of an operator.

function getOperatorPermissions(uint256 characterId, address operator) external view returns (uint256);

Parameters

NameTypeDescription
characterIduint256ID of character that you want to check.
operatoraddressAddress to grant operator permissions to.

Returns

NameTypeDescription
<none>uint256Permission bitmap of this operator.

getOperators4Note

Get operators blocklist and allowlist for a note.

function getOperators4Note(uint256 characterId, uint256 noteId) external view returns (address[] memory blocklist, address[] memory allowlist);

Parameters

NameTypeDescription
characterIduint256ID of character to query.
noteIduint256ID of note to query.

isOperatorAllowedForNote

Query if a operator has permission for a note.

function isOperatorAllowedForNote(uint256 characterId, uint256 noteId, address operator) external view returns (bool);

Parameters

NameTypeDescription
characterIduint256ID of character that you want to query.
noteIduint256ID of note that you want to query.
operatoraddressAddress to query.

Returns

NameTypeDescription
<none>booltrue if Operator has permission for a note, otherwise false.

getPrimaryCharacterId

Returns primary character for a given account.

function getPrimaryCharacterId(address account) external view returns (uint256);

Parameters

NameTypeDescription
accountaddressThe address to query.

Returns

NameTypeDescription
<none>uint256uint256 The primary character ID, which will be 0 if not mapped.

isPrimaryCharacter

Returns whether or not a character is primary character.

function isPrimaryCharacter(uint256 characterId) external view returns (bool);

Parameters

NameTypeDescription
characterIduint256The character ID to query.

Returns

NameTypeDescription
<none>boolbool True if the character is primary, false otherwise.

getCharacter

Returns the full character struct associated with a given character token ID.

function getCharacter(uint256 characterId) external view returns (DataTypes.Character memory);

Parameters

NameTypeDescription
characterIduint256The token ID of the character to query.

Returns

NameTypeDescription
<none>DataTypes.CharacterThe full character struct of given character.

getCharacterByHandle

Returns the full character struct associated with a given character handle.

function getCharacterByHandle(string calldata handle) external view returns (DataTypes.Character memory);

Parameters

NameTypeDescription
handlestringThe handle of the character to query.

Returns

NameTypeDescription
<none>DataTypes.CharacterThe full character struct of given character.

getHandle

Returns the handle of character with a given character.

function getHandle(uint256 characterId) external view returns (string memory);

Parameters

NameTypeDescription
characterIduint256The token ID of the character to query.

Returns

NameTypeDescription
<none>stringThe handle of given character.

getCharacterUri

Returns the uri of character with a given character.

function getCharacterUri(uint256 characterId) external view returns (string memory);

Parameters

NameTypeDescription
characterIduint256The token ID of the character to query.

Returns

NameTypeDescription
<none>stringThe uri of given character.

getNote

Returns the full note struct associated with a given note.

function getNote(uint256 characterId, uint256 noteId) external view returns (DataTypes.Note memory);

Parameters

NameTypeDescription
characterIduint256The token ID of the character to query.
noteIduint256The token ID of the note to query.

Returns

NameTypeDescription
<none>DataTypes.NoteThe full note struct of given note.

getLinklistUri

Returns the uri of linklist with a given linklist.

function getLinklistUri(uint256 tokenId) external view returns (string memory);

Parameters

NameTypeDescription
tokenIduint256The token ID of the linklist to query.

Returns

NameTypeDescription
<none>stringstring The uri of given linklist.

getLinklistId

Returns the token ID of linklist with a given character and linkType.

function getLinklistId(uint256 characterId, bytes32 linkType) external view returns (uint256);

Parameters

NameTypeDescription
characterIduint256The token ID of the character to query.
linkTypebytes32The linkType.

Returns

NameTypeDescription
<none>uint256The token ID of linklist.

getLinklistType

Returns the linkType of linklist with a given linklist.

function getLinklistType(uint256 linkListId) external view returns (bytes32);

Parameters

NameTypeDescription
linkListIduint256The token ID of the linklist to query.

Returns

NameTypeDescription
<none>bytes32bytes32 The linkType of given linklist.

getLinklistContract

Returns the address of linklist contract.

function getLinklistContract() external view returns (address);

Returns

NameTypeDescription
<none>addressThe address of linklist contract.

getDomainSeparator

Returns the domain separator for this NFT contract.

function getDomainSeparator() external view returns (bytes32);

Returns

NameTypeDescription
<none>bytes32bytes32 The domain separator.

nonces

Returns the current nonce for owner. This value must be included whenever a signature is generated by grantOperatorPermissionsWithSig. Every successful call to grantOperatorPermissionsWithSig increases owner's nonce by one. This prevents a signature from being used multiple times.

function nonces(address owner) external view returns (uint256);

Parameters

NameTypeDescription
owneraddressThe owner address to query.

Returns

NameTypeDescription
<none>uint256uint256 The current nonce for owner.

getRevision

Returns the revision number of web3Entry contract.

function getRevision() external pure returns (uint256);

Returns

NameTypeDescription
<none>uint256The the revision number of web3Entry contract.

Contents

CharacterLib

Git Source

Functions

createCharacter

Creates a character.

function createCharacter( address to, string memory handle, string memory uri, address linkModule, bytes memory linkModuleInitData, uint256 characterId, bool validateHandle ) external;

Parameters

NameTypeDescription
toaddressThe address to mint the character to.
handlestringThe handle to set for the new character.
uristringThe URI to set for the new character’s metadata.
linkModuleaddressThe link module to set for the new character or the zero address.
linkModuleInitDatabytesArbitrary data to be decoded in the link module for initialization.
characterIduint256The ID of the new character.
validateHandleboolWhether to validate the handle or not.

setSocialToken

Sets a social token for a given character.

function setSocialToken(uint256 characterId, address tokenAddress) external;

Parameters

NameTypeDescription
characterIduint256The character ID to set social token for.
tokenAddressaddressToken address to be set.

setCharacterLinkModule

Sets link module for a given character.

function setCharacterLinkModule(uint256 characterId, address linkModule, bytes calldata linkModuleInitData) external;

Parameters

NameTypeDescription
characterIduint256The character ID to set link module for.
linkModuleaddressThe link module to set.
linkModuleInitDatabytesThe data to pass to the link module for initialization, if any.

setHandle

Sets new handle for a given character.

function setHandle(uint256 characterId, string calldata newHandle) external;

Parameters

NameTypeDescription
characterIduint256The character ID to set new handle for.
newHandlestringNew handle to set.

_handleHash

function _handleHash(string memory handle) internal pure returns (bytes32);

Constants

Git Source

State Variables

MAX_HANDLE_LENGTH

uint8 public constant MAX_HANDLE_LENGTH = 31;

MIN_HANDLE_LENGTH

uint8 public constant MIN_HANDLE_LENGTH = 3;
bytes32 public constant LINK_ITEM_TYPE_CHARACTER = "Character";
bytes32 public constant LINK_ITEM_TYPE_ADDRESS = "Address";
bytes32 public constant LINK_ITEM_TYPE_LINKLIST = "Linklist";
bytes32 public constant LINK_ITEM_TYPE_NOTE = "Note";
bytes32 public constant LINK_ITEM_TYPE_ERC721 = "ERC721";
bytes32 public constant LINK_ITEM_TYPE_ANYURI = "AnyUri";

DataTypes

Git Source

A standard library of data types.

Structs

MigrateData

struct MigrateData { address account; string handle; string uri; address[] toAddresses; bytes32 linkType; }

CreateCharacterData

struct CreateCharacterData { address to; string handle; string uri; address linkModule; bytes linkModuleInitData; }

createThenLinkCharacterData

struct createThenLinkCharacterData { uint256 fromCharacterId; address to; bytes32 linkType; }

linkNoteData

struct linkNoteData { uint256 fromCharacterId; uint256 toCharacterId; uint256 toNoteId; bytes32 linkType; bytes data; }

unlinkNoteData

struct unlinkNoteData { uint256 fromCharacterId; uint256 toCharacterId; uint256 toNoteId; bytes32 linkType; }

linkCharacterData

struct linkCharacterData { uint256 fromCharacterId; uint256 toCharacterId; bytes32 linkType; bytes data; }

unlinkCharacterData

struct unlinkCharacterData { uint256 fromCharacterId; uint256 toCharacterId; bytes32 linkType; }

linkERC721Data

struct linkERC721Data { uint256 fromCharacterId; address tokenAddress; uint256 tokenId; bytes32 linkType; bytes data; }

unlinkERC721Data

struct unlinkERC721Data { uint256 fromCharacterId; address tokenAddress; uint256 tokenId; bytes32 linkType; }

linkAddressData

struct linkAddressData { uint256 fromCharacterId; address ethAddress; bytes32 linkType; bytes data; }

unlinkAddressData

struct unlinkAddressData { uint256 fromCharacterId; address ethAddress; bytes32 linkType; }

linkAnyUriData

struct linkAnyUriData { uint256 fromCharacterId; string toUri; bytes32 linkType; bytes data; }

unlinkAnyUriData

struct unlinkAnyUriData { uint256 fromCharacterId; string toUri; bytes32 linkType; }

linkLinklistData

struct linkLinklistData { uint256 fromCharacterId; uint256 toLinkListId; bytes32 linkType; bytes data; }

unlinkLinklistData

struct unlinkLinklistData { uint256 fromCharacterId; uint256 toLinkListId; bytes32 linkType; }

setLinkModule4CharacterData

struct setLinkModule4CharacterData { uint256 characterId; address linkModule; bytes linkModuleInitData; }

setLinkModule4NoteData

struct setLinkModule4NoteData { uint256 characterId; uint256 noteId; address linkModule; bytes linkModuleInitData; }

setLinkModule4LinklistData

struct setLinkModule4LinklistData { uint256 linklistId; address linkModule; bytes linkModuleInitData; }

setLinkModule4ERC721Data

struct setLinkModule4ERC721Data { address tokenAddress; uint256 tokenId; address linkModule; bytes linkModuleInitData; }

setLinkModule4AddressData

struct setLinkModule4AddressData { address account; address linkModule; bytes linkModuleInitData; }

setMintModule4NoteData

struct setMintModule4NoteData { uint256 characterId; uint256 noteId; address mintModule; bytes mintModuleInitData; }

linkCharactersInBatchData

struct linkCharactersInBatchData { uint256 fromCharacterId; uint256[] toCharacterIds; bytes[] data; address[] toAddresses; bytes32 linkType; }

LinkData

struct LinkData { uint256 linklistId; uint256 linkItemType; uint256 linkingCharacterId; address linkingAddress; uint256 linkingLinklistId; bytes32 linkKey; }

PostNoteData

struct PostNoteData { uint256 characterId; string contentUri; address linkModule; bytes linkModuleInitData; address mintModule; bytes mintModuleInitData; bool locked; }

MintNoteData

struct MintNoteData { uint256 characterId; uint256 noteId; address to; bytes mintModuleData; }

Character

struct Character { uint256 characterId; string handle; string uri; uint256 noteCount; address socialToken; address linkModule; }

Note

A struct containing data associated with each new note.

struct Note { bytes32 linkItemType; bytes32 linkKey; string contentUri; address linkModule; address mintModule; address mintNFT; bool deleted; bool locked; }

CharacterLinkStruct

struct CharacterLinkStruct { uint256 fromCharacterId; uint256 toCharacterId; bytes32 linkType; }

NoteStruct

struct NoteStruct { uint256 characterId; uint256 noteId; }

ERC721Struct

struct ERC721Struct { address tokenAddress; uint256 erc721TokenId; }

Operators4Note

struct Operators4Note { EnumerableSet.AddressSet blocklist; EnumerableSet.AddressSet allowlist; }

EIP712Signature

A struct containing the necessary information to reconstruct an EIP-712 typed data signature.

struct EIP712Signature { address signer; uint8 v; bytes32 r; bytes32 s; uint256 deadline; }

ErrCharacterNotExists

Git Source

Character ID not exists

error ErrCharacterNotExists(uint256 characterId);

ErrNotAddressOwner

Git Source

Not owner of address

error ErrNotAddressOwner();

ErrNotCharacterOwner

Git Source

Caller is not the owner of character

error ErrNotCharacterOwner();

ErrNoteLocked

Git Source

Note has been locked

error ErrNoteLocked();

ErrHandleExists

Git Source

Handle does not exist

error ErrHandleExists();

ErrSocialTokenExists

Git Source

Social token address does not exist

error ErrSocialTokenExists();

ErrHandleLengthInvalid

Git Source

Handle length too long or too short

error ErrHandleLengthInvalid();

ErrHandleContainsInvalidCharacters

Git Source

Handle contains invalid characters

error ErrHandleContainsInvalidCharacters();

ErrNotEnoughPermission

Git Source

Operator has not enough permission for this character

error ErrNotEnoughPermission();

ErrNotEnoughPermissionForThisNote

Git Source

Operator has not enough permissions for this note

error ErrNotEnoughPermissionForThisNote();

ErrTargetAlreadyHasPrimaryCharacter

Git Source

Target address already has primary character

error ErrTargetAlreadyHasPrimaryCharacter();

ErrNoteIsDeleted

Git Source

Note has been deleted

error ErrNoteIsDeleted();

ErrNoteNotExists

Git Source

Note does not exist

error ErrNoteNotExists();

ErrArrayLengthMismatch

Git Source

Array length mismatch

error ErrArrayLengthMismatch();

ErrCallerNotWeb3Entry

Git Source

Caller is not web3Entry contract

error ErrCallerNotWeb3Entry();

ErrCallerNotWeb3EntryOrNotOwner

Git Source

Caller is not web3Entry contract, and not the owner of character

error ErrCallerNotWeb3EntryOrNotOwner();

ErrTokenIdAlreadyExists

Git Source

Token id already exists

error ErrTokenIdAlreadyExists();

ErrNotExistingCharacter

Git Source

Character does not exist

error ErrNotExistingCharacter();

ErrNotExistingLinklistToken

Git Source

Token id of linklist does not exist

error ErrNotExistingLinklistToken();

ErrInvalidWeb3Entry

Git Source

Invalid web3Entry address

error ErrInvalidWeb3Entry();

ErrNotApprovedOrExceedApproval

Git Source

Not approved by module or exceed the approval amount

error ErrNotApprovedOrExceedApproval();

ErrExceedMaxSupply

Git Source

Exceed max supply

error ErrExceedMaxSupply();

ErrExceedApproval

Git Source

Exceed the approval amount

error ErrExceedApproval();

ErrSignatureExpired

Git Source

Signature is expired

error ErrSignatureExpired();

ErrSignatureInvalid

Git Source

Signature is invalid

error ErrSignatureInvalid();

ErrNotOwner

Git Source

Caller not owner

error ErrNotOwner();

ErrTokenNotExists

Git Source

Token not exists

error ErrTokenNotExists();

ErrLinkTypeExists

Git Source

LinkType already exists

error ErrLinkTypeExists(uint256 characterId, bytes32 linkType);

Events

Git Source

Events

BaseInitialized

event BaseInitialized(string name, string symbol, uint256 timestamp);

Web3EntryInitialized

event Web3EntryInitialized(uint256 timestamp);

LinklistNFTInitialized

event LinklistNFTInitialized(uint256 timestamp);

MintNFTInitialized

event MintNFTInitialized(uint256 characterId, uint256 noteId, uint256 timestamp);

CharacterCreated

event CharacterCreated( uint256 indexed characterId, address indexed creator, address indexed to, string handle, uint256 timestamp );

SetPrimaryCharacterId

event SetPrimaryCharacterId(address indexed account, uint256 indexed characterId, uint256 indexed oldCharacterId);

SetHandle

event SetHandle(address indexed account, uint256 indexed characterId, string newHandle);

SetSocialToken

event SetSocialToken(address indexed account, uint256 indexed characterId, address indexed tokenAddress);

GrantOperatorPermissions

event GrantOperatorPermissions(uint256 indexed characterId, address indexed operator, uint256 permissionBitMap);

GrantOperators4Note

event GrantOperators4Note( uint256 indexed characterId, uint256 indexed noteId, address[] blocklist, address[] allowlist );

SetCharacterUri

event SetCharacterUri(uint256 indexed characterId, string newUri);

PostNote

event PostNote( uint256 indexed characterId, uint256 indexed noteId, bytes32 indexed linkKey, bytes32 linkItemType, bytes data );

SetNoteUri

event SetNoteUri(uint256 indexed characterId, uint256 noteId, string newUri);

DeleteNote

event DeleteNote(uint256 indexed characterId, uint256 noteId);

LockNote

event LockNote(uint256 indexed characterId, uint256 noteId);

LinkCharacter

event LinkCharacter( address indexed account, uint256 indexed fromCharacterId, uint256 indexed toCharacterId, bytes32 linkType, uint256 linklistId );

UnlinkCharacter

event UnlinkCharacter( address indexed account, uint256 indexed fromCharacterId, uint256 indexed toCharacterId, bytes32 linkType );

LinkNote

event LinkNote( uint256 indexed fromCharacterId, uint256 indexed toCharacterId, uint256 indexed toNoteId, bytes32 linkType, uint256 linklistId );

UnlinkNote

event UnlinkNote( uint256 indexed fromCharacterId, uint256 indexed toCharacterId, uint256 indexed toNoteId, bytes32 linkType, uint256 linklistId );

LinkERC721

event LinkERC721( uint256 indexed fromCharacterId, address indexed tokenAddress, uint256 indexed toNoteId, bytes32 linkType, uint256 linklistId );

LinkAddress

event LinkAddress(uint256 indexed fromCharacterId, address indexed ethAddress, bytes32 linkType, uint256 linklistId);

UnlinkAddress

event UnlinkAddress(uint256 indexed fromCharacterId, address indexed ethAddress, bytes32 linkType);

LinkAnyUri

event LinkAnyUri(uint256 indexed fromCharacterId, string toUri, bytes32 linkType, uint256 linklistId);

UnlinkAnyUri

event UnlinkAnyUri(uint256 indexed fromCharacterId, string toUri, bytes32 linkType);
event LinkCharacterLink( uint256 indexed fromCharacterId, bytes32 indexed linkType, uint256 clFromCharacterId, uint256 clToCharacterId, bytes32 clLinkType );
event UnlinkCharacterLink( uint256 indexed fromCharacterId, bytes32 indexed linkType, uint256 clFromCharactereId, uint256 clToCharacterId, bytes32 clLinkType );

UnlinkERC721

event UnlinkERC721( uint256 indexed fromCharacterId, address indexed tokenAddress, uint256 indexed toNoteId, bytes32 linkType, uint256 linklistId );
event LinkLinklist( uint256 indexed fromCharacterId, uint256 indexed toLinklistId, bytes32 linkType, uint256 indexed linklistId );
event UnlinkLinklist( uint256 indexed fromCharacterId, uint256 indexed toLinklistId, bytes32 linkType, uint256 indexed linklistId );

MintNote

event MintNote( address indexed to, uint256 indexed characterId, uint256 indexed noteId, address tokenAddress, uint256 tokenId );

SetLinkModule4Character

event SetLinkModule4Character( uint256 indexed characterId, address indexed linkModule, bytes linkModuleInitData, bytes returnData );

SetLinkModule4Note

event SetLinkModule4Note( uint256 indexed characterId, uint256 indexed noteId, address indexed linkModule, bytes linkModuleInitData, bytes returnData );

SetLinkModule4Address

event SetLinkModule4Address( address indexed account, address indexed linkModule, bytes linkModuleInitData, bytes returnData );

SetLinkModule4ERC721

event SetLinkModule4ERC721( address indexed tokenAddress, uint256 indexed tokenId, address indexed linkModule, bytes linkModuleInitData, bytes returnData );
event SetLinkModule4Linklist( uint256 indexed linklistId, address indexed linkModule, bytes linkModuleInitData, bytes returnData );

SetMintModule4Note

event SetMintModule4Note( uint256 indexed characterId, uint256 indexed noteId, address indexed mintModule, bytes mintModuleInitData, bytes returnData );
event AttachLinklist(uint256 indexed linklistId, uint256 indexed characterId, bytes32 indexed linkType);
event DetachLinklist(uint256 indexed linklistId, uint256 indexed characterId, bytes32 indexed linkType);

SetApprovedMintAmount4Addresses

event SetApprovedMintAmount4Addresses( uint256 indexed characterId, uint256 indexed noteId, uint256 indexed amount, address[] approvedAddresses );

LinkLib

Git Source

Functions

linkCharacter

Links any characterId.

function linkCharacter( uint256 fromCharacterId, uint256 toCharacterId, bytes32 linkType, bytes memory data, address linklist ) external;

Parameters

NameTypeDescription
fromCharacterIduint256The character ID to sponsor a link action.
toCharacterIduint256The character ID to be linked.
linkTypebytes32linkType, like “follow”.
databytesThe data to pass to the link module, if any.
linklistaddressThe linklist contract address.

unlinkCharacter

Unlinks a given character.

function unlinkCharacter(uint256 fromCharacterId, uint256 toCharacterId, bytes32 linkType, address linklist) external;

Parameters

NameTypeDescription
fromCharacterIduint256The character ID to sponsor a unlink action.
toCharacterIduint256The character ID to be unlinked.
linkTypebytes32linkType, like “follow”.
linklistaddressThe linklist contract address.

linkNote

Links a given note.

function linkNote( uint256 fromCharacterId, uint256 toCharacterId, uint256 toNoteId, bytes32 linkType, bytes calldata data, address linklist ) external;

Parameters

NameTypeDescription
fromCharacterIduint256The character ID to sponsor a link action.
toCharacterIduint256The owner characterId of the note to link.
toNoteIduint256The id of the note to link.
linkTypebytes32The linkType, like “follow”.
databytesThe data to pass to the link module, if any.
linklistaddressThe linklist contract address.

unlinkNote

Unlinks a given note.

function unlinkNote( uint256 fromCharacterId, uint256 toCharacterId, uint256 toNoteId, bytes32 linkType, address linklist ) external;

Parameters

NameTypeDescription
fromCharacterIduint256The character ID to sponsor an unlink action.
toCharacterIduint256The character ID of note to unlink.
toNoteIduint256The id of note to unlink.
linkTypebytes32LinkType, like “follow”.
linklistaddressThe linklist contract address.

Links a linklist.

function linkLinklist(uint256 fromCharacterId, uint256 toLinkListId, bytes32 linkType, address linklist) external;

Parameters

NameTypeDescription
fromCharacterIduint256The character ID to sponsor an link action.
toLinkListIduint256The linklist if to link.
linkTypebytes32LinkType, like “follow”.
linklistaddressThe linklist contract address.

Unlinks a linklist.

function unlinkLinklist(uint256 fromCharacterId, uint256 toLinkListId, bytes32 linkType, address linklist) external;

Parameters

NameTypeDescription
fromCharacterIduint256The character ID to sponsor an unlink action.
toLinkListIduint256The linklist if to unlink.
linkTypebytes32LinkType, like “follow”.
linklistaddressThe linklist contract address.

linkERC721

Links an ERC721 token.

function linkERC721(uint256 fromCharacterId, address tokenAddress, uint256 tokenId, bytes32 linkType, address linklist) external;

Parameters

NameTypeDescription
fromCharacterIduint256The character ID to sponsor an link action.
tokenAddressaddressThe token address of ERC721 to link.
tokenIduint256The token ID of ERC721 to link.
linkTypebytes32linkType, like “follow”.
linklistaddressThe linklist contract address.

unlinkERC721

Unlinks an ERC721 token.

function unlinkERC721( uint256 fromCharacterId, address tokenAddress, uint256 tokenId, bytes32 linkType, address linklist ) external;

Parameters

NameTypeDescription
fromCharacterIduint256The character ID to sponsor an unlink action.
tokenAddressaddressThe token address of ERC721 to unlink.
tokenIduint256The token ID of ERC721 to unlink.
linkTypebytes32LinkType, like “follow”.
linklistaddressThe linklist contract address.

linkAddress

Creates a link to a given address.

function linkAddress(uint256 fromCharacterId, address ethAddress, bytes32 linkType, address linklist) external;

Parameters

NameTypeDescription
fromCharacterIduint256The character ID to init the link.
ethAddressaddressThe address to link.
linkTypebytes32LinkType, like “follow”.
linklistaddressThe linklist contract address.

unlinkAddress

Unlinks a given address.

function unlinkAddress(uint256 fromCharacterId, address ethAddress, bytes32 linkType, address linklist) external;

Parameters

NameTypeDescription
fromCharacterIduint256The character ID to init the unlink.
ethAddressaddressThe address to unlink.
linkTypebytes32LinkType, like “follow”.
linklistaddressThe linklist contract address.

linkAnyUri

Links any uri.

function linkAnyUri(uint256 fromCharacterId, string calldata toUri, bytes32 linkType, address linklist) external;

Parameters

NameTypeDescription
fromCharacterIduint256The character ID to sponsor an link action.
toUristringThe uri to link.
linkTypebytes32LinkType, like “follow”.
linklistaddressThe linklist contract address.

unlinkAnyUri

Unlinks any uri.

function unlinkAnyUri(uint256 fromCharacterId, string calldata toUri, bytes32 linkType, address linklist) external;

Parameters

NameTypeDescription
fromCharacterIduint256The character ID to sponsor an unlink action.
toUristringThe uri to unlink.
linkTypebytes32LinkType, like “follow”.
linklistaddressThe linklist contract address.

Returns the linklistId if the linklist already exists, Otherwise, creates a new linklist and return its ID.

function _mintLinklist(uint256 fromCharacterId, bytes32 linkType, address linklist) internal returns (uint256 linklistId);

_ownerOf

function _ownerOf(uint256 characterId) internal view returns (address);

LinklistLib

Git Source

Functions

setLinklistUri

function setLinklistUri(uint256 linklistId, string calldata uri, address linklist) external;

setLinklistType

function setLinklistType(uint256 characterId, uint256 linklistId, bytes32 linkType, address linklist) external;
function burnLinklist(uint256 characterId, uint256 linklistId, address linklist) external;

MetaTxLib

Git Source

State Variables

EIP712_DOMAIN_TYPEHASH

bytes32 internal constant EIP712_DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)");

GRANT_OPERATOR_PERMISSIONS_WITH_SIG_TYPEHASH

bytes32 internal constant GRANT_OPERATOR_PERMISSIONS_WITH_SIG_TYPEHASH = keccak256( "grantOperatorPermissions(uint256 characterId,address operator,uint256 permissionBitMap,uint256 nonce,uint256 deadline)" );

EIP1271_MAGIC_VALUE

bytes4 public constant EIP1271_MAGIC_VALUE = 0x1626ba7e;

Functions

validateGrantOperatorPermissionsSignature

function validateGrantOperatorPermissionsSignature( DataTypes.EIP712Signature calldata signature, uint256 characterId, address operator, uint256 permissionBitMap ) external;

_getAndIncrementNonce

This fetches a user's signing nonce and increments it, akin to sigNonces++.

function _getAndIncrementNonce(address user) internal returns (uint256);

_calculateDomainSeparator

Calculates EIP712 DOMAIN_SEPARATOR based on the current contract and chain ID.

function _calculateDomainSeparator() internal view returns (bytes32);

_validateRecoveredAddress

Wrapper for ecrecover to reduce code size, used in meta-tx specific functions.

function _validateRecoveredAddress(bytes32 digest, DataTypes.EIP712Signature calldata signature) internal view;

OP

Git Source

In Crossbell's operator system, every uint8 stands for a single method in Web3Entry.sol.
For most cases, we recommend simply granting operators the OPERATOR_SIGN_PERMISSION_BITMAP, which gives operator full permissions aside from owner permissions and future permissions, but for those who're more aware of access control, the custom permission bitmap is all yours, and you can find every customizable methods below.
OPERATOR_SIGN_PERMISSION_BITMAP have access to all methods in OPERATOR_SYNC_PERMISSION_BITMAP plus more permissions for signing.
Permissions are laid out in a increasing order of power. so the bitmap looks like this:

operator sync operator sign future reserved owner
[255 - 236] [235 - 176] [175 - 21] [20 - 0]

State Variables

UINT256_MAX

uint256 internal constant UINT256_MAX = ~uint256(0);

SET_HANDLE

uint8 internal constant SET_HANDLE = 0;

SET_SOCIAL_TOKEN

uint8 internal constant SET_SOCIAL_TOKEN = 1;

GRANT_OPERATOR_PERMISSIONS

uint8 internal constant GRANT_OPERATOR_PERMISSIONS = 2;

GRANT_OPERATORS_FOR_NOTE

uint8 internal constant GRANT_OPERATORS_FOR_NOTE = 3;

OWNER_PERMISSION_BITMAP

uint256 internal constant OWNER_PERMISSION_BITMAP = ~(UINT256_MAX << 4);

SET_CHARACTER_URI

uint8 internal constant SET_CHARACTER_URI = 176;
uint8 internal constant SET_LINKLIST_URI = 177;
uint8 internal constant LINK_CHARACTER = 178;
uint8 internal constant UNLINK_CHARACTER = 179;
uint8 internal constant CREATE_THEN_LINK_CHARACTER = 180;
uint8 internal constant LINK_NOTE = 181;
uint8 internal constant UNLINK_NOTE = 182;
uint8 internal constant LINK_ERC721 = 183;
uint8 internal constant UNLINK_ERC721 = 184;
uint8 internal constant LINK_ADDRESS = 185;
uint8 internal constant UNLINK_ADDRESS = 186;
uint8 internal constant LINK_ANYURI = 187;
uint8 internal constant UNLINK_ANYURI = 188;
uint8 internal constant LINK_LINKLIST = 189;
uint8 internal constant UNLINK_LINKLIST = 190;
uint8 internal constant SET_LINK_MODULE_FOR_CHARACTER = 191;
uint8 internal constant SET_LINK_MODULE_FOR_NOTE = 192;
uint8 internal constant SET_LINK_MODULE_FOR_LINKLIST = 193;

SET_MINT_MODULE_FOR_NOTE

uint8 internal constant SET_MINT_MODULE_FOR_NOTE = 194;

SET_NOTE_URI

uint8 internal constant SET_NOTE_URI = 195;

LOCK_NOTE

uint8 internal constant LOCK_NOTE = 196;

DELETE_NOTE

uint8 internal constant DELETE_NOTE = 197;

POST_NOTE_FOR_CHARACTER

uint8 internal constant POST_NOTE_FOR_CHARACTER = 198;

POST_NOTE_FOR_ADDRESS

uint8 internal constant POST_NOTE_FOR_ADDRESS = 199;

POST_NOTE_FOR_LINKLIST

uint8 internal constant POST_NOTE_FOR_LINKLIST = 200;

POST_NOTE_FOR_NOTE

uint8 internal constant POST_NOTE_FOR_NOTE = 201;

POST_NOTE_FOR_ERC721

uint8 internal constant POST_NOTE_FOR_ERC721 = 202;

POST_NOTE_FOR_ANYURI

uint8 internal constant POST_NOTE_FOR_ANYURI = 203;
uint8 internal constant SET_LINKLIST_TYPE = 204;

POST_NOTE

uint8 internal constant POST_NOTE = 236;

POST_NOTE_PERMISSION_BITMAP

uint256 internal constant POST_NOTE_PERMISSION_BITMAP = 1 << POST_NOTE;

POST_NOTE_DEFAULT_PERMISSION_BITMAP

uint256 internal constant POST_NOTE_DEFAULT_PERMISSION_BITMAP = ((UINT256_MAX << 198) & ~(UINT256_MAX << 204)) | POST_NOTE_PERMISSION_BITMAP;

DEFAULT_PERMISSION_BITMAP

uint256 internal constant DEFAULT_PERMISSION_BITMAP = ((UINT256_MAX << 176) & ~(UINT256_MAX << 205)) | POST_NOTE_PERMISSION_BITMAP;

ALLOWED_PERMISSION_BITMAP_MASK

uint256 internal constant ALLOWED_PERMISSION_BITMAP_MASK = OWNER_PERMISSION_BITMAP | DEFAULT_PERMISSION_BITMAP;

OperatorLib

Git Source

Functions

grantOperatorPermissions

Grants permission to a given operator for a character.

function grantOperatorPermissions(uint256 characterId, address operator, uint256 permissionBitMap) external;

Parameters

NameTypeDescription
characterIduint256The ID of the character to set operator for.
operatoraddressThe operator address to set.
permissionBitMapuint256The permission bitmap for the operator.

grantOperators4Note

Sets blocklist and allowlist for a specific note. Blocklist and allowlist are overwritten every time.

function grantOperators4Note( uint256 characterId, uint256 noteId, address[] calldata blocklist, address[] calldata allowlist ) external;

Parameters

NameTypeDescription
characterIduint256The character ID of the note owner.
noteIduint256The note ID to grant.
blocklistaddress[]The addresses list of blocked operators.
allowlistaddress[]The addresses list of allowed operators.

clearOperators

function clearOperators(uint256 characterId) external;

_clearOperators4Note

function _clearOperators4Note(DataTypes.Operators4Note storage operators4Note) internal;

_updateOperators4Note

function _updateOperators4Note( DataTypes.Operators4Note storage operators4Note, address[] calldata blocklist, address[] calldata allowlist ) internal;

_bitmapFilter

_bitmapFilter unsets bits of non-existent permission IDs to zero.
These unset permission IDs are meaningless now, but they are reserved for future use, so it's best to leave them blank and avoid messing up with future methods.

function _bitmapFilter(uint256 bitmap) internal pure returns (uint256);

PostLib

Git Source

Functions

function postNoteWithLink( DataTypes.PostNoteData calldata vars, uint256 noteId, bytes32 linkItemType, bytes32 linkKey, bytes calldata data ) external;

mintNote

function mintNote(uint256 characterId, uint256 noteId, address to, bytes calldata mintModuleData, address mintNFTImpl) external returns (uint256 tokenId);

setNoteUri

function setNoteUri(uint256 characterId, uint256 noteId, string calldata newUri) external;

lockNote

function lockNote(uint256 characterId, uint256 noteId) external;

deleteNote

function deleteNote(uint256 characterId, uint256 noteId) external;

setLinkModule4Note

Sets link module for a given note.

function setLinkModule4Note(uint256 characterId, uint256 noteId, address linkModule, bytes calldata linkModuleInitData) external;

Parameters

NameTypeDescription
characterIduint256The character ID to set link module for.
noteIduint256The note ID to set link module for.
linkModuleaddressThe link module to set.
linkModuleInitDatabytesThe data to pass to the link module for initialization, if any.

setMintModule4Note

Sets the mint module for a given note.

function setMintModule4Note(uint256 characterId, uint256 noteId, address mintModule, bytes calldata mintModuleInitData) external;

Parameters

NameTypeDescription
characterIduint256The character ID of note to set the mint module for.
noteIduint256The note ID of note.
mintModuleaddressThe mint module to set for note.
mintModuleInitDatabytesThe data to pass to the mint module.

_deployMintNFT

function _deployMintNFT(uint256 characterId, uint256 noteId, address mintNFTImpl) internal returns (address mintNFT);

_setLinkModule4Note

function _setLinkModule4Note( uint256 characterId, uint256 noteId, address linkModule, bytes calldata linkModuleInitData, DataTypes.Note storage _note ) internal;

_setMintModule4Note

function _setMintModule4Note( uint256 characterId, uint256 noteId, address mintModule, bytes calldata mintModuleInitData, DataTypes.Note storage _note ) internal;

StorageLib

Git Source

State Variables

CHARACTERS_MAPPING_SLOT

uint256 public constant CHARACTERS_MAPPING_SLOT = 10;

CHARACTER_ID_BY_HANDLE_HASH_MAPPING_SLOT

uint256 public constant CHARACTER_ID_BY_HANDLE_HASH_MAPPING_SLOT = 11;

PRIMARY_CHARACTER_BY_ADDRESS_MAPPING_SLOT

uint256 public constant PRIMARY_CHARACTER_BY_ADDRESS_MAPPING_SLOT = 12;
uint256 public constant ATTACHED_LINK_LISTS_MAPPING_SLOT = 13;

NOTES_MAPPING_SLOT

uint256 public constant NOTES_MAPPING_SLOT = 14;
uint256 public constant LINK_MODULE_4_LINKLIST_MAPPING_SLOT = 15;
uint256 public constant LINK_MODULE_4_ERC721_MAPPING_SLOT = 16;
uint256 public constant LINK_MODULE_4_ADDRESS_MAPPING_SLOT = 17;

CHARACTER_COUNTER_SLOG

uint256 public constant CHARACTER_COUNTER_SLOG = 18;
uint256 public constant LINKLIST_SLOT = 19;

MINT_NFT_IMPL_SLOT

uint256 public constant MINT_NFT_IMPL_SLOT = 20;

PERIPHERY_SLOT

uint256 public constant PERIPHERY_SLOT = 21;

OPERATORS_BY_CHARACTER_MAPPING_SLOT

uint256 public constant OPERATORS_BY_CHARACTER_MAPPING_SLOT = 24;

OPERATORS_PERMISSION_BIT_MAP_MAPPING_SLOT

uint256 public constant OPERATORS_PERMISSION_BIT_MAP_MAPPING_SLOT = 25;

OPERATOR_FOR_NOTE_MAPPING_SLOT

uint256 public constant OPERATOR_FOR_NOTE_MAPPING_SLOT = 26;

NEWBIE_VILLA_SLOT

uint256 public constant NEWBIE_VILLA_SLOT = 27;

SIG_NONCES_MAPPING_SLOT

uint256 public constant SIG_NONCES_MAPPING_SLOT = 28;

Functions

setOperatorsPermissionBitMap

function setOperatorsPermissionBitMap(uint256 characterId, address operator, uint256 permissionBitMap) internal;

setAttachedLinklistId

function setAttachedLinklistId(uint256 characterId, bytes32 linkType, uint256 linklistId) internal;

deleteAttachedLinklistId

function deleteAttachedLinklistId(uint256 characterId, bytes32 linkType) internal;

getAttachedLinklistId

function getAttachedLinklistId(uint256 characterId, bytes32 linkType) internal view returns (uint256 _linklistId);

nonces

function nonces() internal pure returns (mapping(address => uint256) storage _nonces);

getCharacter

function getCharacter(uint256 characterId) internal pure returns (DataTypes.Character storage _character);

getNote

function getNote(uint256 characterId, uint256 noteId) internal pure returns (DataTypes.Note storage _note);

characterIdByHandleHash

function characterIdByHandleHash() internal pure returns (mapping(bytes32 => uint256) storage _characterIdByHandleHash);

operatorsByCharacter

function operatorsByCharacter() internal pure returns (mapping(uint256 => EnumerableSet.AddressSet) storage _operatorsByCharacter);

getOperators4Note

function getOperators4Note(uint256 characterId, uint256 noteId) internal pure returns (DataTypes.Operators4Note storage _operators4Note);

ValidationLib

Git Source

Functions

validateNoteExists

function validateNoteExists(uint256 characterId, uint256 noteId) internal view;

validateNoteNotLocked

function validateNoteNotLocked(uint256 characterId, uint256 noteId) internal view;

validateHandleNotExists

function validateHandleNotExists(bytes32 handleHash) internal view;

validateHandle

function validateHandle(string memory handle) internal pure;

validateChar

function validateChar(bytes1 c) internal pure;

Contents

CharacterBoundToken

Git Source

Inherits: Context, ERC165, IERC1155, IERC1155MetadataURI, AccessControlEnumerable

State Variables

MINTER_ROLE

bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");

_balances

mapping(uint256 => mapping(uint256 => uint256)) private _balances;

_operatorApprovals

mapping(address => mapping(address => bool)) private _operatorApprovals;

_tokenURIs

mapping(uint256 => string) private _tokenURIs;

web3Entry

address public web3Entry;

_currentTokenNumbers

mapping(uint256 => uint256) private _currentTokenNumbers;

Functions

constructor

constructor(address web3Entry_);

mint

function mint(uint256 characterId, uint256 tokenId) external onlyRole(MINTER_ROLE);

burn

function burn(uint256 characterId, uint256 tokenId, uint256 amount) external;

setTokenURI

function setTokenURI(uint256 tokenId, string memory tokenURI) external onlyRole(MINTER_ROLE);

safeTransferFrom

See {IERC1155-safeTransferFrom}.

function safeTransferFrom(address, address, uint256, uint256, bytes memory) external virtual override;

safeBatchTransferFrom

See {IERC1155-safeBatchTransferFrom}.

function safeBatchTransferFrom(address, address, uint256[] memory, uint256[] memory, bytes memory) external virtual override;

setApprovalForAll

See {IERC1155-setApprovalForAll}.

function setApprovalForAll(address operator, bool approved) external virtual override;

balanceOfBatch

function balanceOfBatch(address[] memory accounts, uint256[] memory tokenIds) external view virtual override returns (uint256[] memory);

supportsInterface

See {IERC165-supportsInterface}.

function supportsInterface(bytes4 interfaceId) public view virtual override(AccessControlEnumerable, ERC165, IERC165) returns (bool);

balanceOf

function balanceOf(address account, uint256 tokenId) public view virtual override returns (uint256 balance);

balanceOf

function balanceOf(uint256 characterId, uint256 tokenId) public view virtual returns (uint256);

uri

function uri(uint256 tokenId) public view virtual override returns (string memory);

isApprovedForAll

See {IERC1155-isApprovedForAll}.

function isApprovedForAll(address account, address operator) public view virtual override returns (bool);

_setApprovalForAll

Approve operator to operate on all of owner tokens Emits an {ApprovalForAll} event.

function _setApprovalForAll(address owner, address operator, bool approved) internal virtual;

_setURI

function _setURI(uint256 tokenId, string memory tokenURI) internal virtual;

Events

Mint

event Mint(uint256 indexed to, uint256 indexed tokenId, uint256 indexed tokenNumber);

Burn

event Burn(uint256 indexed from, uint256 indexed tokenId, uint256 indexed amount);

NewbieVilla

Git Source

Inherits: Initializable, AccessControlEnumerable, IERC721Receiver, IERC777Recipient

Implementation of a contract to keep characters for others. The keepers and addresses with the ADMIN_ROLE are expected to issue the proof to users. Then users could use the proof to withdraw the corresponding character.

State Variables

ADMIN_ROLE

bytes32 public constant ADMIN_ROLE = keccak256("ADMIN_ROLE");

ERC1820_REGISTRY

IERC1820Registry public constant ERC1820_REGISTRY = IERC1820Registry(0x1820a4B7618BdE71Dce8cdc73aAB6C95905faD24);

TOKENS_RECIPIENT_INTERFACE_HASH

bytes32 public constant TOKENS_RECIPIENT_INTERFACE_HASH = keccak256("ERC777TokensRecipient");

web3Entry

address public web3Entry;

xsyncOperator

address public xsyncOperator;

_token

address internal _token;

_balances

mapping(uint256 => uint256) internal _balances;

_tips

address internal _tips;

_keepers

mapping(uint256 characterId => address keeper) private _keepers;

Functions

notExpired

modifier notExpired(uint256 expires);

initialize

Initialize the Newbie Villa contract.

msg.sender will be granted DEFAULT_ADMIN_ROLE.

function initialize(address web3Entry_, address xsyncOperator_, address token_, address admin_, address tips_) external reinitializer(3);

Parameters

NameTypeDescription
web3Entry_addressAddress of web3Entry contract.
xsyncOperator_addressAddress of xsyncOperator.
token_addressAddress of ERC777 token.
admin_addressAddress of admin.
tips_addressAddress of Tips contract.

tipCharacter

Tips a character by transferring amount tokens from account with required permission to Tips contract.
Admin will call send erc777 token to the Tips contract, with fromCharacterId and toCharacterId encoded in the data.
send interface is IERC777-send, and parameters encode refers AbiCoder-encode.
Requirements:

  • The msg.sender must be character's keeper or have ADMIN_ROLE but not character's keeper.
function tipCharacter(uint256 fromCharacterId, uint256 toCharacterId, uint256 amount) external;

Parameters

NameTypeDescription
fromCharacterIduint256The token ID of character that calls this contract.
toCharacterIduint256The token ID of character that will receive the token.
amountuint256Amount of token.

tipCharacterForNote

Tips a character's note by transferring amount tokens from account with required permission to Tips contract.
Admin will call send erc777 token to the Tips contract, with fromCharacterId, toCharacterId and toNoteId encoded in the data.
send interface is IERC777-send, and parameters encode refers AbiCoder-encode.
Requirements:

  • The msg.sender must be character's keeper or have ADMIN_ROLE but not character's keeper.
function tipCharacterForNote(uint256 fromCharacterId, uint256 toCharacterId, uint256 toNoteId, uint256 amount) external;

Parameters

NameTypeDescription
fromCharacterIduint256The token ID of character that calls this contract.
toCharacterIduint256The token ID of character that will receive the token.
toNoteIduint256The note ID.
amountuint256Amount of token.

withdraw

Withdraw character#characterId to to using the nonce, expires and the proof.
Emits the Withdraw event.

*Proof is the signature from character keepers or someone with the ADMIN_ROLE. The message to sign is the packed data of this contract's address, characterId, nonce and expires.
Here's an example to generate a proof:

digest = ethers.utils.arrayify( ethers.utils.solidityKeccak256( ["address", "uint256", "uint256", "uint256"], [newbieVilla.address, characterId, nonce, expires] ) ); proof = await owner.signMessage(digest);

Requirements: :

  • expires is greater than the current timestamp
  • proof is signed by the keeper or address with the ADMIN_ROLE*
function withdraw(address to, uint256 characterId, uint256 nonce, uint256 expires, bytes calldata proof) external notExpired(expires);

Parameters

NameTypeDescription
toaddressReceiver of the withdrawn character.
characterIduint256The token id of the character to withdraw.
nonceuint256Random nonce used to generate the proof.
expiresuint256Expire time of the proof, Unix timestamp in seconds.
proofbytesThe proof using to withdraw the character.

onERC721Received

*Whenever a character tokenId is transferred to this contract via {IERC721-safeTransferFrom} by operator from from, this function is called. data will be decoded as an address and set as the operator of the character. If the data is empty, the operator will be default operator of the character.
Requirements: :

  • msg.sender must be address of Web3Entry.*
function onERC721Received(address operator, address, uint256 tokenId, bytes calldata data) external override returns (bytes4);

Parameters

NameTypeDescription
operatoraddress
<none>address
tokenIduint256
databytesbytes encoded from the operator address to set for the incoming character.

tokensReceived

Receives tokens. Only specific tokens are accepted, so be careful not to send tokens to this address randomly.

The userData/operatorData should be an abi-encoded bytes of fromCharacterId and toCharacter, which are both uint256 type, so the length of data is 64.

function tokensReceived( address, address, address to, uint256 amount, bytes calldata userData, bytes calldata operatorData ) external override(IERC777Recipient);

Parameters

NameTypeDescription
<none>address
<none>address
toaddressThe Newbie Villa contract address.
amountuint256The amount of token sent.
userDatabytesThe abi-encoded bytes of fromCharacterId and toCharacter.
operatorDatabytesThe abi-encoded bytes of fromCharacterId and toCharacter.

balanceOf

Returns the amount of tokens owned by characterId.

function balanceOf(uint256 characterId) external view returns (uint256);

Parameters

NameTypeDescription
characterIduint256The character ID to query.

Returns

NameTypeDescription
<none>uint256uint256 The amount of tokens owned by the character.

getKeeper

Returns the address of keeper by characterId.

function getKeeper(uint256 characterId) external view returns (address);

Parameters

NameTypeDescription
characterIduint256The character ID to query.

Returns

NameTypeDescription
<none>addressaddress The address of the keeper.

getToken

Returns the address of mira token contract.

function getToken() external view returns (address);

Returns

NameTypeDescription
<none>addressThe address of mira token contract.

_hasPermission

It will return true if account is character's keeper or has ADMIN_ROLE but not character's keeper.

function _hasPermission(address account, uint256 characterId) internal view returns (bool);

Events

Withdraw

Emitted when the web3Entry character nft is withdrawn.

event Withdraw(address to, uint256 characterId, address token, uint256 amount);

Periphery

Git Source

Inherits: Initializable

State Variables

web3Entry

address public web3Entry;
address public linklist;

Functions

initialize

function initialize(address web3Entry_, address linklist_) external initializer;

linkCharactersInBatch

function linkCharactersInBatch(DataTypes.linkCharactersInBatchData calldata vars) external;

sync

function sync( address account, string calldata handle, string calldata uri, address[] calldata toAddresses, bytes32 linkType ) external;

migrate

function migrate(DataTypes.MigrateData calldata vars) external;

getNotesByCharacterId

function getNotesByCharacterId(uint256 characterId, uint256 offset, uint256 limit) external view returns (DataTypes.Note[] memory results);

getLinkingCharacterIds

function getLinkingCharacterIds(uint256 fromCharacterId, bytes32 linkType) external view returns (uint256[] memory results);

getLinkingNotes

function getLinkingNotes(uint256 fromCharacterId, bytes32 linkType) external view returns (DataTypes.Note[] memory results);

getLinkingNote

function getLinkingNote(bytes32 linkKey) external view returns (DataTypes.NoteStruct memory);

getLinkingERC721s

function getLinkingERC721s(uint256 fromCharacterId, bytes32 linkType) external view returns (DataTypes.ERC721Struct[] memory results);

getLinkingERC721

function getLinkingERC721(bytes32 linkKey) external view returns (DataTypes.ERC721Struct memory);

getLinkingAnyUris

function getLinkingAnyUris(uint256 fromCharacterId, bytes32 linkType) external view returns (string[] memory results);

getLinkingAnyUri

function getLinkingAnyUri(bytes32 linkKey) external view returns (string memory);

getLinkingAddresses

function getLinkingAddresses(uint256 fromCharacterId, bytes32 linkType) external view returns (address[] memory);

getLinkingLinklistIds

function getLinkingLinklistIds(uint256 fromCharacterId, bytes32 linkType) external view returns (uint256[] memory linklistIds);

getLinkingLinklistId

function getLinkingLinklistId(bytes32 linkKey) external pure returns (uint256 linklistId);

getLinkingAddress

function getLinkingAddress(bytes32 linkKey) external pure returns (address);

getLinkingCharacterId

function getLinkingCharacterId(bytes32 linkKey) external pure returns (uint256 characterId);

_migrate

_migrate will not update handle if the target character already exists

function _migrate( address account, string memory handle, string memory uri, address[] memory toAddresses, bytes32 linkType ) internal;

_exists

function _exists(uint256 characterId) internal view returns (bool);

Tips

Git Source

Inherits: Initializable, IERC777Recipient

Logic to handle rewards that user can send to character and note.

State Variables

ERC1820_REGISTRY

IERC1820Registry public constant ERC1820_REGISTRY = IERC1820Registry(0x1820a4B7618BdE71Dce8cdc73aAB6C95905faD24);

TOKENS_RECIPIENT_INTERFACE_HASH

bytes32 public constant TOKENS_RECIPIENT_INTERFACE_HASH = keccak256("ERC777TokensRecipient");

_web3Entry

address internal _web3Entry;

_token

address internal _token;

Functions

initialize

Initialize the contract, setting web3Entry address and token address.

function initialize(address web3Entry_, address token_) external initializer;

Parameters

NameTypeDescription
web3Entry_addressAddress of web3Entry.
token_addressAddress of token.

tokensReceived

Called by an {IERC777} token contract whenever tokens are being moved or created into a registered account to (this contract).
The userData/operatorData should be an abi encoded bytes of fromCharacterId, toCharacter and toNoteId(optional), which are all uint256 type, so the length of data is 64 or 96.

function tokensReceived( address, address from, address to, uint256 amount, bytes calldata userData, bytes calldata operatorData ) external override(IERC777Recipient);

getWeb3Entry

Returns the address of web3Entry contract.

function getWeb3Entry() external view returns (address);

Returns

NameTypeDescription
<none>addressThe address of web3Entry contract.

getToken

Returns the address of mira token contract.

function getToken() external view returns (address);

Returns

NameTypeDescription
<none>addressThe address of mira token contract.

_tipCharacter

Tips a character by transferring amount tokens from the fromCharacterId account to toCharacterId account.
Emits the TipCharacter event.
User should call send erc777 token to the Tips contract, with fromCharacterId and toCharacterId encoded in the data.
send interface is IERC777-send, and parameters encode refers AbiCoder-encode.
Requirements:

  • The from account must be the character owner of `fromCharacterId.
function _tipCharacter(address from, uint256 fromCharacterId, uint256 toCharacterId, address token, uint256 amount) internal;

Parameters

NameTypeDescription
fromaddressThe caller's account who sends token.
fromCharacterIduint256The token ID of character that calls this contract.
toCharacterIduint256The token ID of character that will receive the token.
tokenaddressAddress of token.
amountuint256Amount of token.

_tipCharacterForNote

Tips a character's note by transferring amount tokens from the fromCharacterId account to toCharacterId account.
Emits the TipCharacterForNote event.
User should call send erc777 token to the Tips contract, with fromCharacterId, toCharacterId and toNoteId encoded in the data.
Requirements:

  • The from account must be the character owner of `fromCharacterId.
function _tipCharacterForNote( address from, uint256 fromCharacterId, uint256 toCharacterId, uint256 toNoteId, address token, uint256 amount ) internal;

Parameters

NameTypeDescription
fromaddressThe caller's account who sends token.
fromCharacterIduint256The token ID of character that calls this contract.
toCharacterIduint256The token ID of character that will receive the token.
toNoteIduint256The note ID.
tokenaddressAddress of token.
amountuint256Amount of token.

_sendToken

function _sendToken(address from, uint256 fromCharacterId, uint256 toCharacterId, address token, uint256 amount) internal;

Events

TipCharacter

Emitted when the assets are rewarded to a character.

event TipCharacter(uint256 indexed fromCharacterId, uint256 indexed toCharacterId, address token, uint256 amount);

TipCharacterForNote

Emitted when the assets are rewarded to a note.

event TipCharacterForNote( uint256 indexed fromCharacterId, uint256 indexed toCharacterId, uint256 indexed toNoteId, address token, uint256 amount );

Errors

ErrCallerNotCharacterOwner

error ErrCallerNotCharacterOwner();

TipsWithConfig

Git Source

Inherits: ITipsWithConfig, Initializable, ReentrancyGuard

Logic to handle the periodical tips that user can send to character periodically.

User can set config for a specific character, and anyone can collect the tip by config id. For setTipsConfig4Character User can set the tips config for a specific character.
For collectTips4Character Anyone can collect the tip by config id, and it will transfer all available tokens from the fromCharacterId account to the toCharacterId account.

State Variables

_web3Entry

address internal _web3Entry;

_tipsConfigIndex

uint256 internal _tipsConfigIndex;

_tipsConfigs

mapping(uint256 tipsConfigId => TipsConfig) internal _tipsConfigs;

_tipsConfigIds

mapping(uint256 fromCharacterId => mapping(uint256 toCharacterId => uint256 tipsConfigId)) internal _tipsConfigIds;

_feeFractions

mapping(address feeReceiver => uint256 fraction) internal _feeFractions;

_feeFractions4Character

mapping(address feeReceiver => mapping(uint256 characterId => uint256 fraction)) internal _feeFractions4Character;

Functions

onlyFeeReceiver

modifier onlyFeeReceiver(address feeReceiver);

validateFraction

modifier validateFraction(uint256 fraction);

initialize

Initialize the contract, setting web3Entry address.

function initialize(address web3Entry_) external override initializer;

Parameters

NameTypeDescription
web3Entry_addressAddress of web3Entry.

setDefaultFeeFraction

Sets the default fee percentage of specific receiver.

The feeReceiver can be a platform account.

function setDefaultFeeFraction(address feeReceiver, uint256 fraction) external override onlyFeeReceiver(feeReceiver) validateFraction(fraction);

Parameters

NameTypeDescription
feeReceiveraddressThe fee receiver address.
fractionuint256The percentage measured in basis points. Each basis point represents 0.01%.

setFeeFraction4Character

Sets the fee percentage of specific <receiver, character>.

If this is set, it will override the default fee fraction.

function setFeeFraction4Character(address feeReceiver, uint256 characterId, uint256 fraction) external override onlyFeeReceiver(feeReceiver) validateFraction(fraction);

Parameters

NameTypeDescription
feeReceiveraddressThe fee receiver address.
characterIduint256The character ID.
fractionuint256The percentage measured in basis points. Each basis point represents 0.01%.

setTipsConfig4Character

Sets the tips config of specific <fromCharacter, toCharacter>.
Emits a {SetTipsConfig4Character} event.

If the tips config of specific <fromCharacter, toCharacter> is already, it will try to collect the tips first, and then override the tips config.

function setTipsConfig4Character( uint256 fromCharacterId, uint256 toCharacterId, address token, uint256 amount, uint256 startTime, uint256 endTime, uint256 interval, address feeReceiver ) external override;

Parameters

NameTypeDescription
fromCharacterIduint256The token ID of character that would send the reward.
toCharacterIduint256The token ID of character that would receive the reward.
tokenaddressThe token address.
amountuint256The amount of token.
startTimeuint256The start time of tips.
endTimeuint256The end time of tips.
intervaluint256The interval of tips.
feeReceiveraddressThe fee receiver address.

cancelTips4Character

Cancels the tips config.
Emits a {CancelTips4Character} event.

It will try to collect the tips first, and then delete the tips config.

function cancelTips4Character(uint256 tipConfigId) external override;

Parameters

NameTypeDescription
tipConfigIduint256The tip config ID to cancel.

collectTips4Character

Collects all unredeemed token from the fromCharacter to the toCharacter.
Emits a {CollectTips4Character} event if collects successfully.

It will transfer all unredeemed token from the fromCharacter to the toCharacter.

function collectTips4Character(uint256 tipConfigId) external override nonReentrant returns (uint256 collectedAmount);

Parameters

NameTypeDescription
tipConfigIduint256The tip config ID.

Returns

NameTypeDescription
collectedAmountuint256The amount of token collected.

getFeeFraction

Returns the fee percentage of specific <receiver, note>.

It will return the first non-zero value by priority feeFraction4Character and defaultFeeFraction.

function getFeeFraction(address feeReceiver, uint256 characterId) external view override returns (uint256);

Parameters

NameTypeDescription
feeReceiveraddressThe fee receiver address.
characterIduint256The character ID .

Returns

NameTypeDescription
<none>uint256fraction The percentage measured in basis points. Each basis point represents 0.01%.

getFeeAmount

Returns how much the fee is owed by <feeFraction, tipAmount>.

function getFeeAmount(address feeReceiver, uint256 characterId, uint256 tipAmount) external view override returns (uint256);

Parameters

NameTypeDescription
feeReceiveraddressThe fee receiver address.
characterIduint256The character ID .
tipAmountuint256

Returns

NameTypeDescription
<none>uint256The fee amount.

getTipsConfigId

Return the tips config Id.

function getTipsConfigId(uint256 fromCharacterId, uint256 toCharacterId) external view returns (uint256);

Parameters

NameTypeDescription
fromCharacterIduint256The token ID of character that initiated a reward.
toCharacterIduint256The token ID of character that would receive the reward.

Returns

NameTypeDescription
<none>uint256uint256 Returns tips config ID.

getTipsConfig

Return the tips config.

function getTipsConfig(uint256 tipConfigId) external view override returns (TipsConfig memory config);

Parameters

NameTypeDescription
tipConfigIduint256The tip config ID.

getWeb3Entry

Returns the address of web3Entry contract.

function getWeb3Entry() external view override returns (address);

Returns

NameTypeDescription
<none>addressThe address of web3Entry contract.

_collectTips4Character

function _collectTips4Character(uint256 tipConfigId) internal returns (uint256);

_getTipsConfigId

function _getTipsConfigId(uint256 fromCharacterId, uint256 toCharacterId) internal view returns (uint256);

_getAvailableRoundAndAmount

function _getAvailableRoundAndAmount(TipsConfig memory config) internal view returns (uint256, uint256);

_getFeeFraction

function _getFeeFraction(address feeReceiver, uint256 characterId) internal view returns (uint256);

_getFeeAmount

function _getFeeAmount(address feeReceiver, uint256 characterId, uint256 tipAmount) internal view returns (uint256);

_getTipRound

function _getTipRound(uint256 startTime, uint256 endTime, uint256 interval) internal pure returns (uint256);

_feeDenominator

Defaults to 10000 so fees are expressed in basis points.

function _feeDenominator() internal pure virtual returns (uint96);

Events

SetTipsConfig4Character

Emitted when a user set a tip with periodical config.

event SetTipsConfig4Character( uint256 indexed tipConfigId, uint256 indexed fromCharacterId, uint256 indexed toCharacterId, address token, uint256 amount, uint256 startTime, uint256 endTime, uint256 interval, address feeReceiver, uint256 totalRound );

CancelTips4Character

Emitted when a periodical config is canceled.

event CancelTips4Character(uint256 indexed tipConfigId);

CollectTips4Character

Emitted when a user collect a tip with periodical config.

event CollectTips4Character( uint256 indexed tipConfigId, uint256 indexed fromCharacterId, uint256 indexed toCharacterId, address token, uint256 amount, uint256 fee, address feeReceiver, uint256 currentRound );

TipsWithFee

Git Source

Inherits: ITipsWithFee, Initializable, IERC777Recipient

Logic to handle rewards that user can send to character and note.

The platform can set the commission ratio through the TipsWithFee contract, and draw a commission from the user's tips.
For TipCharacter User/Client should call send erc777 token to the TipsWithFee contract, with fromCharacterId, toCharacterId and receiver(a platform account) encoded in the data.
send interface is IERC777-send, and parameters encode refers AbiCoder-encode.
For TipCharacter4Note User should call send erc777 token to the TipsWithFee contract, with fromCharacterId, toCharacterId, toNoteId and receiver encoded in the data.
The platform account can set the commission ratio through setDefaultFeeFraction, setFeeFraction4Character and setFeeFraction4Note.

State Variables

ERC1820_REGISTRY

IERC1820Registry public constant ERC1820_REGISTRY = IERC1820Registry(0x1820a4B7618BdE71Dce8cdc73aAB6C95905faD24);

TOKENS_RECIPIENT_INTERFACE_HASH

bytes32 public constant TOKENS_RECIPIENT_INTERFACE_HASH = keccak256("ERC777TokensRecipient");

_web3Entry

address internal _web3Entry;

_token

address internal _token;

_feeFractions

mapping(address => uint256) internal _feeFractions;

_feeFractions4Character

mapping(address => mapping(uint256 => uint256)) internal _feeFractions4Character;

_feeFractions4Note

mapping(address => mapping(uint256 => mapping(uint256 => uint256))) internal _feeFractions4Note;

Functions

onlyFeeReceiver

modifier onlyFeeReceiver(address feeReceiver);

validateFraction

modifier validateFraction(uint256 fraction);

initialize

Initialize the contract, setting web3Entry address and token address.

function initialize(address web3Entry_, address token_) external override initializer;

Parameters

NameTypeDescription
web3Entry_addressAddress of web3Entry.
token_addressAddress of token.

setDefaultFeeFraction

Changes the default fee percentage of specific receiver.

The feeReceiver can be a platform account.

function setDefaultFeeFraction(address feeReceiver, uint256 fraction) external override onlyFeeReceiver(feeReceiver) validateFraction(fraction);

Parameters

NameTypeDescription
feeReceiveraddressThe fee receiver address.
fractionuint256The percentage measured in basis points. Each basis point represents 0.01%.

setFeeFraction4Character

Changes the fee percentage of specific <receiver, character>.

If feeFraction4Character is set, it will override the default fee fraction.

function setFeeFraction4Character(address feeReceiver, uint256 characterId, uint256 fraction) external override onlyFeeReceiver(feeReceiver) validateFraction(fraction);

Parameters

NameTypeDescription
feeReceiveraddressThe fee receiver address.
characterIduint256The character ID.
fractionuint256The percentage measured in basis points. Each basis point represents 0.01%.

setFeeFraction4Note

Changes the fee percentage of specific <receiver, note>.

If feeFraction4Note is set, it will override feeFraction4Character and the default fee fraction.

function setFeeFraction4Note(address feeReceiver, uint256 characterId, uint256 noteId, uint256 fraction) external override onlyFeeReceiver(feeReceiver) validateFraction(fraction);

Parameters

NameTypeDescription
feeReceiveraddressThe fee receiver address.
characterIduint256The character ID .
noteIduint256The note ID .
fractionuint256The percentage measured in basis points. Each basis point represents 0.01%.

tokensReceived

Called by an {IERC777} token contract whenever tokens are being moved or created into a registered account to (this contract).
The userData/operatorData should be an abi encoded bytes of fromCharacterId, toCharacter and toNoteId(optional) and receiver(platform account), so the length of data is 96 or 128.

function tokensReceived( address, address from, address to, uint256 amount, bytes calldata userData, bytes calldata operatorData ) external override(IERC777Recipient);

getWeb3Entry

Returns the address of web3Entry contract.

function getWeb3Entry() external view override returns (address);

Returns

NameTypeDescription
<none>addressThe address of web3Entry contract.

getToken

Returns the address of mira token contract.

function getToken() external view override returns (address);

Returns

NameTypeDescription
<none>addressThe address of mira token contract.

getFeeFraction

Returns the fee percentage of specific <receiver, note>.

It will return the first non-zero value by priority feeFraction4Note, feeFraction4Character and defaultFeeFraction.

function getFeeFraction(address feeReceiver, uint256 characterId, uint256 noteId) external view override returns (uint256);

Parameters

NameTypeDescription
feeReceiveraddressThe fee receiver address.
characterIduint256The character ID .
noteIduint256The note ID .

Returns

NameTypeDescription
<none>uint256fraction The percentage measured in basis points. Each basis point represents 0.01%.

getFeeAmount

Returns how much the fee is owed by <feeFraction, tipAmount>.

function getFeeAmount(address feeReceiver, uint256 characterId, uint256 noteId, uint256 tipAmount) external view override returns (uint256);

Parameters

NameTypeDescription
feeReceiveraddressThe fee receiver address.
characterIduint256The character ID .
noteIduint256The note ID .
tipAmountuint256

Returns

NameTypeDescription
<none>uint256The fee amount.

_tipCharacter

Tips a character by transferring amount tokens from the fromCharacterId account to toCharacterId account.
Emits the TipCharacter event.
User should call send erc777 token to the Tips contract, with fromCharacterId and toCharacterId encoded in the data.
send interface is IERC777-send, and parameters encode refers AbiCoder-encode.
Requirements:

  • The from account must be the character owner of `fromCharacterId.
function _tipCharacter( address from, uint256 fromCharacterId, uint256 toCharacterId, address token, uint256 amount, address feeReceiver ) internal;

Parameters

NameTypeDescription
fromaddressThe caller's account who sends token.
fromCharacterIduint256The token ID of character that calls this contract.
toCharacterIduint256The token ID of character that will receive the token.
tokenaddressAddress of token.
amountuint256Amount of token.
feeReceiveraddressFee receiver address.

_tipCharacterForNote

Tips a character's note by transferring amount tokens from the fromCharacterId account to toCharacterId account.
Emits the TipCharacterForNote event.
User should call send erc777 token to the Tips contract, with fromCharacterId, toCharacterId and toNoteId encoded in the data.
Requirements:

  • The from account must be the character owner of `fromCharacterId.
function _tipCharacterForNote( address from, uint256 fromCharacterId, uint256 toCharacterId, uint256 toNoteId, address token, uint256 amount, address feeReceiver ) internal;

Parameters

NameTypeDescription
fromaddressThe caller's account who sends token.
fromCharacterIduint256The token ID of character that calls this contract.
toCharacterIduint256The token ID of character that will receive the token.
toNoteIduint256The note ID.
tokenaddressAddress of token.
amountuint256Amount of token.
feeReceiveraddressFee receiver address.

_tip

function _tip( address from, uint256 fromCharacterId, uint256 toCharacterId, uint256 toNoteId, address token, uint256 amount, address feeReceiver ) internal;

_getFeeFraction

function _getFeeFraction(address feeReceiver, uint256 characterId, uint256 noteId) internal view returns (uint256);

_getFeeAmount

function _getFeeAmount(address feeReceiver, uint256 characterId, uint256 noteId, uint256 tipAmount) internal view returns (uint256);

_feeDenominator

Defaults to 10000 so fees are expressed in basis points.

function _feeDenominator() internal pure virtual returns (uint96);

Events

TipCharacter

Emitted when the assets are rewarded to a character.

event TipCharacter( uint256 indexed fromCharacterId, uint256 indexed toCharacterId, address token, uint256 amount, uint256 fee, address feeReceiver );

TipCharacterForNote

Emitted when the assets are rewarded to a note.

event TipCharacterForNote( uint256 indexed fromCharacterId, uint256 indexed toCharacterId, uint256 indexed toNoteId, address token, uint256 amount, uint256 fee, address feeReceiver );

Contents

Contents

ApprovalLinkModule4Character

Git Source

Inherits: ILinkModule4Character, ModuleBase

This is a simple LinkModule implementation, inheriting from the ILinkModule4Character interface.

State Variables

_approvedByCharacterByOwner

mapping(address => mapping(uint256 => mapping(address => bool))) internal _approvedByCharacterByOwner;

Functions

constructor

constructor(address web3Entry_) ModuleBase(web3Entry_);

initializeLinkModule

function initializeLinkModule(uint256 characterId, bytes calldata data) external override returns (bytes memory);

approve

A custom function that allows character owners to customize approved addresses.

function approve(uint256 characterId, address[] calldata addresses, bool[] calldata toApprove) external;

Parameters

NameTypeDescription
characterIduint256The character ID to approve/disapprove.
addressesaddress[]The addresses to approve/disapprove for linking the character.
toApprovebool[]Whether to approve or disapprove the addresses for linking the character.
function processLink(address caller, uint256 characterId, bytes calldata) external view override onlyWeb3Entry;

isApproved

function isApproved(address characterOwner, uint256 characterId, address toCheck) external view returns (bool);

ApprovalLinkModule4Note

Git Source

Inherits: ILinkModule4Note, ModuleBase

This is a simple LinkModule implementation, inheriting from the ILinkModule4Note interface.

State Variables

_approvedByCharacterByNoteByOwner

mapping(address => mapping(uint256 => mapping(uint256 => mapping(address => bool)))) internal _approvedByCharacterByNoteByOwner;

Functions

constructor

constructor(address web3Entry_) ModuleBase(web3Entry_);

initializeLinkModule

function initializeLinkModule(uint256 characterId, uint256 noteId, bytes calldata data) external override returns (bytes memory);

approve

function approve(uint256 characterId, uint256 noteId, address[] calldata addresses, bool[] calldata toApprove) external;
function processLink(address caller, uint256 characterId, uint256 noteId, bytes calldata) external view override onlyWeb3Entry;

isApproved

function isApproved(address characterOwner, uint256 characterId, uint256 noteId, address toCheck) external view returns (bool);

Currency

Git Source

Inherits: ERC20

Functions

mint

function mint(address to, uint256 amount) external;

ERC1271WalletMock

Git Source

Inherits: Ownable, IERC1271, IERC721Receiver

Functions

constructor

constructor(address originalOwner);

isValidSignature

function isValidSignature(bytes32 hash, bytes memory signature) external view override returns (bytes4 magicValue);

onERC721Received

function onERC721Received(address, address, uint256, bytes calldata) external pure override returns (bytes4);

ERC1271MaliciousMock

Git Source

Inherits: IERC1271, IERC721Receiver

Functions

isValidSignature

function isValidSignature(bytes32, bytes memory) external pure override returns (bytes4);

onERC721Received

function onERC721Received(address, address, uint256, bytes calldata) external pure override returns (bytes4);

MiraToken

Git Source

Inherits: AccessControlEnumerable, IERC20Mintable, ERC777

State Variables

BLOCK_ROLE

bytes32 public constant BLOCK_ROLE = keccak256("BLOCK_ROLE");

Functions

constructor

constructor(string memory name_, string memory symbol_, address admin) ERC777(name_, symbol_, new address[](0));

mint

*Creates amount new tokens for to. Requirements:

  • the caller must have the DEFAULT_ADMIN_ROLE.*
function mint(address to, uint256 amount) external override onlyRole(DEFAULT_ADMIN_ROLE);

renounceRole

*Revokes role from the calling account. Requirements:

  • the caller must have the DEFAULT_ADMIN_ROLE.*
function renounceRole(bytes32 role, address account) public override(AccessControl, IAccessControl) onlyRole(DEFAULT_ADMIN_ROLE);

_send

Blocks send tokens from account from who has the BLOCK_ROLE.

function _send( address from, address to, uint256 amount, bytes memory userData, bytes memory operatorData, bool requireReceptionAck ) internal override;

_burn

Disables burn

function _burn(address, uint256, bytes memory, bytes memory) internal pure override;

NFT

Git Source

Inherits: NFTBase, Initializable

Functions

initialize

function initialize(string calldata name_, string calldata symbol_) external initializer;

mint

function mint(address to) public;

NFT1155

Git Source

Inherits: ERC1155

Functions

constructor

constructor() ERC1155("https://ipfsxxxx");

mint

function mint(address to) public;

Contents

Contents

ApprovalMintModule

Git Source

Inherits: IMintModule4Note, ModuleBase

This is a simple MintModule implementation, inheriting from the IMintModule4Note interface. This module works by allowing limited minting for a post, and only for those who are approved.

State Variables

_approvedInfo

mapping(uint256 => mapping(uint256 => mapping(address => ApprovedInfo))) internal _approvedInfo;

Functions

constructor

constructor(address web3Entry_) ModuleBase(web3Entry_);

initializeMintModule

Initialize the MintModule for a specific note.

The data should an abi encoded bytes, containing (in order): an address array and an uint256

function initializeMintModule(uint256 characterId, uint256 noteId, bytes calldata data) external override onlyWeb3Entry returns (bytes memory);

Parameters

NameTypeDescription
characterIduint256The character ID of the note to initialize.
noteIduint256The note ID to initialize.
databytesThe data passed from the user to be decoded.

Returns

NameTypeDescription
<none>bytesbytes The returned data of calling initializeMintModule.

setApprovedAmount

Set the approved addresses for minting and the approvedAmount allowed to be minted.
The approvedAmount is 0 by default, and you can also revoke the approval for addresses by setting the approvedAmount to 0.

function setApprovedAmount(uint256 characterId, uint256 noteId, address[] calldata addresses, uint256 approvedAmount) external;

Parameters

NameTypeDescription
characterIduint256The character ID of the note owner.
noteIduint256The ID of the note.
addressesaddress[]The Addresses to set.
approvedAmountuint256The amount of NFTs allowed to be minted.

processMint

Process minting and check if the caller is eligible.

function processMint(address to, uint256 characterId, uint256 noteId, bytes calldata) external override onlyWeb3Entry;

Parameters

NameTypeDescription
toaddressThe receive address of the NFT.
characterIduint256The character ID of the note owner.
noteIduint256The note ID.
<none>bytes

getApprovedInfo

Returns the approved info indicates the approved amount and minted amount of an address.

function getApprovedInfo(uint256 characterId, uint256 noteId, address account) external view returns (uint256 approvedAmount, uint256 mintedAmount);

Parameters

NameTypeDescription
characterIduint256ID of the character to query.
noteIduint256ID of the note to query.
accountaddressThe address to query.

Returns

NameTypeDescription
approvedAmountuint256The approved amount that the address can mint.
mintedAmountuint256The amount that the address has already minted.

_setApprovedAmount

function _setApprovedAmount(uint256 characterId, uint256 noteId, address[] memory addresses, uint256 approvedAmount) internal;

Structs

ApprovedInfo

struct ApprovedInfo { uint256 approvedAmount; uint256 mintedAmount; }

CharacterNoteData

Git Source

A struct containing associated data with each note.

struct CharacterNoteData { uint256 amount; address token; address recipient; }

FeeMintModule

Git Source

Inherits: IMintModule4Note, ModuleBase

This is a simple MintModule implementation, inheriting from the IMintModule4Note interface.

State Variables

_dataByNoteByCharacter

mapping(uint256 => mapping(uint256 => CharacterNoteData)) internal _dataByNoteByCharacter;

Functions

constructor

constructor(address web3Entry_) ModuleBase(web3Entry_);

initializeMintModule

function initializeMintModule(uint256 characterId, uint256 noteId, bytes calldata data) external override onlyWeb3Entry returns (bytes memory);

processMint

Processes the mint logic by charging a fee. Triggered when the mintNote of web3Entry is called, if mint module of note if set.

function processMint(address to, uint256 characterId, uint256 noteId, bytes calldata data) external override onlyWeb3Entry;

Parameters

NameTypeDescription
toaddress
characterIduint256ID of character.
noteIduint256ID of note.
databytesThe mintModuleData passed by user who called the mintNote of web3Entry .

getNoteData

Returns the associated data for a given note.

onlyWeb3Entry can call processMint

function getNoteData(uint256 characterId, uint256 noteId) external view returns (CharacterNoteData memory);

Parameters

NameTypeDescription
characterIduint256ID of character to query.
noteIduint256ID of note to query.

Returns

NameTypeDescription
<none>CharacterNoteDataReturns the associated data for a given note.

LimitedMintModule

Git Source

Inherits: IMintModule4Note, ModuleBase

This is a simple MintModule implementation, inheriting from the IMintModule4Note interface. This module works by allowing limited minting for a post.

State Variables

_limitedMintInfo

mapping(uint256 => mapping(uint256 => LimitedMintInfo)) internal _limitedMintInfo;

_mintedAmount

mapping(uint256 => mapping(uint256 => mapping(address => uint256))) internal _mintedAmount;

Functions

constructor

constructor(address web3Entry_) ModuleBase(web3Entry_);

initializeMintModule

Initialize the MintModule for a specific note.

The data should an abi encoded bytes of (uint256,uint256)

function initializeMintModule(uint256 characterId, uint256 noteId, bytes calldata data) external override onlyWeb3Entry returns (bytes memory);

Parameters

NameTypeDescription
characterIduint256The character ID of the note to initialize.
noteIduint256The note ID to initialize.
databytesThe data passed from the user to be decoded.

Returns

NameTypeDescription
<none>bytesbytes The returned data of calling initializeMintModule.

processMint

Process minting and check if the caller is eligible.

function processMint(address to, uint256 characterId, uint256 noteId, bytes calldata) external override onlyWeb3Entry;

Parameters

NameTypeDescription
toaddressThe receive address of the NFT.
characterIduint256The character ID of the note owner.
noteIduint256The note ID.
<none>bytes

getLimitedMintInfo

Returns the info indicates the limited mint info of an address.

function getLimitedMintInfo(uint256 characterId, uint256 noteId, address account) external view returns (uint256 maxSupply, uint256 currentSupply, uint256 maxMintPerAddress, uint256 mintedAmount);

Parameters

NameTypeDescription
characterIduint256ID of the character to query.
noteIduint256ID of the note to query.
accountaddressThe address to query.

Returns

NameTypeDescription
maxSupplyuint256The max supply of nft that can be minted.
currentSupplyuint256The current supply of nft that has been minted.
maxMintPerAddressuint256The amount that each address can mint.
mintedAmountuint256The amount that the address has already minted.

Structs

LimitedMintInfo

struct LimitedMintInfo { uint256 maxSupply; uint256 currentSupply; uint256 maxMintPerAddress; }

ModuleBase

Git Source

State Variables

web3Entry

address public immutable web3Entry;

Functions

onlyWeb3Entry

modifier onlyWeb3Entry();

constructor

constructor(address web3Entry_);

Contents

LinklistExtendStorage

Git Source

State Variables

_tokenCount

uint256 internal _tokenCount;

_linklistOwners

mapping(uint256 tokenId => uint256 characterId) internal _linklistOwners;

_linklistBalances

mapping(uint256 characterId => uint256 balances) internal _linklistBalances;

_totalSupply

uint256 internal _totalSupply;

LinklistStorage

Git Source

State Variables

Web3Entry

address public Web3Entry;

_linkTypes

mapping(uint256 => bytes32) internal _linkTypes;

_linkingCharacters

mapping(uint256 => EnumerableSet.UintSet) internal _linkingCharacters;

_linkingAddresses

mapping(uint256 => EnumerableSet.AddressSet) internal _linkingAddresses;

_linkingLinklists

mapping(uint256 => EnumerableSet.UintSet) internal _linkingLinklists;

_linkKeys

mapping(uint256 => EnumerableSet.Bytes32Set) internal _linkKeys;

_linkingERC721s

mapping(bytes32 => DataTypes.ERC721Struct) internal _linkingERC721s;

_linkNotes

mapping(bytes32 => DataTypes.NoteStruct) internal _linkNotes;
mapping(bytes32 => DataTypes.CharacterLinkStruct) internal _linkingCharacterLinks;

_linkingAnys

mapping(bytes32 => string) internal _linkingAnys;

_currentTakeOver

mapping(uint256 => uint256) internal _currentTakeOver;

_uris

mapping(uint256 => string) internal _uris;

_linkingERC721Keys

mapping(uint256 => EnumerableSet.Bytes32Set) internal _linkingERC721Keys;

_linkNoteKeys

mapping(uint256 => EnumerableSet.Bytes32Set) internal _linkNoteKeys;

_linkingCharacterLinkKeys

mapping(uint256 => EnumerableSet.Bytes32Set) internal _linkingCharacterLinkKeys;

_linkingAnyKeys

mapping(uint256 => EnumerableSet.Bytes32Set) internal _linkingAnyKeys;

Web3EntryExtendStorage

Git Source

State Variables

_periphery

address internal _periphery;

_operatorByCharacter

mapping(uint256 => address) internal _operatorByCharacter;

resolver

address public resolver;

_operatorsByCharacter

mapping(uint256 => EnumerableSet.AddressSet) internal _operatorsByCharacter;

_operatorsPermissionBitMap

mapping(uint256 => mapping(address => uint256)) internal _operatorsPermissionBitMap;

_operators4Note

mapping(uint256 => mapping(uint256 => DataTypes.Operators4Note)) internal _operators4Note;

_newbieVilla

address internal _newbieVilla;

_sigNonces

mapping(address => uint256) internal _sigNonces;

Web3EntryStorage

Git Source

State Variables

_characterById

mapping(uint256 => DataTypes.Character) internal _characterById;

_characterIdByHandleHash

mapping(bytes32 => uint256) internal _characterIdByHandleHash;

_primaryCharacterByAddress

mapping(address => uint256) internal _primaryCharacterByAddress;

_attachedLinklists

mapping(uint256 => mapping(bytes32 => uint256)) internal _attachedLinklists;

_noteByIdByCharacter

mapping(uint256 => mapping(uint256 => DataTypes.Note)) internal _noteByIdByCharacter;
mapping(uint256 => address) internal _linkModules4Linklist;

_linkModules4ERC721

disable uninitialized-state check, as linkmodule for erc721 is not enabled currently

mapping(address => mapping(uint256 => address)) internal _linkModules4ERC721;

_linkModules4Address

mapping(address => address) internal _linkModules4Address;

_characterCounter

uint256 internal _characterCounter;
address internal _linklist;

MINT_NFT_IMPL

address internal MINT_NFT_IMPL;

Contents

TransparentUpgradeableProxy

Git Source

Inherits: ERC1967Proxy

*This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand:

  1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself.
  2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says "admin cannot fallback to proxy target". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the ProxyAdmin instance as the real administrative interface of your proxy.*

Functions

constructor

Initializes an upgradeable proxy managed by _admin, backed by the implementation at _logic, and optionally initialized with _data as explained in {ERC1967Proxy-constructor}.

constructor(address _logic, address admin_, bytes memory _data) payable ERC1967Proxy(_logic, _data);

ifAdmin

Modifier used internally that will delegate the call to the implementation unless the sender is the admin.

modifier ifAdmin();

admin

Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[eth_getStorageAt] RPC call. 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103

function admin() external ifAdmin returns (address admin_);

implementation

Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[eth_getStorageAt] RPC call. 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc

function implementation() external ifAdmin returns (address implementation_);

changeAdmin

Changes the admin of the proxy. Emits an {AdminChanged} event. NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.

function changeAdmin(address newAdmin) external virtual ifAdmin;

upgradeTo

Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.

function upgradeTo(address newImplementation) external ifAdmin;

upgradeToAndCall

Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by data, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.

function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin;

_admin

Returns the current admin.

function _admin() internal view virtual returns (address);

_beforeFallback

Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.

function _beforeFallback() internal virtual override;

Linklist

Git Source

Inherits: ILinklist, LinklistBase, LinklistStorage, Initializable, LinklistExtendStorage

Functions

onlyWeb3Entry

modifier onlyWeb3Entry();

onlyExistingToken

modifier onlyExistingToken(uint256 tokenId);

initialize

Initializes the contract.

function initialize(string calldata name_, string calldata symbol_, address web3Entry_) external override reinitializer(2);

Parameters

NameTypeDescription
name_stringThe name of the token.
symbol_stringThe symbol of the token.
web3Entry_addressThe address of the Web3Entry contract.

mint

Mints a Linklist NFT to the specified character with linkType. This can only be called by web3Entry.

function mint(uint256 characterId, bytes32 linkType) external override onlyWeb3Entry returns (uint256 tokenId);

Parameters

NameTypeDescription
characterIduint256The character ID to mint to.
linkTypebytes32The type of link.

Returns

NameTypeDescription
tokenIduint256The minted token ID.

burn

Burns a Linklist NFT.

Only web3Entry can burn the Linklist NFT.

function burn(uint256 tokenId) external override onlyWeb3Entry;

Parameters

NameTypeDescription
tokenIduint256The token ID to burn.

setUri

Sets URI for a linklist.

You can set any URI for your linklist, and the functionality of this URI is undetermined and expandable. One scenario that comes to mind is setting a cover for your liked notes or following list in your bookmarks.

function setUri(uint256 tokenId, string memory uri) external override onlyExistingToken(tokenId);

Parameters

NameTypeDescription
tokenIduint256The token ID to set URI.
uristringThe new URI to set.

setLinkType

Sets the link type of the linklist NFT.

function setLinkType(uint256 tokenId, bytes32 linkType) external override onlyWeb3Entry onlyExistingToken(tokenId);

Parameters

NameTypeDescription
tokenIduint256The token ID of linklist to set.
linkTypebytes32The link type to set.

addLinkingCharacterId

Adds a linked character to a linklist.

function addLinkingCharacterId(uint256 tokenId, uint256 toCharacterId) external override onlyWeb3Entry;

Parameters

NameTypeDescription
tokenIduint256The token ID of linklist.
toCharacterIduint256The character ID to link.

removeLinkingCharacterId

Removes a linked character from a linklist.

function removeLinkingCharacterId(uint256 tokenId, uint256 toCharacterId) external override onlyWeb3Entry;

Parameters

NameTypeDescription
tokenIduint256The token ID of linklist.
toCharacterIduint256The character ID to remove.

addLinkingNote

Adds a linked note to a linklist.

function addLinkingNote(uint256 tokenId, uint256 toCharacterId, uint256 toNoteId) external override onlyWeb3Entry returns (bytes32);

Parameters

NameTypeDescription
tokenIduint256The token ID of linklist.
toCharacterIduint256The character ID to link.
toNoteIduint256The note ID to link.

Returns

NameTypeDescription
<none>bytes32linkKey The link key.

removeLinkingNote

Removes a linked note from a linklist.

function removeLinkingNote(uint256 tokenId, uint256 toCharacterId, uint256 toNoteId) external override onlyWeb3Entry;

Parameters

NameTypeDescription
tokenIduint256The token ID of linklist.
toCharacterIduint256The character ID to remove.
toNoteIduint256The note ID to remove.

addLinkingERC721

Adds a linked ERC721 to a linklist.

function addLinkingERC721(uint256 tokenId, address tokenAddress, uint256 erc721TokenId) external override onlyWeb3Entry returns (bytes32);

Parameters

NameTypeDescription
tokenIduint256The token ID of linklist.
tokenAddressaddressThe address of ERC721 contract.
erc721TokenIduint256The token ID of ERC721.

Returns

NameTypeDescription
<none>bytes32linkKey The link key of ERC721.

removeLinkingERC721

Removes a linked ERC721 from a linklist.

function removeLinkingERC721(uint256 tokenId, address tokenAddress, uint256 erc721TokenId) external override onlyWeb3Entry;

Parameters

NameTypeDescription
tokenIduint256The token ID of linklist.
tokenAddressaddressThe address of ERC721 contract.
erc721TokenIduint256The token ID of ERC721.

addLinkingAddress

Adds a linked address to a linklist.

function addLinkingAddress(uint256 tokenId, address ethAddress) external override onlyWeb3Entry;

Parameters

NameTypeDescription
tokenIduint256The token ID of linklist.
ethAddressaddressThe address to link.

removeLinkingAddress

Removes a linked address from a linklist.

function removeLinkingAddress(uint256 tokenId, address ethAddress) external override onlyWeb3Entry;

Parameters

NameTypeDescription
tokenIduint256The token ID of linklist.
ethAddressaddressThe address to remove.

addLinkingAnyUri

Adds a linked anyURI to a linklist.

function addLinkingAnyUri(uint256 tokenId, string memory toUri) external override onlyWeb3Entry returns (bytes32);

Parameters

NameTypeDescription
tokenIduint256The token ID of linklist.
toUristringThe anyURI to link.

Returns

NameTypeDescription
<none>bytes32linkKey The link key of anyURI.

removeLinkingAnyUri

Removes a linked anyURI from a linklist.

function removeLinkingAnyUri(uint256 tokenId, string memory toUri) external override onlyWeb3Entry;

Parameters

NameTypeDescription
tokenIduint256The token ID of linklist.
toUristringThe anyURI to remove.

addLinkingLinklistId

Adds a linked linklist to a linklist.

function addLinkingLinklistId(uint256 tokenId, uint256 linklistId) external override onlyWeb3Entry;

Parameters

NameTypeDescription
tokenIduint256The token ID of linklist.
linklistIduint256The linklist ID to link.

removeLinkingLinklistId

Removes a linked linklist from a linklist.

function removeLinkingLinklistId(uint256 tokenId, uint256 linklistId) external override onlyWeb3Entry;

Parameters

NameTypeDescription
tokenIduint256The token ID of linklist.
linklistIduint256The linklist ID to remove.

getLinkingCharacterIds

Returns the linked character IDs of the linklist NFT.

function getLinkingCharacterIds(uint256 tokenId) external view override onlyExistingToken(tokenId) returns (uint256[] memory);

Parameters

NameTypeDescription
tokenIduint256The token ID of linklist to check.

Returns

NameTypeDescription
<none>uint256[]The linked character IDs.

getLinkingCharacterListLength

Returns the length of linked character IDs of the linklist NFT.

function getLinkingCharacterListLength(uint256 tokenId) external view override onlyExistingToken(tokenId) returns (uint256);

Parameters

NameTypeDescription
tokenIduint256The token ID of linklist to check.

Returns

NameTypeDescription
<none>uint256The length of linked character IDs .

getOwnerCharacterId

Returns the character ID who owns the linklist NFT.

function getOwnerCharacterId(uint256 tokenId) external view override onlyExistingToken(tokenId) returns (uint256);

Parameters

NameTypeDescription
tokenIduint256The token ID of linklist to check.

Returns

NameTypeDescription
<none>uint256The character ID who owns the linklist NFT.

getLinkingNotes

Returns the linked notes of the linklist NFT.

function getLinkingNotes(uint256 tokenId) external view override onlyExistingToken(tokenId) returns (DataTypes.NoteStruct[] memory results);

Parameters

NameTypeDescription
tokenIduint256The token ID of linklist to check.

Returns

NameTypeDescription
resultsDataTypes.NoteStruct[]The linked notes.

getLinkingNote

Return the linked note of the linklist NFT by linkKey.

function getLinkingNote(bytes32 linkKey) external view override returns (DataTypes.NoteStruct memory);

Parameters

NameTypeDescription
linkKeybytes32The link key of the note.

Returns

NameTypeDescription
<none>DataTypes.NoteStructThe linked note.

getLinkingNoteListLength

Returns the length of linked notes of the linklist NFT.

function getLinkingNoteListLength(uint256 tokenId) external view override onlyExistingToken(tokenId) returns (uint256);

Parameters

NameTypeDescription
tokenIduint256The token ID of linklist to check.

Returns

NameTypeDescription
<none>uint256The length of linked notes.

getLinkingERC721s

Returns the linked ERC721s of the linklist NFT.

function getLinkingERC721s(uint256 tokenId) external view override onlyExistingToken(tokenId) returns (DataTypes.ERC721Struct[] memory results);

Parameters

NameTypeDescription
tokenIduint256The token ID of linklist to check.

Returns

NameTypeDescription
resultsDataTypes.ERC721Struct[]The linked ERC721s.

getLinkingERC721

Return the linked ERC721 of the linklist NFT by linkKey.

function getLinkingERC721(bytes32 linkKey) external view override returns (DataTypes.ERC721Struct memory);

Parameters

NameTypeDescription
linkKeybytes32The link key of the ERC721.

Returns

NameTypeDescription
<none>DataTypes.ERC721StructThe linked ERC721.

getLinkingERC721ListLength

Returns the length of linked ERC721s of the linklist NFT.

function getLinkingERC721ListLength(uint256 tokenId) external view override onlyExistingToken(tokenId) returns (uint256);

Parameters

NameTypeDescription
tokenIduint256The token ID of linklist to check.

Returns

NameTypeDescription
<none>uint256The length of linked ERC721s.

getLinkingAddresses

Returns the linked addresses of the linklist NFT.

function getLinkingAddresses(uint256 tokenId) external view override onlyExistingToken(tokenId) returns (address[] memory);

Parameters

NameTypeDescription
tokenIduint256The token ID of linklist to check.

Returns

NameTypeDescription
<none>address[]The linked addresses.

getLinkingAddressListLength

Returns the linked address of the linklist NFT by linkKey.

function getLinkingAddressListLength(uint256 tokenId) external view override onlyExistingToken(tokenId) returns (uint256);

Parameters

NameTypeDescription
tokenIduint256The token ID of linklist to check.

Returns

NameTypeDescription
<none>uint256The length of linked address.

getLinkingAnyUris

Returns the linked anyURIs of the linklist NFT.

function getLinkingAnyUris(uint256 tokenId) external view override onlyExistingToken(tokenId) returns (string[] memory results);

Parameters

NameTypeDescription
tokenIduint256The token ID of linklist to check.

Returns

NameTypeDescription
resultsstring[]The linked anyURIs.

getLinkingAnyUri

Return the linked anyURI of the linklist NFT by linkKey.

function getLinkingAnyUri(bytes32 linkKey) external view override returns (string memory);

Parameters

NameTypeDescription
linkKeybytes32The link key of the anyURI.

Returns

NameTypeDescription
<none>stringThe linked anyURI.

getLinkingAnyUriKeys

Returns the length of linked anyURIs of the linklist NFT.

function getLinkingAnyUriKeys(uint256 tokenId) external view override onlyExistingToken(tokenId) returns (bytes32[] memory);

Parameters

NameTypeDescription
tokenIduint256The token ID of linklist to check.

Returns

NameTypeDescription
<none>bytes32[]The length of linked anyURIs.

getLinkingAnyListLength

Returns the length of linked Uris of the linklist NFT.

function getLinkingAnyListLength(uint256 tokenId) external view override onlyExistingToken(tokenId) returns (uint256);

Parameters

NameTypeDescription
tokenIduint256The token ID of linklist to check.

Returns

NameTypeDescription
<none>uint256The length of linked Uris.

getLinkingLinklistIds

Returns the linked linklists of the linklist NFT.

function getLinkingLinklistIds(uint256 tokenId) external view override onlyExistingToken(tokenId) returns (uint256[] memory);

Parameters

NameTypeDescription
tokenIduint256The token ID of linklist to check.

Returns

NameTypeDescription
<none>uint256[]The linked linklists.

getLinkingLinklistLength

Return the length of linked linklist of the linklist NFT.

function getLinkingLinklistLength(uint256 tokenId) external view override onlyExistingToken(tokenId) returns (uint256);

Parameters

NameTypeDescription
tokenIduint256The token ID of linklist to check.

Returns

NameTypeDescription
<none>uint256The length of linked linklist.

getCurrentTakeOver

function getCurrentTakeOver(uint256 tokenId) external view override returns (uint256);

getLinkType

Returns the link type of the linklist NFT.

function getLinkType(uint256 tokenId) external view override onlyExistingToken(tokenId) returns (bytes32);

Parameters

NameTypeDescription
tokenIduint256The token ID of linklist to check.

Returns

NameTypeDescription
<none>bytes32The link type.

Uri

Returns the URI of the linklist NFT.

function Uri(uint256 tokenId) external view override onlyExistingToken(tokenId) returns (string memory);

Parameters

NameTypeDescription
tokenIduint256The token ID of linklist to check.

Returns

NameTypeDescription
<none>stringThe URI of the linklist NFT.

characterOwnerOf

Returns the character ID who owns the Linklist NFT.

function characterOwnerOf(uint256 tokenId) external view override onlyExistingToken(tokenId) returns (uint256);

Parameters

NameTypeDescription
tokenIduint256The token ID to check.

Returns

NameTypeDescription
<none>uint256The character ID.

totalSupply

Returns the total supply of the Linklist NFTs.

function totalSupply() external view override returns (uint256);

Returns

NameTypeDescription
<none>uint256The total supply of the Linklist NFTs.

balanceOf

Returns the balance of the character.

function balanceOf(uint256 characterId) external view override returns (uint256);

Parameters

NameTypeDescription
characterIduint256The character ID to check.

Returns

NameTypeDescription
<none>uint256uint256 The balance of the character.

balanceOf

Returns the balance of the character.

function balanceOf(address account) external view override returns (uint256 balance);

Parameters

NameTypeDescription
accountaddress

Returns

NameTypeDescription
balanceuint256uint256 The balance of the character.

ownerOf

Returns the owner of the tokenId token.

function ownerOf(uint256 tokenId) external view override onlyExistingToken(tokenId) returns (address);

Parameters

NameTypeDescription
tokenIduint256The token ID to check.

Returns

NameTypeDescription
<none>addressThe owner of the tokenId token.

_ownerOf

function _ownerOf(uint256 tokenId) internal view returns (address);

Events

Transfer

event Transfer(address indexed from, uint256 indexed characterId, uint256 indexed tokenId);

Burn

event Burn(uint256 indexed from, uint256 indexed tokenId);

UriSet

event UriSet(uint256 indexed tokenId, string uri);

LinkTypeSet

event LinkTypeSet(uint256 indexed tokenId, bytes32 indexed newlinkType);

MintNFT

Git Source

Inherits: NFTBase, IMintNFT, ERC2981, Initializable

State Variables

_characterId

uint256 internal _characterId;

_noteId

uint256 internal _noteId;

_web3Entry

address internal _web3Entry;

_tokenCounter

uint256 internal _tokenCounter;

_originalReceiver

mapping(uint256 => address) internal _originalReceiver;

Functions

onlyWeb3Entry

modifier onlyWeb3Entry();

onlyOwner

modifier onlyOwner();

initialize

Initialize the mint nft.

function initialize( uint256 characterId_, uint256 noteId_, address web3Entry_, string calldata name_, string calldata symbol_ ) external override initializer;

Parameters

NameTypeDescription
characterId_uint256The character ID of the note to initialize.
noteId_uint256The note ID to initialize.
web3Entry_addressThe address of web3Entry contract.
name_stringThe name to set for this NFT.
symbol_stringThe symbol to set for this NFT.

mint

Mints a note NFT to the specified address. This can only be called by web3Entry, and is called upon note.

function mint(address to) external override onlyWeb3Entry returns (uint256 tokenId);

Parameters

NameTypeDescription
toaddressThe address to mint the NFT to.

Returns

NameTypeDescription
tokenIduint256uint256 The minted token ID.

setTokenRoyalty

Changes the royalty percentage of specific token ID for secondary sales. Can only be called by character owner of note.

function setTokenRoyalty(uint256 tokenId, address recipient, uint96 fraction) external override onlyOwner;

Parameters

NameTypeDescription
tokenIduint256The token ID to set.
recipientaddressThe receive address.
fractionuint96The royalty percentage measured in basis points. Each basis point represents 0.01%.

setDefaultRoyalty

Changes the default royalty percentage for secondary sales. Can only be called by character owner of note.

function setDefaultRoyalty(address recipient, uint96 fraction) external override onlyOwner;

Parameters

NameTypeDescription
recipientaddressThe receive address.
fractionuint96The royalty percentage measured in basis points. Each basis point represents 0.01%.

deleteDefaultRoyalty

Deletes the default royalty percentage. Can only be called by character owner of note.

function deleteDefaultRoyalty() external override onlyOwner;

originalReceiver

Returns the original receiver of specified NFT.

function originalReceiver(uint256 tokenId) external view override returns (address);

Returns

NameTypeDescription
<none>addressThe address of original receiver.

getSourceNotePointer

Returns the source note pointer mapped to this note NFT.

function getSourceNotePointer() external view override returns (uint256 characterId, uint256 noteId);

Returns

NameTypeDescription
characterIduint256The character ID.
noteIduint256The note ID.

supportsInterface

function supportsInterface(bytes4 interfaceId) public view virtual override(ERC2981, ERC721Enumerable) returns (bool);

totalSupply

function totalSupply() public view override returns (uint256);

tokenURI

function tokenURI(uint256 tokenId) public view override returns (string memory uri);

Web3Entry

Git Source

Inherits: IWeb3Entry, Multicall, NFTBase, Web3EntryStorage, Initializable, Web3EntryExtendStorage

State Variables

REVISION

uint256 internal constant REVISION = 4;

Functions

validateCallerPermission

modifier validateCallerPermission(uint256 characterId, uint256 permissionId);

onlyExistingToken

modifier onlyExistingToken(uint256 tokenId);

initialize

Initializes the Web3Entry.

function initialize( string calldata name_, string calldata symbol_, address linklist_, address mintNFTImpl_, address periphery_, address newbieVilla_ ) external override reinitializer(3);

Parameters

NameTypeDescription
name_stringThe name to set for the web3Entry character NFT.
symbol_stringThe symbol to set for the web3Entry character NFT.
linklist_addressThe address of linklist contract to set.
mintNFTImpl_addressThe address of mintNFTImpl contract to set.
periphery_addressThe address of periphery contract to set.
newbieVilla_addressThe address of newbieVilla contract to set.

grantOperatorPermissions

Grant an address as an operator and authorize it with custom permissions.

Every bit in permissionBitMap stands for a corresponding method in Web3Entry. more details in OP.sol.

function grantOperatorPermissions(uint256 characterId, address operator, uint256 permissionBitMap) external override validateCallerPermission(characterId, OP.GRANT_OPERATOR_PERMISSIONS);

Parameters

NameTypeDescription
characterIduint256ID of your character that you want to authorize.
operatoraddressAddress to grant operator permissions to.
permissionBitMapuint256Bitmap used for finer grained operator permissions controls.

grantOperatorPermissionsWithSig

Grant an address as an operator and authorize it with custom permissions via signature.

Only character owner can call.

function grantOperatorPermissionsWithSig( uint256 characterId, address operator, uint256 permissionBitMap, DataTypes.EIP712Signature calldata signature ) external override;

Parameters

NameTypeDescription
characterIduint256ID of your character that you want to authorize.
operatoraddressAddress to grant operator permissions to.
permissionBitMapuint256Bitmap used for finer grained operator permissions controls.
signatureDataTypes.EIP712SignatureThe EIP712Signature struct containing the character owner's signature.

grantOperators4Note

Grant operators allowlist and blocklist roles of a note.

function grantOperators4Note( uint256 characterId, uint256 noteId, address[] calldata blocklist, address[] calldata allowlist ) external override validateCallerPermission(characterId, OP.GRANT_OPERATORS_FOR_NOTE);

Parameters

NameTypeDescription
characterIduint256ID of character that you want to set.
noteIduint256ID of note that you want to set.
blocklistaddress[]blocklist addresses that you want to grant.
allowlistaddress[]allowlist addresses that you want to grant.

createCharacter

This method creates a character with the given parameters to the given address.

function createCharacter(DataTypes.CreateCharacterData calldata vars) external override returns (uint256 characterId);

Parameters

NameTypeDescription
varsDataTypes.CreateCharacterDataThe CreateCharacterData struct containing the following parameters: to: The address receiving the character.
handle: The handle to set for the character.
uri: The URI to set for the character metadata.
linkModule: The link module to use, can be the zero address.
linkModuleInitData: The link module initialization data, if any.

setHandle

Sets new handle for a given character.

Owner permission only.

function setHandle(uint256 characterId, string calldata newHandle) external override validateCallerPermission(characterId, OP.SET_HANDLE);

Parameters

NameTypeDescription
characterIduint256The character id to set new handle for.
newHandlestringNew handle to set.

setSocialToken

Sets a social token for a given character.

Owner permission only.

function setSocialToken(uint256 characterId, address tokenAddress) external override validateCallerPermission(characterId, OP.SET_SOCIAL_TOKEN);

Parameters

NameTypeDescription
characterIduint256The characterId to set social token for.
tokenAddressaddressToken address to be set.

setPrimaryCharacterId

Sets a given character as primary.

Only character owner can call this function.

function setPrimaryCharacterId(uint256 characterId) external override;

Parameters

NameTypeDescription
characterIduint256The character id to to be set.

setCharacterUri

Sets a new URI for a given character.

function setCharacterUri(uint256 characterId, string calldata newUri) external override validateCallerPermission(characterId, OP.SET_CHARACTER_URI);

Parameters

NameTypeDescription
characterIduint256The characterId to to be set.
newUristringNew URI to be set.

setLinklistUri

Sets a new metadataURI for a given link list.

function setLinklistUri(uint256 linklistId, string calldata uri) external override;

Parameters

NameTypeDescription
linklistIduint256
uristringThe metadata uri to set.

setLinklistType

Sets a link type for a given linklist.

Emits a {DetachLinklist} event and a {AttachLinklist} event from web3Entry contract..
Emits a {LinkTypeSet} event from linklist contract.
Linklist is the group of all linking objects with the same link type, like "like".
Each character can only have one linklist for each link type.
It will fail if you try to set a link type which is already set for some linklist owned by the same character.

function setLinklistType(uint256 linklistId, bytes32 linkType) external override;

Parameters

NameTypeDescription
linklistIduint256
linkTypebytes32The link type to set.

linkCharacter

Links a character with the given parameters.

function linkCharacter(DataTypes.linkCharacterData calldata vars) external override onlyExistingToken(vars.toCharacterId) validateCallerPermission(vars.fromCharacterId, OP.LINK_CHARACTER);

Parameters

NameTypeDescription
varsDataTypes.linkCharacterDataThe linkCharacterData struct containing the linking parameters:
fromCharacterId: The character ID to sponsor a link action.
toCharacterId: The character ID to be linked.
linkType: The link type, like "follow", which is a bytes32 format.
data: The data passed to the link module to use, if any.

unlinkCharacter

Unlinks a character with the given parameters.

function unlinkCharacter(DataTypes.unlinkCharacterData calldata vars) external override validateCallerPermission(vars.fromCharacterId, OP.UNLINK_CHARACTER);

Parameters

NameTypeDescription
varsDataTypes.unlinkCharacterDataThe unlinkCharacterData struct containing the unlinking parameters: fromCharacterId: The character ID to sponsor a unlink action.
toCharacterId: The character ID to be unlinked.
linkType: The link type, like "follow", which is a bytes32 format.

createThenLinkCharacter

Create a character and then link it.

function createThenLinkCharacter(DataTypes.createThenLinkCharacterData calldata vars) external override validateCallerPermission(vars.fromCharacterId, OP.CREATE_THEN_LINK_CHARACTER) returns (uint256 characterId);

Parameters

NameTypeDescription
varsDataTypes.createThenLinkCharacterDataThe createThenLinkCharacterData struct containing the parameters:
fromCharacterId: The character ID to sponsor a link action.
to: The address to receive the new character nft.
linkType: The link type, like "follow", which is a bytes32 format.

linkNote

Links a note with the given parameters.

function linkNote(DataTypes.linkNoteData calldata vars) external override validateCallerPermission(vars.fromCharacterId, OP.LINK_NOTE);

Parameters

NameTypeDescription
varsDataTypes.linkNoteDataThe linkNoteData struct containing the linking parameters:
fromCharacterId: The character ID to sponsor a link action.
toCharacterId: The character ID of note to be linked.
toNoteId: The note ID of note to be linked.
linkType: The link type, like "like", which is a bytes32 format.
data: The data passed to the link module to use, if any.

unlinkNote

UnLinks a note with the given parameters.

function unlinkNote(DataTypes.unlinkNoteData calldata vars) external override validateCallerPermission(vars.fromCharacterId, OP.UNLINK_NOTE);

Parameters

NameTypeDescription
varsDataTypes.unlinkNoteDataThe unlinkNoteData struct containing the unlinking parameters:
fromCharacterId: The character ID to sponsor a unlink action.
toCharacterId: The character ID of note to be unlinked.
toNoteId: The note ID of note to be unlinked.
linkType: The link type, like "like", which is a bytes32 format.

linkERC721

Links an ERC721 with the given parameters.

function linkERC721(DataTypes.linkERC721Data calldata vars) external override validateCallerPermission(vars.fromCharacterId, OP.LINK_ERC721);

Parameters

NameTypeDescription
varsDataTypes.linkERC721DataThe linkERC721Data struct containing the linking parameters:
fromCharacterId: The character ID to sponsor a link action.
tokenAddress: The token address of ERC721 to be linked.
tokenId: The token ID of ERC721 to be linked.
linkType: The link type, like "like", which is a bytes32 format.
data: The data passed to the link module to use, if any.

unlinkERC721

Unlinks an ERC721 with the given parameters.

function unlinkERC721(DataTypes.unlinkERC721Data calldata vars) external override validateCallerPermission(vars.fromCharacterId, OP.UNLINK_ERC721);

Parameters

NameTypeDescription
varsDataTypes.unlinkERC721DataThe unlinkERC721Data struct containing the unlinking parameters:
fromCharacterId: The character ID to sponsor a unlink action.
tokenAddress: The token address of ERC721 to be unlinked.
tokenId: The token ID of ERC721 to be unlinked.
linkType: The link type, like "like", which is a bytes32 format.

linkAddress

Links an address with the given parameters.

function linkAddress(DataTypes.linkAddressData calldata vars) external override validateCallerPermission(vars.fromCharacterId, OP.LINK_ADDRESS);

Parameters

NameTypeDescription
varsDataTypes.linkAddressDataThe linkAddressData struct containing the linking parameters:
fromCharacterId: The character ID to sponsor a link action.
ethAddress: The address to be linked.
linkType: The link type, like "like", which is a bytes32 format.
data: The data passed to the link module to use, if any.

unlinkAddress

Unlinks an address with the given parameters.

function unlinkAddress(DataTypes.unlinkAddressData calldata vars) external override validateCallerPermission(vars.fromCharacterId, OP.UNLINK_ADDRESS);

Parameters

NameTypeDescription
varsDataTypes.unlinkAddressDataThe unlinkAddressData struct containing the unlinking parameters:
fromCharacterId: The character ID to sponsor a unlink action.
ethAddress: The address to be unlinked.
linkType: The link type, like "like", which is a bytes32 format.

linkAnyUri

Links any uri with the given parameters.

function linkAnyUri(DataTypes.linkAnyUriData calldata vars) external override validateCallerPermission(vars.fromCharacterId, OP.LINK_ANYURI);

Parameters

NameTypeDescription
varsDataTypes.linkAnyUriDataThe linkAnyUriData struct containing the linking parameters:
fromCharacterId: The character ID to sponsor a link action.
toUri: The uri to be linked.
linkType: The link type, like "like", which is a bytes32 format.
data: The data passed to the link module to use, if any.

unlinkAnyUri

Unlinks any uri with the given parameters.

function unlinkAnyUri(DataTypes.unlinkAnyUriData calldata vars) external override validateCallerPermission(vars.fromCharacterId, OP.UNLINK_ANYURI);

Parameters

NameTypeDescription
varsDataTypes.unlinkAnyUriDataThe unlinkAnyUriData struct containing the unlinking parameters:
fromCharacterId: The character ID to sponsor a unlink action.
toUri: The uri to be unlinked.
linkType: The link type, like "like", which is a bytes32 format.

Links a linklist with the given parameters.

function linkLinklist(DataTypes.linkLinklistData calldata vars) external override validateCallerPermission(vars.fromCharacterId, OP.LINK_LINKLIST);

Parameters

NameTypeDescription
varsDataTypes.linkLinklistDataThe linkLinklistData struct containing the linking parameters:
fromCharacterId: The character ID to sponsor a link action.
toLinkListId: The linklist ID to be linked.
linkType: The link type, like "like", which is a bytes32 format.
data: The data passed to the link module to use, if any.

Unlinks a linklist with the given parameters.

function unlinkLinklist(DataTypes.unlinkLinklistData calldata vars) external override validateCallerPermission(vars.fromCharacterId, OP.UNLINK_LINKLIST);

Parameters

NameTypeDescription
varsDataTypes.unlinkLinklistDataThe unlinkLinklistData struct containing the unlinking parameters:
fromCharacterId: The character ID to sponsor a unlink action.
toLinkListId: The linklist ID to be unlinked.
linkType: The link type, like "like", which is a bytes32 format.

setLinkModule4Character

Sets a link module for a given character.

function setLinkModule4Character(DataTypes.setLinkModule4CharacterData calldata vars) external override validateCallerPermission(vars.characterId, OP.SET_LINK_MODULE_FOR_CHARACTER);

Parameters

NameTypeDescription
varsDataTypes.setLinkModule4CharacterDataThe setLinkModule4CharacterData struct containing the parameters:
characterId: The character ID to set for.
linkModule: The address of link module contract to set.
linkModuleInitData: The data passed to the link module to use, if any.

setLinkModule4Note

Sets a link module for a given note.

function setLinkModule4Note(DataTypes.setLinkModule4NoteData calldata vars) external override validateCallerPermission(vars.characterId, OP.SET_LINK_MODULE_FOR_NOTE);

Parameters

NameTypeDescription
varsDataTypes.setLinkModule4NoteDataThe setLinkModule4NoteData struct containing the parameters:
characterId: The character ID to set for.
noteId: The note ID to set for.
linkModule: The address of link module contract to set.
linkModuleInitData: The data passed to the link module to use, if any.

mintNote

Mints an nft with the given note.

function mintNote(DataTypes.MintNoteData calldata vars) external override returns (uint256 tokenId);

Parameters

NameTypeDescription
varsDataTypes.MintNoteDataThe MintNoteData struct containing the minting parameters:
characterId: The character ID of the note.
noteId: The note ID of the note.
to: The address to receive the minted nft.
data: The data passed to the mint module to use, if any.

setMintModule4Note

Sets a mint module for the given note.

function setMintModule4Note(DataTypes.setMintModule4NoteData calldata vars) external override validateCallerPermission(vars.characterId, OP.SET_MINT_MODULE_FOR_NOTE);

Parameters

NameTypeDescription
varsDataTypes.setMintModule4NoteDataThe setMintModule4NoteData struct containing the setting parameters:
characterId: The character ID of the note.
noteId: The note ID of the note.
mintModule: The address of mint module to set.
mintModuleInitData: The data passed to the mint module to init, if any.

postNote

Posts a note with the given parameters.

function postNote(DataTypes.PostNoteData calldata vars) external override validateCallerPermission(vars.characterId, OP.POST_NOTE) returns (uint256 noteId);

Parameters

NameTypeDescription
varsDataTypes.PostNoteDataThe postNoteData struct containing the posting parameters:
characterId: The character ID to post to.
contentUri: The uri to set for the new post.
linkModule: The address of link module to set for the new post.
linkModuleInitData: The data passed to the link module to init, if any.
mintModule: The address of mint module to set for the new post.
mintModuleInitData: The data passed to the mint module to init, if any.

setNoteUri

Set URI for a note.

function setNoteUri(uint256 characterId, uint256 noteId, string calldata newUri) external override;

Parameters

NameTypeDescription
characterIduint256The character ID of the note owner.
noteIduint256The ID of the note to set.
newUristringThe new URI.

lockNote

Lock a note and put it into a immutable state where no modifications are allowed. Locked notes are usually assumed as final versions.

function lockNote(uint256 characterId, uint256 noteId) external override validateCallerPermission(characterId, OP.LOCK_NOTE);

Parameters

NameTypeDescription
characterIduint256The character ID of the note owner.
noteIduint256The ID of the note to lock.

deleteNote

Delete a note.

Deleting a note doesn't essentially mean that the txs or contents are being removed due to the immutability of blockchain itself, but the deleted notes will be tagged as deleted after calling deleteNote.

function deleteNote(uint256 characterId, uint256 noteId) external override validateCallerPermission(characterId, OP.DELETE_NOTE);

Parameters

NameTypeDescription
characterIduint256The character ID of the note owner.
noteIduint256The ID of the note to delete.

postNote4Character

Posts a note for a given character.

function postNote4Character(DataTypes.PostNoteData calldata vars, uint256 toCharacterId) external override validateCallerPermission(vars.characterId, OP.POST_NOTE_FOR_CHARACTER) returns (uint256 noteId);

Parameters

NameTypeDescription
varsDataTypes.PostNoteDataThe postNoteData struct containing the posting parameters:
characterId: The character ID to post to.
contentUri: The uri to set for the new post.
linkModule: The address of link module to set for the new post.
linkModuleInitData: The data passed to the link module to init, if any.
mintModule: The address of mint module to set for the new post.
mintModuleInitData: The data passed to the mint module to init, if any.
toCharacterIduint256The target character ID.

Returns

NameTypeDescription
noteIduint256The note ID of the new post.

postNote4Address

Posts a note for a given address.

function postNote4Address(DataTypes.PostNoteData calldata vars, address ethAddress) external override validateCallerPermission(vars.characterId, OP.POST_NOTE_FOR_ADDRESS) returns (uint256 noteId);

Parameters

NameTypeDescription
varsDataTypes.PostNoteDataThe postNoteData struct containing the posting parameters:
characterId: The character ID to post to.
contentUri: The uri to set for the new post.
linkModule: The address of link module to set for the new post.
linkModuleInitData: The data passed to the link module to init, if any.
mintModule: The address of mint module to set for the new post.
mintModuleInitData: The data passed to the mint module to init, if any.
ethAddressaddressThe target address.

Returns

NameTypeDescription
noteIduint256The note ID of the new post.

Posts a note for a given linklist.

function postNote4Linklist(DataTypes.PostNoteData calldata vars, uint256 toLinklistId) external override validateCallerPermission(vars.characterId, OP.POST_NOTE_FOR_LINKLIST) returns (uint256 noteId);

Parameters

NameTypeDescription
varsDataTypes.PostNoteDataThe postNoteData struct containing the posting parameters:
characterId: The character ID to post to.
contentUri: The uri to set for the new post.
linkModule: The address of link module to set for the new post.
linkModuleInitData: The data passed to the link module to init, if any.
mintModule: The address of mint module to set for the new post.
mintModuleInitData: The data passed to the mint module to init, if any.
toLinklistIduint256The target linklist.

Returns

NameTypeDescription
noteIduint256The note ID of the new post.

postNote4Note

Posts a note for a given note.

function postNote4Note(DataTypes.PostNoteData calldata vars, DataTypes.NoteStruct calldata note) external override validateCallerPermission(vars.characterId, OP.POST_NOTE_FOR_NOTE) returns (uint256 noteId);

Parameters

NameTypeDescription
varsDataTypes.PostNoteDataThe postNoteData struct containing the posting parameters:
characterId: The character ID to post to.
contentUri: The uri to set for the new post.
linkModule: The address of link module to set for the new post.
linkModuleInitData: The data passed to the link module to init, if any.
mintModule: The address of mint module to set for the new post.
mintModuleInitData: The data passed to the mint module to init, if any.
noteDataTypes.NoteStructThe target note struct containing the parameters:
characterId: The character ID of target note.
noteId: The note ID of target note.

Returns

NameTypeDescription
noteIduint256The note ID of the new post.

postNote4ERC721

Posts a note for a given ERC721.

function postNote4ERC721(DataTypes.PostNoteData calldata vars, DataTypes.ERC721Struct calldata erc721) external override validateCallerPermission(vars.characterId, OP.POST_NOTE_FOR_ERC721) returns (uint256 noteId);

Parameters

NameTypeDescription
varsDataTypes.PostNoteDataThe postNoteData struct containing the posting parameters:
characterId: The character ID to post to.
contentUri: The uri to set for the new post.
linkModule: The address of link module to set for the new post.
linkModuleInitData: The data passed to the link module to init, if any.
mintModule: The address of mint module to set for the new post.
mintModuleInitData: The data passed to the mint module to init, if any.
erc721DataTypes.ERC721StructThe target ERC721 struct containing the parameters:
tokenAddress: The token address of target ERC721.
erc721TokenId: The token ID of target ERC721.

Returns

NameTypeDescription
noteIduint256The note ID of the new post.

postNote4AnyUri

Posts a note for a given uri.

function postNote4AnyUri(DataTypes.PostNoteData calldata vars, string calldata uri) external override validateCallerPermission(vars.characterId, OP.POST_NOTE_FOR_ANYURI) returns (uint256 noteId);

Parameters

NameTypeDescription
varsDataTypes.PostNoteDataThe postNoteData struct containing the posting parameters:
characterId: The character ID to post to.
contentUri: The uri to set for the new post.
linkModule: The address of link module to set for the new post.
linkModuleInitData: The data passed to the link module to init, if any.
mintModule: The address of mint module to set for the new post.
mintModuleInitData: The data passed to the mint module to init, if any.
uristringThe target uri(could be an url link).

Returns

NameTypeDescription
noteIduint256The note ID of the new post.

Burns a linklist NFT.

It will burn the linklist NFT and remove the links from a character.

function burnLinklist(uint256 linklistId) external override;

Parameters

NameTypeDescription
linklistIduint256The linklist ID to burn.

getOperators

Get operator list of a character. This operator list has only a sole purpose, which is keeping records of keys of operatorsPermissionBitMap. Thus, addresses queried by this function not always have operator permissions. Keep in mind don't use this function to check authorizations!!!

function getOperators(uint256 characterId) external view override returns (address[] memory);

Parameters

NameTypeDescription
characterIduint256ID of your character that you want to check.

Returns

NameTypeDescription
<none>address[]All keys of operatorsPermission4NoteBitMap.

getOperatorPermissions

Get permission bitmap of an operator.

function getOperatorPermissions(uint256 characterId, address operator) external view override returns (uint256);

Parameters

NameTypeDescription
characterIduint256ID of character that you want to check.
operatoraddressAddress to grant operator permissions to.

Returns

NameTypeDescription
<none>uint256Permission bitmap of this operator.

getOperators4Note

Get operators blocklist and allowlist for a note.

function getOperators4Note(uint256 characterId, uint256 noteId) external view override returns (address[] memory blocklist, address[] memory allowlist);

Parameters

NameTypeDescription
characterIduint256ID of character to query.
noteIduint256ID of note to query.

isOperatorAllowedForNote

Query if a operator has permission for a note.

function isOperatorAllowedForNote(uint256 characterId, uint256 noteId, address operator) external view override returns (bool);

Parameters

NameTypeDescription
characterIduint256ID of character that you want to query.
noteIduint256ID of note that you want to query.
operatoraddressAddress to query.

Returns

NameTypeDescription
<none>booltrue if Operator has permission for a note, otherwise false.

getPrimaryCharacterId

Returns primary character for a given account.

function getPrimaryCharacterId(address account) external view override returns (uint256);

Parameters

NameTypeDescription
accountaddressThe address to query.

Returns

NameTypeDescription
<none>uint256uint256 The primary character ID, which will be 0 if not mapped.

isPrimaryCharacter

Returns whether or not a character is primary character.

function isPrimaryCharacter(uint256 characterId) external view override returns (bool);

Parameters

NameTypeDescription
characterIduint256The character ID to query.

Returns

NameTypeDescription
<none>boolbool True if the character is primary, false otherwise.

getCharacter

Returns the full character struct associated with a given character token ID.

function getCharacter(uint256 characterId) external view override onlyExistingToken(characterId) returns (DataTypes.Character memory);

Parameters

NameTypeDescription
characterIduint256The token ID of the character to query.

Returns

NameTypeDescription
<none>DataTypes.CharacterThe full character struct of given character.

getCharacterByHandle

Returns the full character struct associated with a given character handle.

function getCharacterByHandle(string calldata handle) external view override returns (DataTypes.Character memory);

Parameters

NameTypeDescription
handlestringThe handle of the character to query.

Returns

NameTypeDescription
<none>DataTypes.CharacterThe full character struct of given character.

getHandle

Returns the handle of character with a given character.

function getHandle(uint256 characterId) external view override onlyExistingToken(characterId) returns (string memory);

Parameters

NameTypeDescription
characterIduint256The token ID of the character to query.

Returns

NameTypeDescription
<none>stringThe handle of given character.

getCharacterUri

Returns the uri of character with a given character.

function getCharacterUri(uint256 characterId) external view override returns (string memory);

Parameters

NameTypeDescription
characterIduint256The token ID of the character to query.

Returns

NameTypeDescription
<none>stringThe uri of given character.

getNote

Returns the full note struct associated with a given note.

function getNote(uint256 characterId, uint256 noteId) external view override returns (DataTypes.Note memory);

Parameters

NameTypeDescription
characterIduint256The token ID of the character to query.
noteIduint256The token ID of the note to query.

Returns

NameTypeDescription
<none>DataTypes.NoteThe full note struct of given note.

getLinklistUri

Returns the uri of linklist with a given linklist.

function getLinklistUri(uint256 tokenId) external view override returns (string memory);

Parameters

NameTypeDescription
tokenIduint256The token ID of the linklist to query.

Returns

NameTypeDescription
<none>stringstring The uri of given linklist.

getLinklistId

Returns the token ID of linklist with a given character and linkType.

function getLinklistId(uint256 characterId, bytes32 linkType) external view override returns (uint256);

Parameters

NameTypeDescription
characterIduint256The token ID of the character to query.
linkTypebytes32The linkType.

Returns

NameTypeDescription
<none>uint256The token ID of linklist.

getLinklistType

Returns the linkType of linklist with a given linklist.

function getLinklistType(uint256 linkListId) external view override returns (bytes32);

Parameters

NameTypeDescription
linkListIduint256The token ID of the linklist to query.

Returns

NameTypeDescription
<none>bytes32bytes32 The linkType of given linklist.

getLinklistContract

Returns the address of linklist contract.

function getLinklistContract() external view override returns (address);

Returns

NameTypeDescription
<none>addressThe address of linklist contract.

getDomainSeparator

Returns the domain separator for this NFT contract.

function getDomainSeparator() external view override returns (bytes32);

Returns

NameTypeDescription
<none>bytes32bytes32 The domain separator.

nonces

Returns the current nonce for owner. This value must be included whenever a signature is generated by grantOperatorPermissionsWithSig. Every successful call to grantOperatorPermissionsWithSig increases owner's nonce by one. This prevents a signature from being used multiple times.

function nonces(address owner) external view override returns (uint256);

Parameters

NameTypeDescription
owneraddressThe owner address to query.

Returns

NameTypeDescription
<none>uint256uint256 The current nonce for owner.

getRevision

Returns the revision number of web3Entry contract.

function getRevision() external pure override returns (uint256);

Returns

NameTypeDescription
<none>uint256The the revision number of web3Entry contract.

burn

Burns a web3Entry character nft.

function burn(uint256 tokenId) public virtual override;

Parameters

NameTypeDescription
tokenIduint256The token ID to burn.

tokenURI

Returns the associated URI with a given character.

function tokenURI(uint256 characterId) public view override onlyExistingToken(characterId) returns (string memory);

Parameters

NameTypeDescription
characterIduint256The character ID to query.

Returns

NameTypeDescription
<none>stringThe token URI.

_createCharacter

function _createCharacter(DataTypes.CreateCharacterData memory vars, bool validateHandle) internal returns (uint256 characterId);

_beforeTokenTransfer

Operators will be reset to blank before the characters are transferred in order to grant the whole control power to receivers of character transfers. If character is transferred from newbieVilla contract, don't clear operators. Permissions4Note is left unset, because permissions for notes are always stricter than default.

function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual override;

_afterTokenTransfer

function _afterTokenTransfer(address from, address to, uint256 tokenId) internal virtual override;

_nextNoteId

function _nextNoteId(uint256 characterId) internal returns (uint256);

_isOperatorAllowedForNote

It will first check note permission, and then check operators permission.

function _isOperatorAllowedForNote(uint256 characterId, uint256 noteId, address operator) internal view returns (bool);

_validateCallerPermission

function _validateCallerPermission(uint256 characterId, uint256 permissionId) internal view;

_callerIsCharacterOwner

function _callerIsCharacterOwner(address caller, uint256 characterId) internal view returns (bool);

_validateCallerPermission4Note

function _validateCallerPermission4Note(uint256 characterId, uint256 noteId) internal view;

_checkBit

_checkBit checks if the value of the i'th bit of x is 1

function _checkBit(uint256 x, uint256 i) internal pure returns (bool);

_addressToHexString

_addressToHexString converts an address to its ASCII `string hexadecimal representation.

function _addressToHexString(address addr) internal pure returns (string memory);

_handleHash

function _handleHash(string memory handle) internal pure returns (bytes32);