# Auction Module CLI Commands

## Build the Chain

The following command builds the Ethermint daemon and places the binary in the `build` directory

```
make build

```

## Setup the Chain

The following steps need to be followed only before running the chain for the first time.

1. Add the root key:
   ```
   ./build/chibaclonkd keys add root
   ```
   Keep a note of the keyring passphrase if you set it.
2. Init the chain:
   ```
   ./build/chibaclonkd init test-moniker --chain-id ethermint_9000-1
   ```
3. Add genesis account:
   ```
   ./build/chibaclonkd add-genesis-account $(./build/chibaclonkd keys show root -a) 1000000000000000000aphoton,1000000000000000000stake
   ```
4. Make a genesis tx:
   ```
   ./build/chibaclonkd gentx root 1000000000000000000stake --chain-id ethermint_9000-1 
   ```
5. Collect gentxs:
   ```
   ./build/chibaclonkd collect-gentxs
   ```

The chain can now be started using:

```
./build/chibaclonkd start
```

## Querying the Params

The following command will dislay the default params for the `auction` module:

```
# ./build/chibaclonkd q auction params -o json | jq

{
  "params": {
    "commits_duration": "0s",
    "reveals_duration": "0s",
    "commit_fee": {
      "denom": "",
      "amount": "0"
    },
    "reveal_fee": {
      "denom": "",
      "amount": "0"
    },
    "minimum_bid": {
      "denom": "",
      "amount": "0"
    }
  }
}
```

## Auction TX CLI Commands

### Create Auction

```
# ./build/chibaclonkd tx auction create 100s 100s 10aphoton 10aphoton 1000aphoton --from root --chain-id $(./build/chibaclonkd status | jq .NodeInfo.network -r)

Enter keyring passphrase:

{"body":{"messages":[{"@type":"/vulcanize.auction.v1beta1.MsgCreateAuction","commits_duration":"100s","reveals_duration":"100s","commit_fee":{"denom":"aphoton","amount":"10"},"reveal_fee":{"denom":"aphoton","amount":"10"},"minimum_bid":{"denom":"aphoton","amount":"1000"},"signer":"ethm1l7cstwtf2lvev27ka67c23yk7mmj8ad7tetpqc"}],"memo":"","timeout_height":"0","extension_options":[],"non_critical_extension_options":[]},"auth_info":{"signer_infos":[],"fee":{"amount":[],"gas_limit":"200000","payer":"","granter":""}},"signatures":[]}

confirm transaction before signing and broadcasting [y/N]: y

code: 0
codespace: ""
data: ""
gas_used: "0"
gas_wanted: "0"
height: "0"
info: ""
logs: []
raw_log: '[]'
timestamp: ""
tx: null
txhash: ECAD6DF1ECA763FBD26EB7C2C0B77425FFE2FBEA2BEC57CE0FBC173AE0F45298
```

### Commit Bid

```
# ./build/chibaclonkd tx auction commit-bid e7d14c7e7a6d7537cbdb8fbe62f22b1553c2ef4ce3705ada7c28f80faf2fbe0d 2000aphoton --from root --chain-id $(./build/chibaclonkd status | jq .NodeInfo.network -r)

Enter keyring passphrase:

{"body":{"messages":[{"@type":"/vulcanize.auction.v1beta1.MsgCommitBid","auction_id":"e7d14c7e7a6d7537cbdb8fbe62f22b1553c2ef4ce3705ada7c28f80faf2fbe0d","commit_hash":"bafyreibt4twofrc3xi2es27cfrroy346iy6lr3gkw33i5dltkqqarlyltm","signer":"ethm1l7cstwtf2lvev27ka67c23yk7mmj8ad7tetpqc"}],"memo":"","timeout_height":"0","extension_options":[],"non_critical_extension_options":[]},"auth_info":{"signer_infos":[],"fee":{"amount":[],"gas_limit":"200000","payer":"","granter":""}},"signatures":[]}

confirm transaction before signing and broadcasting [y/N]: y

code: 0
codespace: ""
data: ""
gas_used: "0"
gas_wanted: "0"
height: "0"
info: ""
logs: []
raw_log: '[]'
timestamp: ""
tx: null
txhash: 71D8CF34026E32A3A34C2C2D4ADF25ABC8D7943A4619761BE27F196603D91B9D
```

### Reveal Bid

```
# ./build/chibaclonkd tx auction reveal-bid e7d14c7e7a6d7537cbdb8fbe62f22b1553c2ef4ce3705ada7c28f80faf2fbe0d root-bafyreibt4twofrc3xi2es27cfrroy346iy6lr3gkw33i5dltkqqarlyltm.json --from root --chain-id $(./build/chibaclonkd status | jq .NodeInfo.network -r)

Enter keyring passphrase:

{"body":{"messages":[{"@type":"/vulcanize.auction.v1beta1.MsgRevealBid","auction_id":"e7d14c7e7a6d7537cbdb8fbe62f22b1553c2ef4ce3705ada7c28f80faf2fbe0d","reveal":" ","signer":"ethm1l7cstwtf2lvev27ka67c23yk7mmj8ad7tetpqc"}],"memo":"","timeout_height":"0","extension_options":[],"non_critical_extension_options":[]},"auth_info":{"signer_infos":[],"fee":{"amount":[],"gas_limit":"200000","payer":"","granter":""}},"signatures":[]}

confirm transaction before signing and broadcasting [y/N]: y

code: 0
codespace: ""
data: ""
gas_used: "0"
gas_wanted: "0"
height: "0"
info: ""
logs: []
raw_log: '[]'
timestamp: ""
tx: null
txhash: 4D1C0B3DDA4050F9BB32240FBD5234229E5C32543C1A0A78033B9531EB0CF8BA
```

## Auction Query CLI Commands

### List Auctions

```
# ./build/chibaclonkd q auction list

auctions:
  auctions:
  - commit_fee:
      amount: "10"
      denom: aphoton
    commits_end_time: "2021-09-30T07:57:07.933412800Z"
    create_time: "2021-09-30T07:55:27.933412800Z"
    id: e7d14c7e7a6d7537cbdb8fbe62f22b1553c2ef4ce3705ada7c28f80faf2fbe0d
    minimum_bid:
      amount: "1000"
      denom: aphoton
    owner_address: ethm1l7cstwtf2lvev27ka67c23yk7mmj8ad7tetpqc
    reveal_fee:
      amount: "10"
      denom: aphoton
    reveals_end_time: "2021-09-30T07:58:47.933412800Z"
    status: commit
    winner_address: ""
    winning_bid:
      amount: "0"
      denom: ""
    winning_price:
      amount: "0"
      denom: ""
pagination: null
```

### Get Bid

```
# ./build/chibaclonkd q auction get-bid e7d14c7e7a6d7537cbdb8fbe62f22b1553c2ef4ce3705ada7c28f80faf2fbe0e ethm1l7cstwtf2lvev27ka67c23yk7mmj8ad7tetpqc

bid:
  auction_id: e7d14c7e7a6d7537cbdb8fbe62f22b1553c2ef4ce3705ada7c28f80faf2fbe0d
  bid_amount:
    amount: "0"
    denom: ""
  bidder_address: ethm1l7cstwtf2lvev27ka67c23yk7mmj8ad7tetpqc
  commit_fee:
    amount: "10"
    denom: aphoton
  commit_hash: bafyreibt4twofrc3xi2es27cfrroy346iy6lr3gkw33i5dltkqqarlyltm
  commit_time: "2021-09-30T08:49:48.358878200Z"
  reveal_fee:
    amount: "10"
    denom: aphoton
  reveal_time: "0001-01-01T00:00:00Z"
  status: commit
```

### Get All Bids for an Auction

```
./build/chibaclonkd q auction get-bids e7d14c7e7a6d7537cbdb8fbe62f22b1553c2ef4ce3705ada7c28f80faf2fbe0d

bids:
- auction_id: e7d14c7e7a6d7537cbdb8fbe62f22b1553c2ef4ce3705ada7c28f80faf2fbe0d
  bid_amount:
    amount: "0"
    denom: ""
  bidder_address: ethm1l7cstwtf2lvev27ka67c23yk7mmj8ad7tetpqc
  commit_fee:
    amount: "10"
    denom: aphoton
  commit_hash: bafyreibt4twofrc3xi2es27cfrroy346iy6lr3gkw33i5dltkqqarlyltm
  commit_time: "2021-09-30T08:49:48.358878200Z"
  reveal_fee:
    amount: "10"
    denom: aphoton
  reveal_time: "0001-01-01T00:00:00Z"
  status: commit
```

### Get Auction by AuctionID

```
# ./build/chibaclonkd q auction get e7d14c7e7a6d7537cbdb8fbe62f22b1553c2ef4ce3705ada7c28f80faf2fbe0d

auction:
  commit_fee:
    amount: "10"
    denom: aphoton
  commits_end_time: "2021-09-30T07:57:07.933412800Z"
  create_time: "2021-09-30T07:55:27.933412800Z"
  id: e7d14c7e7a6d7537cbdb8fbe62f22b1553c2ef4ce3705ada7c28f80faf2fbe0d
  minimum_bid:
    amount: "1000"
    denom: aphoton
  owner_address: ethm1l7cstwtf2lvev27ka67c23yk7mmj8ad7tetpqc
  reveal_fee:
    amount: "10"
    denom: aphoton
  reveals_end_time: "2021-09-30T07:58:47.933412800Z"
  status: commit
  winner_address: ""
  winning_bid:
    amount: "0"
    denom: ""
  winning_price:
    amount: "0"
    denom: ""

```

### Get Auction by Bidder

```
# ./build/chibaclonkd q auction query-by-owner ethm1l7cstwtf2lvev27ka67c23yk7mmj8ad7tetpqc

auctions:
  auctions:
  - commit_fee:
      amount: "10"
      denom: aphoton
    commits_end_time: "2021-09-30T07:57:07.933412800Z"
    create_time: "2021-09-30T07:55:27.933412800Z"
    id: e7d14c7e7a6d7537cbdb8fbe62f22b1553c2ef4ce3705ada7c28f80faf2fbe0d
    minimum_bid:
      amount: "1000"
      denom: aphoton
    owner_address: ethm1l7cstwtf2lvev27ka67c23yk7mmj8ad7tetpqc
    reveal_fee:
      amount: "10"
      denom: aphoton
    reveals_end_time: "2021-09-30T07:58:47.933412800Z"
    status: commit
    winner_address: ""
    winning_bid:
      amount: "0"
      denom: ""
    winning_price:
      amount: "0"
      denom: ""
```

### Query Account Balance

```
# ./build/chibaclonkd q auction balance                                                   

balance:
- amount: "20"
  denom: aphoton
```