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.

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 overriden 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 overriden 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 overriden 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 overriden 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 overriden 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 overriden 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 overriden 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 overriden 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.

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.

IUri

#
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