CapsuleMinter.sol

The CapsuleMinter Contract

The CapsuleMinter contract is an intermediary contract that holds tokens, assigns user holdings, and prevents abuse. This contract is responsible for the mintage of all Capsules. Nearly any token can be incorporated in the Capsule Protocol, with the exception of deflationary and rebasing tokens. Deflationary tokens are prohibited because the Capsule Protocol performs a check that the exact amount of token deposited is found at the contract post-transfer. Rebasing tokens are prohibited because their amount will change within the contract.

Capsule NFTs’ mint and burn functions are only callable through the CapsuleMinter. While this has no impact on the end functionality of the Capsule NFT (the methods work exactly as expected, simply through an intermediary), it prevents users from abusing contracts. You can think of the routing of NFT methods through the CapsuleMinter as a security blanket to ensure that no one can cheat the Capsule Protocol.

NOTE: It is important to consider that certain tokens, such as rebasing tokens (for example, Ampleforth) will change their amount from within the protocol. As such, refrain from placing such tokens directly into Capsule NFTs unless you wrap the token first (for example, Wrapped Ampleforth).

NOTE: The Capsule Protocol supports deflationary tokens, but note that two 'deflation events' (placing into a Capsule NFT and redeeming from a Capsule NFT) occur when interacting with such.

View CapsuleMinter.sol verified contract code on Etherscan

View CapsuleMinter.sol verified proxy contract code on Etherscan

User Interactable Methods

mintSimpleCapsule

function mintSimpleCapsule(address _capsule, string _uri, address _receiver) external payable

Usage: (External) Create a simple Capsule (normal compatible ERC-721 NFT) from collection _capsule with passed in _uri.

Parameters:

  • _capsule: (address) - the address of the Capsule Collection

  • _uri: (string) - the NFT tokenURI

  • _receiver: (address) - the address which will receive the NFT (can be a contract)

Returns: (Nothing)


burnSimpleCapsule

Usage: (External) Burn a simple Capsule from collection _capsule (normally, there is no incentive to do so).

Parameters:

  • _capsule: (address) - the address of the Capsule Collection

  • _id: (uint256) - the Simple Capsule NFT id

Returns: (Nothing)


mintSingleERC20Capsule

Usage: (External) Create an ERC-721 Capsule from collection _capsule which holds an _amount of one token at address _token, with passed in _uri.

Parameters:

  • _capsule: (address) - the address of the Capsule Collection

  • _token: (address) - the token address to be deposited alongside creation of the Capsule

  • _amount: (uint256) - the amount of token to be deposited alongside creation of the Capsule

  • _uri: (string) - the NFT URI (IPFS hashes commonly used)

Returns: (Nothing)


burnSingleERC20Capsule

Usage: (External) Burn a Capsule from collection _capsule at _id. (This will return the amount of token at address token which is attached to that Capsule to the owner)

Parameters:

  • _capsule: (address) - the address of the Capsule Collection

  • _id: (uint256) - the Capsule token id to burn

Returns: (Nothing)


mintSingleERC721Capsule

Usage: (External) Create an ERC-721 Capsule from collection _capsule which holds one ERC-721 compatible token at address _token and _id, with passed in _uri.

Parameters:

  • _capsule: (address) - the address of the Capsule Collection

  • _token: (address) - the token address to be deposited alongside creation of the Capsule

  • _id: (uint256) - the id of token to be deposited alongside creation of the Capsule

  • _uri: (string) - the NFT URI (IPFS hashes commonly used)

Returns: (Nothing)


burnSingleERC721Capsule

Usage: (External) Burn a Capsule from collection _capsule at _id. This will return the ERC-721 token at address token which is attached to that Capsule to the sender.

Parameters:

  • _capsule: (address) - the address of the Capsule Collection

  • _id: (uint256) - the Capsule token id to burn

Returns: (Nothing)


mintMultiERC20Capsule

Usage: (External) Create an ERC-721 Capsule from collection _capsule which holds multiple _amounts of multiple tokens at address _tokens, with passed in _uri. _tokens is passed in as an array, of which each token is matched by an amount in the _amounts array.

For example - a call should be formatted like so:

  • _capsule: your Capsule Collection address

  • _tokens: [ <token-address-1>, <token-address-2]

  • _amounts: [ <token-amount-of-token-address-1>, <token-amount-of-token-address-2> ]

  • _uri: your URI

To which, two token transfers are required, and one Capsule is returned to the user.

Parameters:

  • _capsule: (address) - the address of the Capsule Collection

  • _tokens: (address[]) - the token addresses to be deposited alongside creation of the Capsule

  • _amounts: (uint256[]) - the amounts of each token to be deposited alongside creation of the Capsule

  • _uri: (string) - the NFT URI (IPFS hashes commonly used)

Returns: (Nothing)


burnMultiERC20Capsule

Usage: (External) Burn an ERC-721 Capsule from collection _capsule at _id. This will return the amounts of token at addresses tokens which is attached to that Capsule to the sender.

For example - a multi ERC20 Capsule which holds 1 WBTC and 1 WETH returns both tokens to the sender, and burns the Capsule.

Parameters:

  • _capsule: (address) - the address of the Capsule Collection

  • _id: (uint256) - the Capsule token id to burn

Returns: (Nothing)


mintMultiERC721Capsule

Usage: (External) Create an ERC-721 Capsule from collection _capsule which holds multiple ERC-721 tokens at address _tokens (with corresponding _ids) with passed in _uri. _tokens is passed in as an array, of which each token is matched by an amount in the _ids array.

For example - a call should be formatted like so:

  • _capsule: (address) - the address of the Capsule Collection

  • _tokens: [ <token-address-1>, <token-address-2]

  • _ids: [ <token-id-of-token-address-1>, <token-id-of-token-address-2> ]

  • _uri: your URI

To which, two ERC-721 token transfers are required, and one Capsule is returned to the user.

Parameters:

  • _capsule: (address) - the address of the Capsule Collection

  • _tokens: (address[]) - the token addresses to be deposited alongside creation of the Capsule

  • _ids: (uint256[]) - the ids of each ERC-721 token

  • _uri: (string) - the NFT URI (IPFS hashes commonly used)

Returns: (Nothing)


burnMultiERC721Capsule

Usage: (External) Burn an ERC-721 Capsule from collection _capsule at _id. This will return the token at addresses tokens which is attached to that Capsule to the sender.

For example - a multi ERC721 Capsule which holds 1 Rare Pepe and 1 Polkamon returns both tokens to the sender, and burns the Capsule.

Parameters:

  • _capsule: (address) - the address of the Capsule Collection

  • _id: (uint256) - the Capsule token id to burn

Returns: (Nothing)


getMultiERC20CapsuleData

Usage: (External) Get a struct holding:

  • array of addresses

  • array of amounts of a multi-ERC20 Capsule from collection _capsule, at _id.

Parameters:

  • _capsule: (address) - the address of the Capsule Collection

  • _id: (uint256) - the NFT id

Returns: (Struct: {address[], uint256[]}) - the token ids


getMultiERC721CapsuleData

Usage: (External) Get a struct holding:

  • array of addresses

  • array of ids of a multi-ERC721 Capsule from collection _capsule, at _id.

Parameters:

  • _capsule: (address) - the address of the Capsule Collection

  • _id: (uint256) - the NFT id

Returns: (Struct: {address[], uint256[]}) - the token ids


getCapsuleOwner

Usage: (External) Get the owner of a certain Capsule from collection _capsule at _id.

Parameters:

  • _capsule: (address) - the address of the Capsule Collection

  • _id: (uint256) - the Capsule id

Returns: (address) - the owner of the Capsule


Lesser Interesting Methods

addToWhitelist


removeFromWhitelist


getMintWhitelist


isMintWhitelisted


flushTaxAmount


updateCapsuleMintTax


initialize


onERC721Received


_depositToken


Key Events

CapsuleMintTaxUpdated


SimpleCapsuleMinted


SimpleCapsuleBurnt


SingleERC20CapsuleMinted


SingleERC20CapsuleBurnt


SingleERC721CapsuleMinted


SingleERC721CapsuleBurnt


MultiERC20CapsuleMinted


MultiERC20CapsuleBurnt


MultiERC721CapsuleMinted


MultiERC721CapsuleBurnt


Modifiers

checkStatus


onlyValidCapsuleCollections


onlyCollectionMinter


CapsuleMinterStorage

SingleERC20Capsule


MultiERC20Capsule


SingleERC721Capsule


MultiERC721Capsule


factory


capsuleMintTax


isSimpleCapsule


singleERC20Capsule


singleERC721Capsule


multiERC20Capsule


multiERC721Capsule


mintWhitelist

Last updated