Developer - Mint a Capsule NFT
Users have the option to store tokens within a Capsule NFT at the time of mint and embed the Capsule NFT with artwork. At current date, the tokens stored within Capsule NFTs can be ERC-20 tokens, ERC-721 tokens (including Capsule NFTs), or ERC-1155 tokens. You are also able to create Simple Capsule NFTs, which hold no tokens and function as basic ERC-721 NFTs. All Capsule NFTs are minted from Capsule Collections, which you can learn about in Developer - Create a Capsule Collection.
Below are some examples of creating your own Capsule NFT using a pre-existing Capsule Collection.
In order to create a Capsule NFT you must:
- 1.Select a Capsule Collection from which it will be minted (this could be your Capsule Collection, or anyone else's public Capsule Collection)
- 2.Decide which type of Capsule NFT you'd like to create
- Simple Capsule NFT (a basic ERC-721 Token)
- ERC-20 Capsule NFT (a Capsule NFT which holds any number of ERC-20 tokens)
- Depending on the amount of different tokens stored within the ERC-20 Capsule NFT, you will need to decide between methods
mintSingleERC20Capsule
(storing one token) andmintMultiERC20Capsule
(storing two or more tokens)
- ERC-721 Capsule NFT (a Capsule NFT which holds any number of ERC-721 tokens)
- Depending on the amount of different NFTs stored within the ERC-721 Capsule NFT, you will need to decide between methods
mintSingleERC721Capsule
(storing one NFT) andmintMultiERC721Capsule
(storing two or more NFTs)
- ERC-1155 Capsule NFT (a Capsule NFT which holds any number of ERC-1155 tokens)
- Only
mintMultiERC1155Capsule
is available to users and can still be used to store a single ERC-1155 token.
- 3.(if not a Simple Capsule NFT) - supply the Capsule NFT with the token(s) to store
You'll need the address of the Capsule Collection you'd like to mint the Capsule NFT from. This can be found on the CapsuleNFT Application Collections Tab, by obtaining a response from the Create a Capsule Collection method (upon creation), or by calling
getCapsuleCollectionsOf
and passing in an address as a parameter. This Capsule Collection address will be in the form of 0x...
.More information on the methods below can be found at the CapsuleMinter.sol page. Depending on the type of Capsule NFT you are creating, you will call either:
function mintSimpleCapsule(address _capsule, string _uri, address _receiver) external payable
function mintSingleERC20Capsule(address _capsule, address _token, uint256 _amount, string _uri, address _receiver) external payable
function mintMultiERC20Capsule(address _capsule, address[] _tokens, uint256[] _amounts, string _uri, address _receiver) external payable
function mintSingleERC721Capsule(address _capsule, address _token, uint256 _id, string _uri, address _receiver) external payable
function mintMultiERC721Capsule(address _capsule, address[] _tokens, uint256[] _ids, string _uri, address _receiver) external payable
Only
mintMultiERC1155Capsule
is available to the user. Note: you can still create ERC-1155 Capsule NFTs that store a single token using this method.function mintMultiERC1155Capsule(address _capsule, address[] _tokens, uint256[] _ids, string _uri, address _receiver) external payable
An example call to create a Simple Capsule NFT is shown here:
mintSimpleCapsule(
"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", // Capsule Collection address
"ipfs://bafyreibfmk7yeraghmiw5eygdjzjhgc2pqyh5ycyg5d2tm2lg5c2bop2by/metadata.json", // tokenURI/link to Metadata
"0xB58992cfA9B39A2FFA0dd286248503A2eFbc65Db", // address to receive minted Capsule NFT
{ value: 0.001 }
);
This call will create a Simple Capsule NFT:
- In the Capsule Collection at address
0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
- With
tokenURI
(metadata) linking toipfs://bafy...p2by/metadata.json
- And send that Simple Capsule NFT to the address
0xB58992cfA9B39A2FFA0dd286248503A2eFbc65Db
Note that two different methods,
mintSingleERC20Capsule
and mintMultiERC20Capsule
are available to the user.mintSingleERC20Capsule
is an optimized function meant to save the user gas in the case where only a single ERC-20 token would be embedded within a Capsule NFT. mintMultiERC20Capsule
is a function meant to be called when more than one different token is meant to be embedded within a Capsule NFT. Note: you can create ERC-20 Capsule NFTs that store one token using the mintMultiERC20Capsule
method, but it would be gas inefficient to do so.An example call to create a Single ERC-20 Capsule NFT is shown here:
mintSingleERC20Capsule(
"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", // Capsule Collection address
"0x1b40183EFB4Dd766f11bDa7A7c3AD8982e998421", // Token address
200000000000000000000, // Token amount
"ipfs://bafyreibfmk7yeraghmiw5eygdjzjhgc2pqyh5ycyg5d2tm2lg5c2bop2by/metadata.json", // tokenURI/link to Metadata
"0xB58992cfA9B39A2FFA0dd286248503A2eFbc65Db", // address to receive minted Capsule NFT
{ value: 0.001 }
);
This call will create a Single ERC-20 Capsule NFT:
- In the Capsule Collection at address
0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
- Storing
200
of the token at0x1b40183EFB4Dd766f11bDa7A7c3AD8982e998421
- (Assuming 18 decimals)
- With
tokenURI
(metadata) linking toipfs://bafy...p2by/metadata.json
- And send that Single ERC-20 Capsule NFT to the address
0xB58992cfA9B39A2FFA0dd286248503A2eFbc65Db
An example call to create a Multi ERC-20 Capsule NFT is shown here:
mintMultiERC20Capsule(
"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", // Capsule Collection address
[
"0x1b40183EFB4Dd766f11bDa7A7c3AD8982e998421",
"0xa3d58c4E56fedCae3a7c43A725aeE9A71F0ece4e"
], // Token addresses in an array
[
200000000000000000000,
100000000000000000000
], // Token amounts in an array
"ipfs://bafyreibfmk7yeraghmiw5eygdjzjhgc2pqyh5ycyg5d2tm2lg5c2bop2by/metadata.json", // tokenURI/link to Metadata
"0xB58992cfA9B39A2FFA0dd286248503A2eFbc65Db", // address to receive minted Capsule NFT
{ value: 0.001 }
);
This call will create a Multi ERC-20 Capsule NFT:
- In the Capsule Collection at address
0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
- Storing both:
200
of the token at0x1b40183EFB4Dd766f11bDa7A7c3AD8982e998421
- (Assuming 18 decimals)
100
of the token at0xa3d58c4E56fedCae3a7c43A725aeE9A71F0ece4e
- (Assuming 18 decimals)
- With
tokenURI
(metadata) linking toipfs://bafy...p2by/metadata.json
- And send that Multi ERC-20 Capsule NFT to the address
0xB58992cfA9B39A2FFA0dd286248503A2eFbc65Db
Note that two different methods,
mintSingleERC721Capsule
and mintMultiERC721Capsule
are available to the user.mintSingleERC721Capsule
is an optimized function meant to save the user gas in the case where only a single ERC-721 token would be embedded within a Capsule NFT. mintMultiERC721Capsule
is a function meant to be called when more than one different token is meant to be embedded within a Capsule NFT. Note: you can create ERC-721 Capsule NFTs that store one token using the mintMultiERC721Capsule
method, but it would be gas inefficient to do so.An example call to create a Single ERC-721 Capsule NFT is shown here:
mintSingleERC721Capsule(
"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", // Capsule Collection address
"0x1a0a69a267b3e72d22dEB970b2Cc6296aC31A80c", // NFT address
1, // NFT ID
"ipfs://bafyreibfmk7yeraghmiw5eygdjzjhgc2pqyh5ycyg5d2tm2lg5c2bop2by/metadata.json", // tokenURI/link to Metadata
"0xB58992cfA9B39A2FFA0dd286248503A2eFbc65Db", // address to receive minted Capsule NFT
{ value: 0.001 }
);
This call will create a Single ERC-721 Capsule NFT:
- In the Capsule Collection at address
0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
- Storing the NFT of ID
1
from0x1a0a69a267b3e72d22dEB970b2Cc6296aC31A80c
- With
tokenURI
(metadata) linking toipfs://bafy...p2by/metadata.json
- And send that Single ERC-721 Capsule NFT to the address
0xB58992cfA9B39A2FFA0dd286248503A2eFbc65Db
An example call to create a Multi ERC-721 Capsule NFT is shown here:
mintMultiERC721Capsule(
"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", // Capsule Collection address
[
"0x1a0a69a267b3e72d22dEB970b2Cc6296aC31A80c",
"0xECE3053E1e7C4Dd365975e8AB4Db7D1b238e30B6"
], // NFT addresses in an array
[
1,
15
], // NFT IDs in an array
"ipfs://bafyreibfmk7yeraghmiw5eygdjzjhgc2pqyh5ycyg5d2tm2lg5c2bop2by/metadata.json", // tokenURI/link to Metadata
"0xB58992cfA9B39A2FFA0dd286248503A2eFbc65Db", // address to receive minted Capsule NFT
{ value: 0.001 }
);
This call will create a Multi ERC-721 Capsule NFT:
- In the Capsule Collection at address
0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
- Storing both:
- The NFT of ID
1
from0x1a0a69a267b3e72d22dEB970b2Cc6296aC31A80c
- The NFT of ID
15
from0xECE3053E1e7C4Dd365975e8AB4Db7D1b238e30B6
- With
tokenURI
(metadata) linking toipfs://bafy...p2by/metadata.json
- And send that Multi ERC-721 Capsule NFT to the address
0xB58992cfA9B39A2FFA0dd286248503A2eFbc65Db
For ERC-1155 tokens, only
mintMultiERC1155Capsule
is available to the user.mintMultiERC1155Capsule
is a function meant to be called when more than one different token is meant to be embedded within a Capsule NFT. Note: you can still create ERC-1155 Capsule NFTs that store a single token using the mintMultiERC1155Capsule
method.An example call to create a Multi ERC-1155 Capsule NFT is shown here:
mintMultiERC1155Capsule(
"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", // Capsule Collection address
[
"0xe8aE4BfD7521d26283bc14f2395675144AA65e6d",
"0xd07dc4262BCDbf85190C01c996b4C06a461d2430"
], // ERC-1155 NFT addresses in an array
[
1,
15
], // ERC-1155 NFT IDs in an array
[
2,
1
], // ERC-1155 Token amounts in an array
"ipfs://bafyreibfmk7yeraghmiw5eygdjzjhgc2pqyh5ycyg5d2tm2lg5c2bop2by/metadata.json", // tokenURI/link to Metadata
"0xB58992cfA9B39A2FFA0dd286248503A2eFbc65Db", // address to receive minted Capsule NFT
{ value: 0.001 }
);
This call will create a Multi ERC-1155 Capsule NFT:
- In the Capsule Collection at address
0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
- Storing both:
- The NFT of ID
1
from0xe8aE4BfD7521d26283bc14f2395675144AA65e6d
- of which we will store
2
tokens
- The NFT of ID
15
from0xd07dc4262BCDbf85190C01c996b4C06a461d2430
- of which we will store
1
token
- With
tokenURI
(metadata) linking toipfs://bafy...p2by/metadata.json
- And send that Multi ERC-1155 Capsule NFT to the address
0xB58992cfA9B39A2FFA0dd286248503A2eFbc65Db
Last modified 8mo ago