FA2 Contract
Archetype multi-asset FA2 contract
Last updated
Archetype multi-asset FA2 contract
Last updated
The archetype-lang developers published some . The one we're interested in is the FA2 multi-asset contract, that can be found on their .
We'll use the base that we'll adjust according to our needs.
Go to the .
Create a new contracts folder within the tzombies folder and add a copy of permits.arl
and fa2_multi.arl
The main logic is in fa2_multi
, whereas the permits
contract implements special features for the NFT (such as transfer with a permit, that allows the owner to sign a message to allow another account or contract to transfer its NFT).
We will make the following changes to the FA2 template to suit our project:
Rename the contract
Remove token metadata initialisation
Remove permits update
Customise the mint function
The first line is the contract declaration, we'll rename it to fit our project:
We keep the rest of the declaration defines the parameters required for contract initialization. We can see here that a contract owner, and an address for a permits contract must be given at deployment.
Completium-cli requires the file name to match the contract name. Rename fa2_multi.arl
to tzombies.arl
The template comes with a default token metadata for a token with id 0. Let's remove that. Look for section TOKEN METADATA and remove the constants and the initialized by arguments. It should now look like this:
In the default template, the contract owner has the ability to change the permits contract associated. Even though that's a practical solution if the permits contract needs to be updated or fixed, it creates a hazard risk, as the owner could perform a malicious change.
We'll customise the mint
function that comes with the template.
In the effect
section, we'll transfer the sale product for the payable token to the contract owner.
with metadata
is an optional key for defining contract metadata. Contract metadata is used to identify the contract on block explorers and wallets, (not to be confused with token metadata). Here, we leave it out with ""
but the whole key can be removed. Detailed information on contract metadata can be found in the .
We'd like to have an "open mint" NFT, where anyone can mint. Also, all mints are free, except for token id 1 that will cost 2 ꜩ. See the chapter.