Skip to main content

Deploy contract

In order to deploy a contract on AURA network, make sure that you have done following requirements:

Setting up Environmentโ€‹

You need an environment to run contracts. You can either run your node locally or connect to an existing network. For easy testing, the Euphoria and Serenity testnet is live. You can use the testnets to deploy and run your contract.

The information of RPC Testnet can be retrieved at here.

To verify that the testnet is currently active, make sure the following URLs are working for you:

The testnets have two native tokens set up - aura for Serenity testnet and eaura for Euphoria testnet.

Available Block Explorers:

You can use the block explorer to explore transactions, addresses, validators and contracts.

Setting up aurad CLIโ€‹

Let's configure the aurad executable, point it to the testnet, create a wallet and ask for tokens from faucet:

First source the network configuration for the Serenity testnet in the shell:

export RPC='https://rpc.serenity.aura.network'
export CHAIN_ID='serenity-testnet-001'
export NODE="--node \"$RPC\""
export TXFLAG="${NODE} --chain-id \"${CHAIN_ID}\" --gas-prices 0.025uaura --gas auto --gas-adjustment 1.3"

Set up wallet addresses:

aurad keys add wallet

Running the command above will add two encrypted private keys to the wasmd keyring and display their attributes as follows:

- name: wallet
type: local
address: aura1rh2hwghpazmw4vwr57u38ahk7a2xhjc6z9h7kt
pubkey: '{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"AwnTb8Az+JddriHmcXx5VDY0RpcUAzMf/gCRVjWUB9HM"}'
mnemonic: ""


**Important** write this mnemonic phrase in a safe place.
It is the only way to recover your account if you ever forget your password.

easy news coast scare already verb tongue throw mushroom strong scare seek magic useless maid erupt office stick sound noble machine weekend teach action

You must save the mnemonic for identification on the dapp later!

Ask for tokenโ€‹

To deploy and execute contract, you need to have some AURA token on tesnet. Please follow the guide to ask for tokens at serenity-testnet discord channel.

Deploy contractโ€‹

Moving to the contract directory and compile the wasm contract with stable toolchain:

# compile the wasm contract with stable toolchain
rustup default stable
RUSTFLAGS='-C link-arg=-s' cargo wasm

Deploy contract:

# store contract
RES=$(aurad tx wasm store ../../target/wasm32-unknown-unknown/release/cw721_base.wasm --from wallet $TXFLAG --output json)
# get the code id
CODE_ID=$(echo $RES | jq -r '.logs[0].events[-1].attributes[0].value')

In case the CLI store doesn't return fully tx_result, but only returns results with txhash, we will have to get the code_id by querying from RPC:

CODE_ID=$(curl "https://rpc.serenity.aura.network/tx?hash=0x{txhash}"| jq -r ".result.tx_result.log"|jq -r ".[0].events[-1].attributes[0].value")

Please replace the txhash above with the txhash returned in the RES.

# set variable
INIT='{"minter":"{minter_address}","name":"Aura NFT","symbol":"ANFT"}'

In {minter_address} above is the address value of the minter obtained when creating the wallet, in that case value will be aura1rh2hwghpazmw4vwr57u38ahk7a2xhjc6z9h7kt

# instantiate contract
aurad tx wasm instantiate $CODE_ID "$INIT" --from wallet --label "cw721" $TXFLAG -y --no-admin