Deploying and testing
How to deploy and test our FA2 contract.
Deployment
Now that we have the contract code ready, let's deploy it in our sandbox.
All contracts on the the Tezos blockchain are deployed in the Michelson. Our Archetype contract needs to be compiled to Michelson and then be deployed to the network. completium-cli
can do both Michelson generation and deployment.
Michelson code can also be deployed with octez-client, and using scripts with Taquito, Completium, and others. We'll first see how to deploy with completium-cli
to easily validate our contract, and in the next sections, we'll use a more advanced deployment and test setup.
Make sure you are on a sandbox
endpoint, and run the deploy
command. We'll need to deploy the permits contract first, it takes the owner as a parameter (we'll use the alice account)
You will see the origination output, and find the originated contract address in something like this:
This means that our permits contract has the address KT1EYVjiiX2HSjqqgqEryqjCCeTpC7rKRMFo
.
Let's use this to deploy our tzombies fa2 contract (make sure to replace the permits address with the one you deployed):
You will get the origination output similar to this:
Now we have KT1CPHS16kLFHFi5AXNhoYjD67nwsEFr6h7o
as our tzombies fa2 contract.
Testing
We can keep using the command line to register tokens and test some minting.
The FA2 contract has a set_token_metadata
entrypoint. This adds metadata to a given token id. We consider it's like "registering" a token on our contract. We can call our entrypoint with the following command (we'll get into the meaning of these parameters later).
The call
function on completium-cli is used to send a transaction that calls an entrypoint on our contract. Here we registered token id (tid
) 1, with some metadata.
The command outputs an operation hash (Operation injected: o...
), this is the unique identifier of your transaction. It allows you to check the receipt, see if has been applied correctly to the chain, and even see the state changes that happened. For this, we'll use octez-client
(replace the URL with your sandbox RPC URL)
We can now test the mint entrypoint:
As you can see, the call is pretty straightforward. tid
is the token id we just declared, tow
is the recipient address (here Alice again) and nbt
is the amount of tokens we want to mint. Note that since it's token id 1, we need to send 2ęŠ with the transaction, with the parameter --amount
.
We will cover a more efficient way of deploying and testing our contracts in the Better Testing section.
Last updated