Skip to main content

Part 5: Deploying the contract

So far you have used the token in the SmartPy test scenario and in the Octez client local sandbox. To test it on a live network, you can use the Shadownet test network.

For more information about testnets, see Testing on sandboxes and testnets.

Configuring the Octez client for Shadownet

Follow these steps to set up your installation of the Octez client to work with Shadownet:

  1. Go to https://teztnets.com/shadownet-about and copy the URL of a public RPC node for Shadownet, such as https://rpc.shadownet.teztnets.com.

  2. Use that URL to configure the Octez client in this command:

    octez-client -E https://rpc.shadownet.teztnets.com config update
  3. If you don't have an account on Shadownet, create or import one with the instructions in Creating accounts.

  4. Use the Shadownet faucet to get some tez for the account.

Setting the admin account in the contract

Currently, the admin account in the contract is an automatically-generated account. Follow these steps to use your account as the admin account instead:

  1. Compile the contract with the python command as you did in previous steps.

  2. Get the address of your account by running this command:

    octez-client list known addresses
  3. Update the step_001_cont_0_storage.tz file and replace the first address listed with your account. This is the field that stores the admin account in the contract storage.

  4. Deploy the contract to Shadownet by passing your account alias, the compiled contract, and initial storage value to the originate contract command. For example, if your account is named my_account and the compiled files are in the fa2_lib_fungible folder, the command looks like this:

    octez-client originate contract smartpy_fa2_fungible \
    transferring 0 from my_account \
    running fa2_lib_fungible/step_001_cont_0_contract.tz \
    --init "$(cat fa2_lib_fungible/step_001_cont_0_storage.tz)" --burn-cap 3 --force
  5. Copy the address of the contract from the output of the command. The contract address starts with KT1.

  6. Look up the contract on the block explorer TzKT.io, making sure to select the Shadownet network.

    Note that the block explorer recognizes that the contract is FA2-compliant and thus shows information about the tokens on the Tokens tab, as in this picture:

    The list of tokens in the block explorer
  7. Mint some tokens and send them to your account:

    1. Find an example parameter for the call to the mint entrypoint. You can either use the log.txt file to find a .tz file that corresponds to a mint transaction or use the block explorer to get an example parameter. For example, this parameter corresponds to the line commented Other users can't mint tokens:

      {Pair "tz1WxrQuZ4CK1MBUa2GqUWK1yJ4J6EtG1Gwi" (Pair (Left 0) 4)}
    2. Put your address in the parameter in place of the test account address.

    3. Run this Octez client command to call the mint entrypoint with that parameter, with your address in the parameter:

      octez-client call smartpy_fa2_fungible from my_account --arg '{Pair "tz1QCVQinE8iVj1H2fckqx6oiM85CNJSK9Sx" (Pair (Left 0) 4)}' --entrypoint 'mint' --burn-cap 1
    4. Wait for the call to complete and be confirmed and then verify that the balance of tokens updated on the block explorer.

Interacting with the token in a wallet

Because the token is FA2-compliant, wallet applications can work with it directly. However, you must add the token contract to your wallet for it to recognize the token. For information about Tezos wallets, see Wallets.

The process for adding a token contract to a wallet depends on the wallet application. Here are steps for the Temple wallet:

  1. Open the Temple wallet and sign in.

  2. Get the address of your account in the wallet. This address is probably different from the address in the Octez client.

  3. Using the Octez client, send a transaction to the contract to mint tokens for your Temple wallet account. For example, if your account in Temple is tz1hQKqRPHmxET8du3fNACGyCG8kZRsXm2zD, the command looks like this:

    octez-client call smartpy_fa2_fungible from my_account --arg '{Pair "tz1hQKqRPHmxET8du3fNACGyCG8kZRsXm2zD" (Pair (Left 0) 4)}' --entrypoint 'mint' --burn-cap 1
  4. Copy the address of the contract. You can use the command octez-client list known contracts to print the addresses of contracts that the Octez client knows about.

  5. Switch the wallet to use the Shadownet testnet instead of Tezos Mainnet. Shadownet is a network for testing Tezos applications where tokens are free so you don't have to spend real currency to work with your applications.

    For example, for the Temple browser wallet:

    1. Expand the menu at top right and then turn on Testnet mode, as in this picture:

      Setting testnet mode in Temple
    2. Above the list of tokens, click the display options button:

      Clicking the button to open display options
    3. Under Filter by network, expand All Networks.

    4. Select Shadownet:

      Selecting Shadownet in the network settings
    5. Click the X button next to the search box to close the display options.

    Now Temple shows your token balances on the Shadownet test network, primarily your tez balance. The wallet does not show your contract's token because it does not show custom tokens by default.

  6. Add your token to the list of tokens that are displayed:

    1. Above the list of tokens, click the filter button:

      Clicking the button to open token filtering options
    2. Click Add custom token.

    3. Make sure that the Shadownet network is selected.

    4. Add the token address and ID, as in this picture:

      Clicking the button to open token filtering options
    5. Click Add.

    Now the token is shown in the list of tokens in the wallet.

  7. Click Add Asset.

Now the token appears in your wallet just like any other token:

The new token in the wallet

From here, you can use the token directly in the wallet, such as sending it to a different account.

Next steps

Now that you have an FA2-compliant token, you can use it with all kinds of Tezos dApps. If you want to continue working with the token, here are some ideas:

  • Implement an exchange rate for the convert entrypoint
  • Implement other custom behaviors for your token while keeping it FA2-compliant
  • Build a front-end application to make it easier to interact with it
  • Add other token types and metadata for them
  • Try creating a single asset contract or an NFT contract with the SmartPy FA2 library