This site requires Javascript to be enabled.

Deploying the token contract

As we saw in the My First dapp guide, deployment on Archway is a multi-step process.

  1. Generate an optimized build
  2. Store the optimized build on chain
  3. Instantiate the NFT collection
  4. Configure the deployed contract

Generate an optimized build

First we will need to produce an optimized wasm build and upload it to the blockchain.

Optimized builds are produced by executing the archway contracts build command:

archway contracts build

Store the optimized build on chain

To store the optimized build on Archway using the Archway CLI, you would use the following command:

archway contracts store CONTRACT [--json] [--log-level debug|error|info|warn] [--instantiate-permission any-of|everybody|nobody] [--allowed-addresses <value>] [--keyring-backend file|os|test] [--keyring-path <value>] [-f <value>] [--fee <value>] [--no-confirm] [--gas-adjustment <value>]

Arguments:

CONTRACT  (required) Name of the contract

If using the archwayd, you can launch:

mainnet

testnet

archwayd tx wasm store artifacts/nft_test.wasm --from my-wallet --node https://rpc.mainnet.archway.io:443 --chain-id archway-1 --gas auto --gas-prices $(archwayd q rewards estimate-fees 1 --node 'https://rpc.mainnet.archway.io:443' --output json | jq -r '.gas_unit_price | (.amount + .denom)') --gas-adjustment 1.3

Instantiate the NFT collection

Now we are ready to instantiate the contract. The contract instantiation requires three parameters:

  • name (the NFT collection name)
  • symbol (a token symbol to represent the collection)
  • minter (the wallet address allowed to mint a new NFT using this contract)

When we run the archway instantiate command, we add our values for name, symbol and minter as arguments.

Using the Archway CLI:

archway contracts instantiate basic-nft --args '{ "name": "Test Collection", "symbol": "NFTEST", "minter": "archway1f395p0gg67mmfd5zcqvpnp9cxnu0hg6r9hfczq" }'

If using archwayd:

mainnet

testnet

archwayd tx wasm instantiate  '{ "name": "Test Collection", "symbol": "NFTEST", "minter": "archway1c23y29x9fcs4zlfv5tvl4nrq56p6gywq0snrxl" }' --from my-wallet --node https://rpc.mainnet.archway.io:443 --chain-id archway-1 --label testdev --admin archway1c23y29x9fcs4zlfv5tvl4nrq56p6gywq0snrxl --gas auto --gas-prices $(archwayd q rewards estimate-fees 1 --node 'https://rpc.mainnet.archway.io:443' --output json | jq -r '.gas_unit_price | (.amount + .denom)') --gas-adjustment 1.3

Once instantiation succeeds, you are able to mint your first token of the collection. Read on to learn more about interacting with this contract.

Configure the deployed contract

Now that the NFT contract is deployed it's recommended to set its metadata. This will configure the smart contract to collect developer premiums, rewards and can be used to enable gas rebates with a pooling account.

To set contract metadata, use the command:

archway contracts metadata CONTRACT [--json] [--log-level debug|error|info|warn] [--owner-address <value>] [--rewards-address <value>][--keyring-backend file|os|test] [--keyring-path <value>] [-f <value>] [--fee <value>] [--no-confirm] [--gas-adjustment <value>]

A basic example would be:

archway contracts metadata basic-nft --owner-address "archway12qj4v8jg5pxk6gsqct09sf9szhwql69xmf9fh4"  --rewards-address="archway12qj4v8jg5pxk6gsqct09sf9szhwql69xmf9fh4"

Arguments:

CONTRACT (required) Name of the contract

Set contract premiums

To set a contract premium the contract must have the rewards metadata already configured. You would use the following command to set the premium:

archway contracts premium CONTRACT --premium-fee <value> [--json] [--log-level debug|error|info|warn] [--keyring-backend file|os|test] [--keyring-path <value>] [-f <value>] [--fee <value>] [--no-confirm] [--gas-adjustment <value>]

A basic example would be:

archway contracts premium increment2 --premium-fee "1000000000000000000aconst" --from "mywallet" 

Arguments:

CONTRACT (required) Name of the contract