Nibiru Incentivized Testnet #2

( The task related to voting is simple, you already know how to do it )

Smart Contract Tasks

  • Deploy a smart contract on Nibiru.

  • Instantiate a smart contract on Nibiru.

  • Successfully broadcast an ExecuteContract transaction

The example uses a simple contract cw20_base.wasm ( We will create some new tokens and send them to each other ). You can learn more about cw20 tokens here.

  1. Deploy a smart contract on Nibiru

Cloning a repo

git clone https://github.com/NibiruChain/cw-nibiru

Uploading the contract to the network ( don't forget to specify your wallet !!!! )

nibid tx wasm store $HOME/cw-nibiru/artifacts-cw-plus/cw20_base.wasm --from $wallet  \
--gas-adjustment 1.2 --gas auto  --fees 80000unibi  -y 

Then request this transaction using the tx hash to find out the code_id of the downloaded contract

nibid q tx $txhash -o json |  jq -r '.raw_log'
[
  {
    "events": [
      {
        "type": "message",
        "attributes": [
          {
            "key": "action",
            "value": "/cosmwasm.wasm.v1.MsgStoreCode"
          },
          {
            "key": "module",
            "value": "wasm"
          },
          {
            "key": "sender",
            "value": "nibi12ga83xfqcsgchz5e0ukf5zwhlk3magx0v586ew"
          }
        ]
      },
      {
        "type": "store_code",
        "attributes": [
          {
            "key": "code_checksum",
            "value": "1525a17a5b98438a26b019ffa184b2a355d225485fcfc87ccbcd524d4a24be18"
          },
          {
            "key": "code_id",
            "value": "389"
          }
        ]
      }
    ]
  }
]

Let's create a variable for convenience. The example shows the id of my contract, in your case there will be a different value.

id=389
  1. Instantiate the contract

Before creating an instance of the contract, we will prepare arguments. Replace the following values with your own data - name, symbol, address, minter !!!!!

INIT='{"name":"test","symbol":"test","decimals":6,"initial_balances":[{"address":"nibi12ga83xfqcsgchz5e0ukf5zwhlk3magx0v586ew","amount":"2000000"}],"mint":{"minter":"nibi12ga83xfqcsgchz5e0ukf5zwhlk3magx0v586ew"},"marketing":{}}'

Then perform the transaction . You can change the --label value to your own. ( don't forget to specify your wallet !!!! )

nibid tx wasm instantiate $id $INIT --from $wallet --label "my cw20_base" \
--gas-adjustment 1.2 --gas auto  --fees 73794unibi --no-admin -y

Let's set a variable with the address of your contract

CONTRACT=$(nibid query wasm list-contract-by-code $id --output json | jq -r '.contracts[-1]')
  1. Successfully broadcast an ExecuteContract transaction.

Let's work with the contract and send some of our cw20 tokens to a friend.

Specify the address where you want to send the tokens and their number.

TRANSFER='{"transfer":{"recipient":"nibi1nu47ka8znfs6juvxq52hxma8q9zha45qgl04c6","amount":"50"}}'

Execute Tx ( don't forget to specify your wallet !!!! )

nibid tx wasm execute $CONTRACT $TRANSFER --gas-adjustment 1.2 \
--gas auto --fees 4000unibi --from $wallet -y

Then confirm that the balance transfer was successful. To do this, we will make a small query

Specify the address where we check the balance of cw20 tokens

BALANCE_QUERY='{"balance": {"address": "nibi1nu47ka8znfs6juvxq52hxma8q9zha45qgl04c6"}}'
nibid query wasm contract-state smart $CONTRACT "$BALANCE_QUERY" --output json

Last updated