Skip to main content

Generated Docs

Solidity contracts provided as part of Paima Engine.

Core contracts

State-annotated contracts

  • AnnotatedMintNft: A standard ERC721 that accepts calldata in the mint function for any initialization data needed in a Paima dApp.
  • InverseBaseProjectedNft: Project game state into a ERC721 NFT on an EVM layer initiated on said base layer.
  • InverseAppProjectedNft: Project game state into a ERC721 NFT on an EVM layer initiated on the app layer.
  • InverseBaseProjected1155: Project game state into a ERC1155 on an EVM layer initiated on said base layer.
  • InverseAppProjected1155: Project game state into a ERC1155 on an EVM layer initiated on the app layer.

Facilitating monetization

  • NativeNftSale: Facilitates selling NFTs that accepts extra data when buying for any initialization data needed in a Paima dApp.
  • GenericPayment: Facilitates accepting payment that accepts extra data to know what the payment was for inside a Paima dApp.
  • Erc20NftSale: Facilitates selling NFTs for specific ERC20s that accepts extra data when buying for any initialization data needed in a Paima dApp.
  • OrderbookDexProxy: Proxy for the orderbook DEX contract.
  • IOrderbookDex: Interface to facilitate trading inverse projected ERC1155 tokens.
  • OrderbookDex: Facilitates trading inverse projected ERC1155 tokens.

Core contracts​

PaimaL2Contract​

#
import "@paima/evm-contracts/contracts/PaimaL2Contract.sol";

The main L2 contract for a Paima L2.

constructor(address _owner, uint256 _fee)public#

Sets the contract owner to _owner and payment fee to _fee.

paimaSubmitGameInput(bytes data)public#

Emits the PaimaGameInteraction event, logging the msg.sender, data, and msg.value. Revert if msg.value is less than set fee.

withdrawFunds()public#

Withdraws the contract balance to the owner. Callable only by the contract owner.

setOwner(address newOwner)public#

Sets the newOwner as the contract owner. Callable only by the contract owner.

setFee(uint256 newFee)public#

Sets the newFee as the required payment fee. Callable only by the contract owner.

owner() β†’ addresspublic#

Contract owner.

fee() β†’ uint256public#

Amount in wei that is required to be paid when calling paimaSubmitGameInput.

PaimaGameInteraction(address indexed userAddress, bytes data, uint256 value)event#

Emitted when paimaSubmitGameInput function is called with data. userAddress is the transaction sender and value is the transaction value.

State-annotated contracts​

AnnotatedMintNft​

#
import "@paima/evm-contracts/contracts/AnnotatedMintNft.sol";

A standard ERC721 that accepts calldata in the mint function for any initialization data needed in a Paima dApp. Upon deployment only the contract owner (specified in constructor parameter) is able to mint tokens. Additional minters (e.g. NativeNftSale contract) need to be added by using the setMinter function.

canMint()modifier#

Reverts if msg.sender is neither a minter nor the contract owner.

onlyTokenOwner(uint256 tokenId)modifier#

Reverts if msg.sender is not the specified token's owner.

constructor(string name, string symbol, uint256 supply, address owner)public#

Sets the NFT's name, symbol, maxSupply to supply, currentTokenId to 1 and baseExtension to ".json".

supportsInterface(bytes4 interfaceID) β†’ boolpublic#

Returns true if this contract implements the interface defined by interfaceID. See EIP165.

mint(address _to, string initialData) β†’ uint256external#

Mints a new token to address _to, passing initialData to be emitted in the event. Increases the totalSupply and currentTokenId. Reverts if totalSupply is not less than maxSupply or if _to is a zero address. Emits the Minted event.

burn(uint256 _tokenId)external#

Burns token of ID _tokenId. Callable only by the owner of the specified token. Reverts if _tokenId is not existing.

setMinter(address _minter)external#

Adds _minter to the mapping of allowed minters of this NFT. Callable only by the contract owner. Emits the SetMinter event.

removeMinter(address _minter)external#

Removes _minter from the mapping of allowed minters of this NFT. Callable only by the contract owner. Emits the RemoveMinter event.

_baseURI() β†’ stringinternal#

Returns the baseURI of this NFT.

tokenURI(uint256 tokenId) β†’ stringpublic#

Returns the token URI of specified tokenId.

setBaseURI(string _URI)external#

Sets _URI as the baseURI of the NFT. Callable only by the contract owner. Emits the SetBaseURI event.

setBaseExtension(string _newBaseExtension)public#

Sets _newBaseExtension as the baseExtension of the NFT. Callable only by the contract owner.

updateMaxSupply(uint256 _maxSupply)external#

Sets _maxSupply as the maxSupply of the NFT. Callable only by the contract owner. Emits the UpdateMaxSupply event.

exists(uint256 _tokenId) β†’ boolexternal#

Returns true if specified _tokenId exists.

isMinter(address _account) β†’ boolpublic#

Returns true if _account is in the mapping of allowed minters.

currentTokenId() β†’ uint256public#

The token ID that will be minted when calling the mint function.

baseURI() β†’ stringpublic#

Base URI that is used in the tokenURI function to form the start of the token URI.

totalSupply() β†’ uint256public#

Total token supply, increased by minting and decreased by burning.

maxSupply() β†’ uint256public#

Maximum amount of tokens that is allowed to exist.

baseExtension() β†’ stringpublic#

Base extension that is used in the tokenURI function to form the end of the token URI.

minters() β†’ mapping(address => bool)public#

Returns true for addresses that are allowed to mint this token.

UpdateMaxSupply(uint256 indexed oldMaxSupply, uint256 indexed newMaxSupply)event#

Emitted when max supply is updated from oldMaxSupply to newMaxSupply.

SetMinter(address indexed newMinter)event#

Emitted when newMinter is added to the mapping of allowed minters.

RemoveMinter(address indexed oldMinter)event#

Emitted when oldMinter is removed from the mapping of allowed minters

SetBaseURI(string oldUri, string newUri)event#

Emitted when baseUri is updated from oldUri to newUri.

Minted(uint256 indexed tokenId, string initialData)event#

Emitted when a new token with ID tokenId is minted, with initialData provided in the mint function parameters.

IInverseProjectedNft​

#
import "@paima/evm-contracts/contracts/token/IInverseProjectedNft.sol";

A standard ERC721 that can be burned and has a special tokenURI function accepting a custom base URI. See PRC3 for more.

burn(uint256 _tokenId)external#

Burns token of ID _tokenId. Callable only by the owner of the specified token. Reverts if _tokenId is not existing.

setBaseURI(string _URI)external#

Sets _URI as the baseURI of the NFT. Callable only by the contract owner. Emits the SetBaseURI event.

setBaseExtension(string _newBaseExtension)external#

Sets _newBaseExtension as the baseExtension of the NFT. Callable only by the contract owner.

tokenURI(uint256 tokenId, string customBaseUri) β†’ stringexternal#

Returns the token URI of specified tokenId using a custom base URI.

tokenURI(uint256 tokenId, contract ITokenUri customUriInterface) β†’ stringexternal#

Returns the token URI of specified tokenId using a call to contract implementing ITokenUri.

SetBaseExtension(string oldBaseExtension, string newBaseExtension)event#

Emitted when baseExtension is updated from oldBaseExtension to newBaseExtension.

SetBaseURI(string oldUri, string newUri)event#

Emitted when baseUri is updated from oldUri to newUri.

IInverseBaseProjectedNft​

#
import "@paima/evm-contracts/contracts/token/IInverseBaseProjectedNft.sol";

A Paima Inverse Projection NFT where initialization is handled by the base-layer. A standard ERC721 that accepts calldata in the mint function for any initialization data needed in a Paima dApp. See PRC3 for more.

mint(address _to, string initialData, bytes data) β†’ uint256external#

Mints a new token to address _to, passing initialData to be emitted in the event. Increases the totalSupply and currentTokenId. Reverts if _to is a zero address or if it refers to smart contract but does not implement IERC721Receiver-onERC721Received. Emits the Minted event.

mint(address _to, string initialData) β†’ uint256external#

Shorthand function that calls the mint function with empty data.

Minted(uint256 indexed tokenId, string initialData)event#

Emitted when the globally-enforced tokenId is minted, with initialData provided in the mint function parameters.

InverseBaseProjectedNft​

#
import "@paima/evm-contracts/contracts/token/InverseBaseProjectedNft.sol";

A standard ERC721 that accepts calldata in the mint function for any initialization data needed in a Paima dApp. See PRC3 for more.

onlyTokenOwner(uint256 tokenId)modifier#

Reverts if msg.sender is not the specified token's owner.

constructor(string name, string symbol, address owner)public#

Sets the NFT's name, symbol, and transfers ownership to owner. Also sets currentTokenId to 1 and baseExtension to ".json".

supportsInterface(bytes4 interfaceId) β†’ boolpublic#

Returns true if this contract implements the interface defined by interfaceId. See EIP165.

mint(address _to, string initialData, bytes data) β†’ uint256public#

Mints a new token to address _to, passing initialData to be emitted in the event. Increases the totalSupply and currentTokenId. Reverts if _to is a zero address or if it refers to smart contract but does not implement IERC721Receiver-onERC721Received. Emits the Minted event.

mint(address _to, string initialData) β†’ uint256public#

Shorthand function that calls the mint function with empty data.

burn(uint256 _tokenId)public#

Burns token of ID _tokenId. Callable only by the owner of the specified token. Reverts if _tokenId does not exist.

_baseURI() β†’ stringinternal#

Returns the baseURI of this NFT.

tokenURI(uint256 tokenId) β†’ stringpublic#

Returns the token URI of specified tokenId using the default set base URI.

tokenURI(uint256 tokenId, string customBaseUri) β†’ stringpublic#

Returns the token URI of specified tokenId using a custom base URI.

tokenURI(uint256 tokenId, contract ITokenUri customUriInterface) β†’ stringpublic#

Returns the token URI of specified tokenId using a call to contract implementing ITokenUri.

setBaseURI(string _URI)public#

Sets _URI as the baseURI of the NFT. Callable only by the contract owner. Emits the SetBaseURI event.

setBaseExtension(string _newBaseExtension)public#

Sets _newBaseExtension as the baseExtension of the NFT. Callable only by the contract owner.

updateMetadataBatch(uint256 _fromTokenId, uint256 _toTokenId)public#

Function that emits an event to notify third-parties (e.g. NFT marketplaces) about an update to consecutive range of tokens. Can be overridden in inheriting contract.

updateMetadata(uint256 _tokenId)public#

Function that emits an event to notify third-parties (e.g. NFT marketplaces) about an update to a single token. Can be overridden in inheriting contract.

currentTokenId() β†’ uint256public#

The token ID that will be minted when calling the mint function.

baseURI() β†’ stringpublic#

Base URI that is used in the tokenURI function to form the start of the token URI.

totalSupply() β†’ uint256public#

Total token supply, increased by minting and decreased by burning.

baseExtension() β†’ stringpublic#

Base extension that is used in the tokenURI function to form the end of the token URI.

IInverseAppProjectedNft​

#
import "@paima/evm-contracts/contracts/token/IInverseAppProjectedNft.sol";

A Paima Inverse Projection NFT where initialization is handled by the app-layer. A standard ERC721 that can be freely minted and stores an unique <minter, userTokenId> pair (used in tokenURI) when minted. See PRC3 for more.

mint(address _to, bytes _verificationData, bytes _data) β†’ uint256external#

Mints a new token to address _to Increases the totalSupply and currentTokenId. Reverts if _to is a zero address or if it refers to smart contract but does not implement IERC721Receiver-onERC721Received. Emits the Minted event.

mint(address _to, bytes _verificationData) β†’ uint256external#

Shorthand function that calls the mint function with empty _data.

mint(address _to) β†’ uint256external#

Shorthand function that calls the mint function with empty _verificationData and empty _data.

currentNonce(address seller) β†’ uint256external#

Useful if you need to either needs to

  1. Check if the nonce matches the expected value, or if more NFTs need to be minted
  2. Use a nonce algorithm where the next nonce depends on the current nonce
Minted(uint256 indexed tokenId, address indexed minter, uint256 indexed userTokenId)event#

Emitted when the globally-enforced tokenId in combination with an unique <minter, userTokenId> pair is minted.

InverseAppProjectedNft​

#
import "@paima/evm-contracts/contracts/token/InverseAppProjectedNft.sol";

A standard ERC721 that accepts calldata in the mint function for any initialization data needed in a Paima dApp. See PRC3 for more.

onlyTokenOwner(uint256 tokenId)modifier#

Reverts if msg.sender is not the specified token's owner.

constructor(string name, string symbol, address owner)public#

Sets the NFT's name, symbol, and transfers ownership to owner. Also sets currentTokenId to 1 and baseExtension to ".json".

supportsInterface(bytes4 interfaceId) β†’ boolpublic#

Returns true if this contract implements the interface defined by interfaceId. See EIP165.

currentNonce(address user) β†’ uint256public#

No description given

validateMint(address, bytes) β†’ boolinternal#

No description given

mint(address _to, bytes _verificationData, bytes _data) β†’ uint256public#

Mints a new token to address _to Increases the totalSupply and currentTokenId. Reverts if _to is a zero address or if it refers to smart contract but does not implement IERC721Receiver-onERC721Received. Emits the Minted event.

mint(address _to, bytes _verificationData) β†’ uint256public#

Shorthand function that calls the mint function with empty _data.

mint(address _to) β†’ uint256public#

Shorthand function that calls the mint function with empty _verificationData and empty _data.

burn(uint256 _tokenId)public#

Burns token of ID _tokenId. Callable only by the owner of the specified token. Reverts if _tokenId does not exist.

_baseURI() β†’ stringinternal#

Returns the baseURI of this NFT.

tokenURI(uint256 tokenId) β†’ stringpublic#

Returns the token URI of specified tokenId using the default set base URI.

tokenURI(uint256 tokenId, string customBaseUri) β†’ stringpublic#

Returns the token URI of specified tokenId using a custom base URI.

tokenURI(uint256 tokenId, contract ITokenUri customUriInterface) β†’ stringpublic#

Returns the token URI of specified tokenId using a call to contract implementing ITokenUri.

setBaseURI(string _URI)public#

Sets _URI as the baseURI of the NFT. Callable only by the contract owner. Emits the SetBaseURI event.

setBaseExtension(string _newBaseExtension)public#

Sets _newBaseExtension as the baseExtension of the NFT. Callable only by the contract owner.

updateMetadataBatch(uint256 _fromTokenId, uint256 _toTokenId)public#

Function that emits an event to notify third-parties (e.g. NFT marketplaces) about an update to consecutive range of tokens. Can be overridden in inheriting contract.

updateMetadata(uint256 _tokenId)public#

Function that emits an event to notify third-parties (e.g. NFT marketplaces) about an update to a single token. Can be overridden in inheriting contract.

tokenToMint() β†’ mapping(uint256 => struct MintEntry)public#

tokenId => MintEntry.

mintCount() β†’ mapping(address => uint256)public#

No description given

currentTokenId() β†’ uint256public#

The token ID that will be minted when calling the mint function.

baseURI() β†’ stringpublic#

Base URI that is used in the tokenURI function to form the start of the token URI.

totalSupply() β†’ uint256public#

Total token supply, increased by minting and decreased by burning.

baseExtension() β†’ stringpublic#

Base extension that is used in the tokenURI function to form the end of the token URI.

IInverseProjected1155​

#
import "@paima/evm-contracts/contracts/token/IInverseProjected1155.sol";

A standard ERC1155 that can be burned and has a special uri function accepting a custom base URI.

burn(uint256 id, uint256 value)external#

Burns value amount of token of ID id from transaction sender. Reverts if transaction sender's balance of id is less than value.

burnBatch(uint256[] ids, uint256[] values)external#

Burns batch of values amounts of tokens of IDs ids from transaction sender. Reverts if transaction sender's balance of any id is less than value.

setBaseURI(string _URI)external#

Sets _URI as the baseURI. Callable only by the contract owner. Emits the SetBaseURI event.

setBaseExtension(string _newBaseExtension)external#

Sets _newBaseExtension as the baseExtension. Callable only by the contract owner.

uri(uint256 id, string customBaseUri) β†’ stringexternal#

Returns the token URI of specified id using a custom base URI.

uri(uint256 id, contract IUri customUriInterface) β†’ stringexternal#

Returns the token URI of specified id using a call to contract implementing IUri.

SetBaseExtension(string oldBaseExtension, string newBaseExtension)event#

Emitted when baseExtension is updated from oldBaseExtension to newBaseExtension.

SetBaseURI(string oldUri, string newUri)event#

Emitted when baseUri is updated from oldUri to newUri.

IInverseBaseProjected1155​

#
import "@paima/evm-contracts/contracts/token/IInverseBaseProjected1155.sol";

A Paima Inverse Projection ERC1155 token where initialization is handled by the base-layer. A standard ERC1155 that accepts calldata in the mint function for any initialization data needed in a Paima dApp.

mint(uint256 value, bytes data, string initialData) β†’ uint256external#

Mints value of a new token to transaction sender, passing initialData to be emitted in the event. Increases the currentTokenId. Reverts if transaction sender is a smart contract that does not implement IERC1155Receiver-onERC1155Received. Emits the Minted event.

Minted(uint256 indexed tokenId, uint256 value, string initialData)event#

Emitted when value amount of globally-enforced tokenId is minted, with initialData provided in the mint function parameters.

InverseBaseProjected1155​

#
import "@paima/evm-contracts/contracts/token/InverseBaseProjected1155.sol";

A Paima Inverse Projection ERC1155 token where initialization is handled by the base-layer. A standard ERC1155 that accepts calldata in the mint function for any initialization data needed in a Paima dApp.

constructor(string _name, string _symbol, address _owner)public#

Sets the NFT's name, symbol, and transfers ownership to owner. Also sets currentTokenId to 1.

supportsInterface(bytes4 interfaceId) β†’ boolpublic#

Returns true if this contract implements the interface defined by interfaceId. See EIP165.

totalSupply(uint256 id) β†’ uint256public#

Returns the total amount of tokens with ID id that currently exists.

mint(uint256 value, bytes data, string initialData) β†’ uint256public#

Mints value of a new token to transaction sender, passing initialData to be emitted in the event. Increases the currentTokenId. Reverts if transaction sender is a smart contract that does not implement IERC1155Receiver-onERC1155Received. Emits the Minted event.

burn(uint256 id, uint256 value)public#

Burns value amount of token of ID id from transaction sender. Reverts if transaction sender's balance of id is less than value.

burnBatch(uint256[] ids, uint256[] values)public#

Burns batch of values amounts of tokens of IDs ids from transaction sender. Reverts if transaction sender's balance of any id is less than value.

uri(uint256 id) β†’ stringpublic#

Returns the token URI of specified id using the default set base URI.

uri(uint256 id, string customBaseUri) β†’ stringpublic#

Returns the token URI of specified id using a custom base URI.

uri(uint256 id, contract IUri customUriInterface) β†’ stringpublic#

Returns the token URI of specified id using a call to contract implementing IUri.

setBaseURI(string _URI)public#

Sets _URI as the baseURI of the NFT. Callable only by the contract owner. Emits the SetBaseURI event.

setBaseExtension(string _newBaseExtension)public#

Sets _newBaseExtension as the baseExtension of the NFT. Callable only by the contract owner.

updateMetadataBatch(uint256 _fromTokenId, uint256 _toTokenId)public#

Function that emits an event to notify third-parties (e.g. NFT marketplaces) about an update to consecutive range of tokens. Can be overridden in inheriting contract.

updateMetadata(uint256 _tokenId)public#

Function that emits an event to notify third-parties (e.g. NFT marketplaces) about an update to a single token. Can be overridden in inheriting contract.

_update(address from, address to, uint256[] ids, uint256[] values)internal#

See {ERC1155-_update}.

name() β†’ stringpublic#

No description given

symbol() β†’ stringpublic#

No description given

currentTokenId() β†’ uint256public#

The token ID that will be minted when calling the mint function.

baseURI() β†’ stringpublic#

Base URI that is used in the uri function to form the start of the token URI.

baseExtension() β†’ stringpublic#

Base extension that is used in the uri function to form the end of the token URI.

IInverseAppProjected1155​

#
import "@paima/evm-contracts/contracts/token/IInverseAppProjected1155.sol";

A Paima Inverse Projection ERC1155 token where initialization is handled by the app-layer. A standard ERC1155 that can be freely minted and stores an unique <minter, userTokenId> pair (used in tokenURI) when minted.

currentNonce(address user) β†’ uint256external#

Useful if you need to either needs to

  1. Check if the nonce matches the expected value, or if more NFTs need to be minted
  2. Use a nonce algorithm where the next nonce depends on the current nonce
mint(uint256 value, bytes data, bytes verificationData) β†’ uint256external#

Mints value of a new token to the transaction sender. Increases the currentTokenId. Reverts if transaction sender is a smart contract that does not implement IERC1155Receiver-onERC1155Received. Emits the Minted event.

mint(uint256 value, bytes data) β†’ uint256external#

This works identically to the other function with an extra data parameter, except this function just sets data to "".

Minted(uint256 indexed tokenId, address indexed minter, uint256 indexed userTokenId, uint256 value)event#

Emitted when value amount of globally-enforced tokenId in combination with an unique <minter, userTokenId> pair is minted.

InverseAppProjected1155​

#
import "@paima/evm-contracts/contracts/token/InverseAppProjected1155.sol";

A Paima Inverse Projection ERC1155 token where initialization is handled by the app-layer. A standard ERC1155 that can be freely minted and stores an unique <minter, userTokenId> pair (used in tokenURI) when minted.

constructor(string _name, string _symbol, address _owner)public#

Sets the token's _name, _symbol, and transfers ownership to _owner. Also sets currentTokenId to 1.

supportsInterface(bytes4 interfaceId) β†’ boolpublic#

Returns true if this contract implements the interface defined by interfaceId. See EIP165.

currentNonce(address user) β†’ uint256public#

Useful if you need to either needs to

  1. Check if the nonce matches the expected value, or if more NFTs need to be minted
  2. Use a nonce algorithm where the next nonce depends on the current nonce
validateMint(address, bytes) β†’ boolinternal#

No description given

initialSupply(uint256 id) β†’ uint256public#

Returns the amount of token with ID id that had been initially minted.

totalSupply(uint256 id) β†’ uint256public#

Returns the total amount of tokens with ID id that currently exists.

mint(uint256 value, bytes data, bytes verificationData) β†’ uint256public#

Mints value of a new token to the transaction sender. Increases the currentTokenId. Reverts if transaction sender is a smart contract that does not implement IERC1155Receiver-onERC1155Received. Emits the Minted event.

mint(uint256 value, bytes data) β†’ uint256public#

This works identically to the other function with an extra data parameter, except this function just sets data to "".

burn(uint256 id, uint256 value)public#

Burns value amount of token of ID id from transaction sender. Reverts if transaction sender's balance of id is less than value.

burnBatch(uint256[] ids, uint256[] values)public#

Burns batch of values amounts of tokens of IDs ids from transaction sender. Reverts if transaction sender's balance of any id is less than value.

uri(uint256 id) β†’ stringpublic#

Returns the token URI of specified id using the default set base URI.

uri(uint256 id, string customBaseUri) β†’ stringpublic#

Returns the token URI of specified id using a custom base URI.

uri(uint256 id, contract IUri customUriInterface) β†’ stringpublic#

Returns the token URI of specified id using a call to contract implementing IUri.

setBaseURI(string _URI)public#

Sets _URI as the baseURI of the NFT. Callable only by the contract owner. Emits the SetBaseURI event.

setBaseExtension(string _newBaseExtension)public#

Sets _newBaseExtension as the baseExtension of the NFT. Callable only by the contract owner.

updateMetadataBatch(uint256 _fromTokenId, uint256 _toTokenId)public#

Function that emits an event to notify third-parties (e.g. NFT marketplaces) about an update to consecutive range of tokens. Can be overridden in inheriting contract.

updateMetadata(uint256 _tokenId)public#

Function that emits an event to notify third-parties (e.g. NFT marketplaces) about an update to a single token. Can be overridden in inheriting contract.

_update(address from, address to, uint256[] ids, uint256[] values)internal#

See {ERC1155-_update}.

name() β†’ stringpublic#

No description given

symbol() β†’ stringpublic#

No description given

tokenToMint() β†’ mapping(uint256 => struct MintEntry)public#

No description given

mintCount() β†’ mapping(address => uint256)public#

No description given

currentTokenId() β†’ uint256public#

The token ID that will be minted when calling the mint function.

baseURI() β†’ stringpublic#

Base URI that is used in the uri function to form the start of the token URI.

baseExtension() β†’ stringpublic#

Base extension that is used in the uri function to form the end of the token URI.

Facilitating monetization​

NativeNftSale​

#
import "@paima/evm-contracts/contracts/NativeNftSale.sol";

Facilitates selling NFTs that accepts extra data when buying for any initialization data needed in a Paima dApp.

constructor()public#

No description given

initialize(address owner, address _nft, uint256 _price)public#

Initializes the contract with the requested price _price in native tokens for specified NFT _nft, transferring ownership to the specified owner. Callable only once. Emits the Initialized event.

buyNft(address receiverAddress, string initialData) β†’ uint256public#

Purchases NFT for address receiverAddress, paying required price in native token. This function calls the mint function on the AnnotatedMintNft contract, passing provided initialData. Emits the BuyNFT event.

updatePrice(uint256 _nftPrice)external#

Changes the sale price to _nftPrice. Callable only by the contract owner. Emits the UpdatePrice event.

withdraw(address payable _account)external#

Withdraws the contract balance to _account. Callable only by the contract owner.

upgradeContract(address _newContract)external#

Upgrades the contract implementation to _newContract. Callable only by the contract owner.

receive()external#

Function allowing the contract to receive native tokens.

Initialized(address indexed owner, address indexed nft)event#

Emitted when the contract is initialized.

UpdatePrice(uint256 indexed oldPrice, uint256 indexed newPrice)event#

Emitted when the NFT price is updated from oldPrice to newPrice.

BuyNFT(uint256 indexed tokenId, uint256 indexed PRICE, address indexed receiver, address buyer)event#

Emitted when an NFT of tokenId is minted to receiver by buyer paying PRICE in native tokens.

GenericPayment​

#
import "@paima/evm-contracts/contracts/GenericPayment.sol";

Facilitates accepting payment that accepts extra data to know what the payment was for inside a Paima dApp.

constructor()public#

No description given

initialize(address owner)public#

Initializes the contracts, transferring ownership to the specified owner. Callable only once. Emits the Initialized event.

pay(string message)external#

Transfers native tokens to the contract, providing message. Emits the Pay event.

withdraw(address payable _account)external#

Withdraws the contract balance to _account. Callable only by the contract owner.

upgradeContract(address _newContract)external#

Upgrades the contract implementation to _newContract. Callable only by the contract owner.

initialized() β†’ boolpublic#

True if contract has been initialized via the initialize function.

Initialized(address indexed owner)event#

Emitted when the contract is initialized.

Pay(uint256 amount, address payer, string message)event#

Emitted when payment of amount if made by payer with message.

Erc20NftSale​

#
import "@paima/evm-contracts/contracts/Erc20NftSale.sol";

Facilitates selling NFTs for specific ERC20s that accepts extra data when buying for any initialization data needed in a Paima dApp.

constructor()public#

No description given

initialize(contract ERC20[] currencies, address owner, address _nft, uint256 _price)public#

Initializes the contract with the requested price _price in tokens of currencies for specified NFT _nft, transferring ownership to the specified owner. Callable only once. Emits the Initialized event.

buyWithToken(contract ERC20 _tokenAddress, address receiverAddress, string initialData) β†’ uint256public#

Purchases NFT for address receiverAddress, paying required price in token of _tokenAddress, if it is one of the supportedCurrencies. This function calls the mint function on the AnnotatedMintNft contract, passing provided initialData. Emits the BuyWithToken event.

removeWhitelistedToken(contract ERC20 _token)external#

Removes _token from the list of supportedCurrencies. Callable only by the contract owner. Emits the RemoveWhitelistedToken event.

whitelistTokens(contract ERC20[] _tokens)external#

Adds _tokens to the supportedCurrencies array. Callable only by the contract owner. Emits the WhitelistTokens event.

updatePrice(uint256 _nftPrice)external#

Changes the sale price to _nftPrice. Callable only by the contract owner. Emits the UpdatePrice event.

withdraw(address _account)external#

Withdraws the contract balance of depositedCurrencies to _account. Callable only by the contract owner.

upgradeContract(address _newContract)external#

Upgrades the contract implementation to _newContract. Callable only by the contract owner.

tokenIsWhitelisted(contract ERC20 _token) β†’ boolpublic#

Returns true if _token is part of the supportedCurrencies.

getDepositedCurrencies() β†’ contract ERC20[]public#

Returns the token addresses that have been used as a payment in the NFT purchases.

getSupportedCurrencies() β†’ contract ERC20[]public#

Returns an array of token addresses that are accepted as payment in the NFT purchase.

Initialized(contract ERC20[] indexed currencies, address indexed owner, address indexed nft)event#

Emitted when the contract is initialized.

UpdatePrice(uint256 indexed oldPrice, uint256 indexed newPrice)event#

Emitted when the NFT price is updated from oldPrice to newPrice.

RemoveWhitelistedToken(address indexed token)event#

Emitted when the token is removed from the list of supportedCurrencies.

WhitelistTokens(address[] indexed tokens)event#

Emitted when the tokens are added as the supportedCurrencies.

BuyWithToken(uint256 indexed tokenId, uint256 indexed PRICE, address indexed receiver, address buyer)event#

Emitted when an NFT of tokenId is minted to receiver by buyer paying PRICE in tokens of supportedCurrencies.

OrderbookDexProxy​

#
import "@paima/evm-contracts/contracts/Proxy/OrderbookDexProxy.sol";
constructor(address _implementation, address _owner, uint256 _defaultMakerFee, uint256 _defaultTakerFee, uint256 _orderCreationFee)public#

No description given

IOrderbookDex​

#
import "@paima/evm-contracts/contracts/orderbook/IOrderbookDex.sol";

Orders are identified by an asset-specific unique incremental orderId.

balances(address user) β†’ uint256external#

No description given

claim()external#

No description given

currentOrderId(address asset) β†’ uint256external#

No description given

collectedFees() β†’ uint256external#

No description given

defaultMakerFee() β†’ uint256external#

No description given

defaultTakerFee() β†’ uint256external#

No description given

orderCreationFee() β†’ uint256external#

No description given

maxFee() β†’ uint256external#

No description given

getAssetFeeInfo(address asset) β†’ struct IOrderbookDex.FeeInfoexternal#

No description given

getAssetAppliedFees(address asset) β†’ uint256 makerFee, uint256 takerFeeexternal#

No description given

setAssetFeeInfo(address asset, uint256 makerFee, uint256 takerFee)external#

MUST revert if makerFee or takerFee exceeds maxFee. MUST revert if called by unauthorized account.

setDefaultFeeInfo(uint256 makerFee, uint256 takerFee)external#

MUST revert if makerFee or takerFee exceeds maxFee. MUST revert if called by unauthorized account.

setOrderCreationFee(uint256 fee)external#

MUST revert if called by unauthorized account.

getOrder(address asset, uint256 orderId) β†’ struct IOrderbookDex.Orderexternal#

No description given

createSellOrder(address asset, uint256 assetId, uint256 assetAmount, uint256 pricePerAsset) β†’ uint256external#

The order information is saved in a mapping asset -> orderId -> Order, with orderId being an asset-specific unique incremental identifier. MUST transfer the assetAmount of asset with ID assetId from the seller to the contract. MUST emit OrderCreated event. MUST revert if msg.value is less than orderCreationFee.

createBatchSellOrder(address asset, uint256[] assetIds, uint256[] assetAmounts, uint256[] pricesPerAssets) β†’ uint256[]external#

This is a batched version of createSellOrder that simply iterates through the arrays to call said function. MUST revert if msg.value is less than orderCreationFee * assetIds.length.

fillOrdersExactEth(address asset, uint256 minimumAsset, uint256[] orderIds)external#

Transfers portions of msg.value to the orders' sellers according to the price. The sum of asset amounts of filled orders MUST be at least minimumAsset. If msg.value is more than the sum of orders' prices, it MUST refund the excess back to msg.sender. MUST decrease the assetAmount parameter for the specified order according to how much of it was filled, and transfer that amount of the order's asset with ID assetId to the buyer. MUST emit OrderFilled event for each order accordingly.

fillOrdersExactAsset(address asset, uint256 assetAmount, uint256[] orderIds)external#

Transfers portions of msg.value to the orders' sellers according to the price. The sum of asset amounts of filled orders MUST be exactly assetAmount. Excess ETH MUST be returned back to msg.sender. MUST decrease the assetAmount parameter for the specified order according to how much of it was filled, and transfer that amount of the order's asset with ID assetId to the buyer. MUST emit OrderFilled event for each order accordingly. If msg.value is more than the sum of orders' prices, it MUST refund the difference back to msg.sender.

cancelSellOrder(address asset, uint256 orderId)external#

MUST revert if the order's seller is not msg.sender. MUST change the assetAmount parameter for the specified order to 0. MUST emit OrderCancelled event. MUST transfer the order's assetAmount of asset with assetId back to the seller.

cancelBatchSellOrder(address asset, uint256[] orderIds)external#

This is a batched version of cancelSellOrder that simply iterates through the array to call said function.

withdrawFees()external#

MUST transfer the entire contract balance to the owner. MUST revert if called by unauthorized account. MUST emit FeesWithdrawn event.

BalanceClaimed(address indexed user, uint256 amount)event#

No description given

FeeInfoChanged(address indexed asset, uint256 makerFee, uint256 takerFee)event#

No description given

OrderCreated(address indexed asset, uint256 indexed assetId, uint256 indexed orderId, address seller, uint256 assetAmount, uint256 pricePerAsset, uint256 makerFee, uint256 takerFee)event#

No description given

OrderFilled(address indexed asset, uint256 indexed assetId, uint256 indexed orderId, address seller, address buyer, uint256 assetAmount, uint256 pricePerAsset, uint256 makerFeeCollected, uint256 takerFeeCollected)event#

No description given

OrderCancelled(address indexed asset, uint256 indexed assetId, uint256 indexed orderId)event#

No description given

OrderCreationFeeChanged(uint256 oldFee, uint256 newFee)event#

No description given

FeesWithdrawn(address indexed receiver, uint256 amount)event#

No description given

OrderbookDex​

#
import "@paima/evm-contracts/contracts/orderbook/OrderbookDex.sol";

Orders are identified by an asset-specific unique incremental orderId.

Functions

constructor()public#

No description given

initialize(address _owner, uint256 _defaultMakerFee, uint256 _defaultTakerFee, uint256 _orderCreationFee)public#

No description given

claim()external#

No description given

getAssetFeeInfo(address asset) β†’ struct IOrderbookDex.FeeInfopublic#

No description given

getAssetAppliedFees(address asset) β†’ uint256 makerFee, uint256 takerFeepublic#

No description given

setAssetFeeInfo(address asset, uint256 makerFee, uint256 takerFee)public#

MUST revert if makerFee or takerFee exceeds maxFee. MUST revert if called by unauthorized account.

setDefaultFeeInfo(uint256 makerFee, uint256 takerFee)public#

MUST revert if makerFee or takerFee exceeds maxFee. MUST revert if called by unauthorized account.

setOrderCreationFee(uint256 fee)public#

MUST revert if called by unauthorized account.

getOrder(address asset, uint256 orderId) β†’ struct IOrderbookDex.Orderpublic#

No description given

createSellOrder(address asset, uint256 assetId, uint256 assetAmount, uint256 pricePerAsset) β†’ uint256external#

The order information is saved in a mapping asset -> orderId -> Order, with orderId being an asset-specific unique incremental identifier. MUST transfer the assetAmount of asset with ID assetId from the seller to the contract. MUST emit OrderCreated event. MUST revert if msg.value is less than orderCreationFee.

createBatchSellOrder(address asset, uint256[] assetIds, uint256[] assetAmounts, uint256[] pricesPerAssets) β†’ uint256[]external#

This is a batched version of createSellOrder that simply iterates through the arrays to call said function. MUST revert if msg.value is less than orderCreationFee * assetIds.length.

fillOrdersExactEth(address asset, uint256 minimumAsset, uint256[] orderIds)external#

Transfers portions of msg.value to the orders' sellers according to the price. The sum of asset amounts of filled orders MUST be at least minimumAsset. If msg.value is more than the sum of orders' prices, it MUST refund the excess back to msg.sender. MUST decrease the assetAmount parameter for the specified order according to how much of it was filled, and transfer that amount of the order's asset with ID assetId to the buyer. MUST emit OrderFilled event for each order accordingly.

fillOrdersExactAsset(address asset, uint256 assetAmount, uint256[] orderIds)external#

Transfers portions of msg.value to the orders' sellers according to the price. The sum of asset amounts of filled orders MUST be exactly assetAmount. Excess ETH MUST be returned back to msg.sender. MUST decrease the assetAmount parameter for the specified order according to how much of it was filled, and transfer that amount of the order's asset with ID assetId to the buyer. MUST emit OrderFilled event for each order accordingly. If msg.value is more than the sum of orders' prices, it MUST refund the difference back to msg.sender.

cancelSellOrder(address asset, uint256 orderId)external#

MUST revert if the order's seller is not msg.sender. MUST change the assetAmount parameter for the specified order to 0. MUST emit OrderCancelled event. MUST transfer the order's assetAmount of asset with assetId back to the seller.

cancelBatchSellOrder(address asset, uint256[] orderIds)external#

This is a batched version of cancelSellOrder that simply iterates through the array to call said function.

withdrawFees()external#

MUST transfer the entire contract balance to the owner. MUST revert if called by unauthorized account. MUST emit FeesWithdrawn event.

supportsInterface(bytes4 interfaceId) β†’ boolpublic#

Returns true if this contract implements the interface defined by interfaceId. See EIP165.

_authorizeUpgrade(address)internal#

No description given

_createSellOrder(address asset, uint256 assetId, uint256 assetAmount, uint256 pricePerAsset) β†’ uint256internal#

No description given

_cancelSellOrder(address asset, uint256 orderId)internal#

No description given

maxFee() β†’ uint256public#

No description given

balances() β†’ mapping(address => uint256)public#

No description given

currentOrderId() β†’ mapping(address => uint256)public#

No description given

collectedFees() β†’ uint256public#

No description given

defaultMakerFee() β†’ uint256public#

No description given

defaultTakerFee() β†’ uint256public#

No description given

orderCreationFee() β†’ uint256public#

No description given

FeeTooHigh()error#

No description given

OrderDoesNotExist(uint256 orderId)error#

No description given

InsufficientEndAmount(uint256 expectedAmount, uint256 actualAmount)error#

No description given

InsufficientPayment()error#

No description given

InvalidArrayLength()error#

No description given

InvalidInput(uint256 input)error#

No description given

Unauthorized(address sender)error#

No description given

Utilities​

BaseState​

#
import "@paima/evm-contracts/contracts/BaseState.sol";
nftPrice() β†’ uint256public#

Required payment for the NFT in sale.

initialized() β†’ boolpublic#

True if contract has been initialized via initialize function.

nftAddress() β†’ addresspublic#

Address of the NFT for sale.

State​

#
import "@paima/evm-contracts/contracts/State.sol";
nftPrice() β†’ uint256public#

Required payment for the NFT in sale.

initialized() β†’ boolpublic#

True if contract has been initialized via initialize function.

nftAddress() β†’ addresspublic#

Address of the NFT for sale.

depositedCurrencies() β†’ contract ERC20[]public#

Array of addresses of tokens that have been deposited to the contract via NFT sales.

depositedCurrenciesMap() β†’ mapping(contract ERC20 => bool)public#

Mapping that returns true for address of token that has been deposited to the contract via NFT sale.

supportedCurrencies() β†’ contract ERC20[]public#

Array of addresses of tokens that are accepted as payment for the NFT sale.

IERC4906Agnostic​

#
import "@paima/evm-contracts/contracts/token/IERC4906Agnostic.sol";
MetadataUpdate(uint256 _tokenId)event#

This event emits when the metadata of a token is changed. So that the third-party platforms such as NFT market could timely update the images and related attributes of the token.

BatchMetadataUpdate(uint256 _fromTokenId, uint256 _toTokenId)event#

This event emits when the metadata of a range of tokens is changed. So that the third-party platforms such as NFT market could timely update the images and related attributes of the tokens.

ERC1967​

#
import "@paima/evm-contracts/contracts/ERC1967.sol";

ERC1967 contract providing randomized implementation storage slot Made as a small subset of https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/proxy/ERC1967/ERC1967Upgrade.sol

_assertCorrectImplementationSlot()internal#

Assert that value of _IMPLEMENTATION_SLOT matches expected value

_getImplementation() β†’ addressinternal#

Returns the current implementation address.

_setImplementation(address newImplementation)internal#

Stores a new address in the EIP1967 implementation slot.

import "@paima/evm-contracts/contracts/token/IUri.sol";

An interface exposing the uri function from IERC1155MetadataURI.

Functions

uri(uint256 id) β†’ stringexternal#

Returns the URI for token type id.

If the \{id\} substring is present in the URI, it must be replaced by clients with the actual token type ID.

ITokenUri​

#
import "@paima/evm-contracts/contracts/token/ITokenUri.sol";

An interface exposing the tokenURI function from IERC721Metadata.

tokenURI(uint256 tokenId) β†’ stringexternal#

Returns the Uniform Resource Identifier (URI) for tokenId token.

NativeNftSaleProxy​

#
import "@paima/evm-contracts/contracts/Proxy/NativeNftSaleProxy.sol";

Proxy contract mostly based on https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/proxy/Proxy.sol

constructor(address implementation, address owner, address nftAddress, uint256 nftPrice)public#

Sets implementation address and calls the NativeNftSale.initialize function with the parameters owner, nftAddress, nftPrice.

_delegate(address target)internal#

Delegates the current call to implementation. This function does not return to its internal call site, it will return directly to the external caller.

_fallback()internal#

Delegates the current call to the address returned by _implementation(). This function does not return to its internal call site, it will return directly to the external caller.

fallback()external#

Fallback function that delegates calls to the address returned by _implementation(). Will run if no other function in the contract matches the call data.

receive()external#

Called if this contract is receiving native tokens and msg.data is empty

GenericPaymentProxy​

#
import "@paima/evm-contracts/contracts/Proxy/GenericPaymentProxy.sol";

Proxy contract mostly based on https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/proxy/Proxy.sol

constructor(address implementation, address owner)public#

Sets implementation address and calls the GenericPayment.initialize function with the parameter owner.

_delegate(address target)internal#

Delegates the current call to implementation. This function does not return to its internal call site, it will return directly to the external caller.

_fallback()internal#

Delegates the current call to the address returned by _implementation(). This function does not return to its internal call site, it will return directly to the external caller.

fallback()external#

Fallback function that delegates calls to the address returned by _implementation(). Will run if no other function in the contract matches the call data.

Erc20NftSaleProxy​

#
import "@paima/evm-contracts/contracts/Proxy/Erc20NftSaleProxy.sol";

Proxy contract mostly based on https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/proxy/Proxy.sol

constructor(address implementation, contract ERC20[] currencies, address owner, address nftAddress, uint256 nftPrice)public#

Sets implementation address and calls the Erc20NftSale.initialize function with the parameters currencies, owner, nftAddress, nftPrice.

_delegate(address target)internal#

Delegates the current call to implementation. This function does not return to its internal call site, it will return directly to the external caller.

_fallback()internal#

Delegates the current call to the address returned by _implementation(). This function does not return to its internal call site, it will return directly to the external caller.

fallback()external#

Fallback function that delegates calls to the address returned by _implementation(). Will run if no other function in the contract matches the call data.

receive()external#

Called if this contract is receiving native tokens and msg.data is empty