Place multiple orders in one transaction

I couldn't understand the syntax of the command seid tx dex place-orders sei14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9sh9m79m -h , so I went the other way.

  1. Creating a Tx Body.

Necessarily replace the value of : creator = "your address" , account = "your address"

Optional : price = "specify your price" , quantity = "specify your quantity", orderType ="LIMIT or MARKET", positionDirection = " LONG or SHORT" ...... etc

example with my address

echo '{
  "body": {
    "messages": [
      {
        "@type": "/seiprotocol.seichain.dex.MsgPlaceOrders",
        "creator": "sei1g65zdfxyu3h79pq8ggjdrhs3wcspk483m7ylm6",
        "orders": [
          {
            "id": "0",
            "status": "PLACED",
            "account": "sei1g65zdfxyu3h79pq8ggjdrhs3wcspk483m7ylm6",
            "contractAddr": "sei1466nf3zuxpya8q9emxukd7vftaf6h4psr0a07srl5zw74zh84yjqpeheyc",
            "price": "1.000000000000000000",
            "quantity": "0.000010000000000000",
            "priceDenom": "UST2",
            "assetDenom": "ATOM",
            "orderType": "LIMIT",
            "positionDirection": "LONG",
            "data": "{\"position_effect\":\"Open\",\"leverage\":\"1\"}",
            "statusDescription": ""
          }
        ],
        "contractAddr": "sei1466nf3zuxpya8q9emxukd7vftaf6h4psr0a07srl5zw74zh84yjqpeheyc",
        "funds": [
          {
            "denom": "uusdc",
            "amount": "10"
          }
        ]
      },
      {
        "@type": "/seiprotocol.seichain.dex.MsgPlaceOrders",
        "creator": "sei1g65zdfxyu3h79pq8ggjdrhs3wcspk483m7ylm6",
        "orders": [
          {
            "id": "0",
            "status": "PLACED",
            "account": "sei1g65zdfxyu3h79pq8ggjdrhs3wcspk483m7ylm6",
            "contractAddr": "sei1466nf3zuxpya8q9emxukd7vftaf6h4psr0a07srl5zw74zh84yjqpeheyc",
            "price": "1.000000000000000000",
            "quantity": "0.000010000000000000",
            "priceDenom": "UST2",
            "assetDenom": "ATOM",
            "orderType": "LIMIT",
            "positionDirection": "LONG",
            "data": "{\"position_effect\":\"Open\",\"leverage\":\"1\"}",
            "statusDescription": ""
          }
        ],
        "contractAddr": "sei1466nf3zuxpya8q9emxukd7vftaf6h4psr0a07srl5zw74zh84yjqpeheyc",
        "funds": [
          {
            "denom": "uusdc",
            "amount": "10"
          }
        ]
      }
    ],
    "memo": "",
    "timeout_height": "0",
    "extension_options": [],
    "non_critical_extension_options": []
  },
  "auth_info": {
    "signer_infos": [],
    "fee": {
      "amount": [
        {
          "denom": "usei",
          "amount": "0"
        }
      ],
      "gas_limit": "0",
      "payer": "",
      "granter": ""
    }
  },
  "signatures": []
}' > $HOME/gen_tx.json

2. Signing the Tx.

You need to find out your account number. ADDR="your address"

ACC=$(seid q account $ADDR -o json | jq -r .account_number)

If necessary, you can use a public node https://sei-testnet-rpc.brocha.in:443. ( The node is supported Quadrillion#1364 || Quadrillion | Brochain, many thanks to him ) Then you need to use an additional flag.

ACC=$(seid q account $ADDR -o json --node https://sei-testnet-rpc.brocha.in:443 | jq -r .account_number)

You also have specify the sequence value.

seq=$(seid q account $ADDR -o json | jq -r .sequence)

If necessary, you can use a public node. Then you need to use an additional flag.

seq=$(seid q account $ADDR -o json --node https://sei-testnet-rpc.brocha.in:443 | jq -r .sequence)

Sign the Tx offline (enter a password if necessary). Don't forget to specify your wallet

seid tx sign $HOME/gen_tx.json -s $seq -a $ACC --offline \
--from $wallet --chain-id atlantic-1 \
--output-document $HOME/txs.json

3. Tx Broadcast.

seid tx broadcast $HOME/txs.json

If necessary, you can use a public node. Then you need to use an additional flag.

seid tx broadcast --node https://sei-testnet-rpc.brocha.in:443 $HOME/txs.json 

If successful, you will get code = 0

code: 0
codespace: ""
data: ""
events: []
gas_used: "0"
gas_wanted: "0"
height: "0"
info: ""
logs: []
raw_log: '[]'
timestamp: ""
tx: null
txhash: 5BA641A155C054BB51A709AA09D703FF98FBEBF214415A186788B78B048DC29C

Decoding typical errors

  1. incorrect account sequence. ( code 32 )

code: 32
codespace: sdk
data: ""
events: []
gas_used: "0"
gas_wanted: "0"
height: "0"
info: ""
logs: []
raw_log: 'account sequence mismatch, expected 7088, got 1: incorrect account sequence'
timestamp: ""
tx: null
txhash: C6669800E12B5B56577CE20B0C3B04129890C39BD02A15CCB5FF68A11FA6860A

During step two, you specified an incorrect sequence value. Re-sign the Tx template with the correct sequence value

2. tx already in mempool ( code 19 )

code: 19
codespace: sdk
data: ""
events: []
gas_used: "0"
gas_wanted: "0"
height: "0"
info: ""
logs: []
raw_log: ""
timestamp: ""
tx: null
txhash: 17ADEA161EA6F4FF84DC6DC498AF8E63FF6E6446AE58B04AEEDAFF8AB7951078

You have already sent this Tx to mempool

Update the sequence values, sign the Tx and broadcast it

seq=$(seid q account $ADDR -o json | jq -r .sequence)
seid tx sign $HOME/gen_tx.json -s $seq -a $ACC --offline \
--from $wallet --chain-id atlantic-1 \
--output-document $HOME/txs.json
seid tx broadcast $HOME/txs.json

3. signature verification failed ( code 4 )

code: 4
codespace: sdk
data: ""
events: []
gas_used: "0"
gas_wanted: "0"
height: "0"
info: ""
logs: []
raw_log: 'signature verification failed; please verify account number (54) and chain-id
  (atlantic-1): unauthorized'
timestamp: ""
tx: null
txhash: 3C849F2B7978E2FABE6DC43682C9AFA1990ED4F2CCB79F2E1925DDC549190402

In the second step, when signing the Tx template, you entered your account number incorrectly

4. Error related to insufficient fee ( code 13 )

code: 13
codespace: sdk
data: ""
events: []
gas_used: "0"
gas_wanted: "0"
height: "0"
info: ""
logs: []
raw_log: 'insufficient fees; got:  required: 400000tkyve: insufficient fee'
timestamp: ""
tx: null
txhash: 74AE9EEF116B28621BFB81B195A6F6CE4F6584DC60CD5CDFBBA731FD7135600A

At the first step in the Tx template, change the fee value ( "amount": "200" for example )

    "fee": {
      "amount": [
        {
          "denom": "usei",
          "amount": "0"
        }

Last updated