Tx

Tx module allows you to sign or broadcast transactions

Available Commands

NameDescription
signSign transactions generated offline
broadcastBroadcast a signed transaction to the network
multisignSign the same transaction by multiple accounts
txQuery for a transaction by hash in a committed block
txsSearch for transactions that match the exact given events where results are paginated

iris tx sign

Sign transactions in generated offline file. The file created with the --generate-only flag.

iris tx sign <file> [flags]

Flags

Name, shorthandTypeRequiredDefaultDescription
--appendbooltruetrueAttach a signature to an existing signature.
--fromstringtrueKey name for signature
--offlinebooltrueOffline mode.
--signature-onlybooltruePrint only the generated signature, then exit
--multisigstringtrueAddress of the multisig account on behalf of which the transaction shall be signed

Generate an offline tx

TIP

You can generate any type of txs offline by appending the flag --generate-only

We use a transfer tx in the following examples:

iris tx bank send iaa1w9lvhwlvkwqvg08q84n2k4nn896u9pqx93velx iaa15uys54epmd2xzhcn32szps56wvev40tt908h62 10iris --chain-id=irishub --generate-only

The unsigned.json should look like:

{
    "type": "cosmos-sdk/StdTx",
    "value": {
        "msg": [
            {
                "type": "cosmos-sdk/MsgSend",
                "value": {
                    "from_address": "iaa1w9lvhwlvkwqvg08q84n2k4nn896u9pqx93velx",
                    "to_address": "iaa15uys54epmd2xzhcn32szps56wvev40tt908h62",
                    "amount": [
                        {
                            "denom": "iris",
                            "amount": "10"
                        }
                    ]
                }
            }
        ],
        "fee": {
            "amount": [],
            "gas": "200000"
        },
        "signatures": null,
        "memo": ""
    }
}

Sign tx offline

iris tx sign unsigned.json --name=<key-name> > signed.tx

The signed.json should look like:

{
    "type": "auth/StdTx",
    "value": {
        "msg": [
            {
                "type": "cosmos-sdk/Send",
                "value": {
                    "inputs": [
                        {
                            "address": "iaa106nhdckyf996q69v3qdxwe6y7408pvyvyxzhxh",
                            "coins": [
                                {
                                    "denom": "uiris",
                                    "amount": "1000000"
                                }
                            ]
                        }
                    ],
                    "outputs": [
                        {
                            "address": "iaa1893x4l2rdshytfzvfpduecpswz7qtpstevr742",
                            "coins": [
                                {
                                    "denom": "uiris",
                                    "amount": "1000000"
                                }
                            ]
                        }
                    ]
                }
            }
        ],
        "fee": {
            "amount": [
                {
                    "denom": "uiris",
                    "amount": "4000000"
                }
            ],
            "gas": "200000"
        },
        "signatures": [
            {
                "pub_key": {
                    "type": "tendermint/PubKeySecp256k1",
                    "value": "Auouudrg0P86v2kq2lykdr97AJYGHyD6BJXAQtjR1gzd"
                },
                "signature": "sJewd6lKjma49rAiGVfdT+V0YYerKNx6ZksdumVCvuItqGm24bEN9msh7IJ12Sil1lYjqQjdAcjVCX/77FKlIQ==",
                "account_number": "0",
                "sequence": "3"
            }
        ],
        "memo": "test"
    }
}

Note the signature in the signed.json should no longer be empty after signing.

Now it's ready to broadcast the signed tx to the IRIS Hub.

iris tx broadcast

This command is used to broadcast an offline signed transaction to the network.

Broadcast offline signed transaction

iris tx broadcast signed.json --chain-id=irishub

iris tx multisign

Sign a transaction by multiple accounts. The tx could be broadcasted only when the number of signatures meets the multisig-threshold.

iris tx multisign <file> <key-name> <[signature]...> [flags]

Generate an offline tx by multisig key

TIP

No multisig key? Create one

iris tx bank send <from> <to> 10iris --fees=0.3iris --chain-id=irishub --from=<multisig-keyname> --generate-only > unsigned.json

Sign the multisig tx

Query the multisig address

iris keys show <multisig-keyname>

Sign the unsigned.json

Assume the multisig-threshold is 2, here we sign the unsigned.json by 2 of the signers

Sign the tx by signer-1:

iris tx sign unsigned.json --from=<signer-keyname-1> --chain-id=irishub --multisig=<multisig-address> --signature-only > signed-1.json

Sign the tx by signer-2:

iris tx sign unsigned.json --from=<signer-keyname-2> --chain-id=irishub --multisig=<multisig-address> --signature-only > signed-2.json

Merge the signatures

Merge all the signatures into signed.json

iris tx multisign --chain-id=irishub unsigned.json <multisig-keyname> signed-1.json signed-2.json > signed.json

Now you can broadcast the signed tx.

iris query tx

iris query tx [hash] [flags]

iris query txs

iris query txs --events 'message.sender=<iaa...>&message.action=xxxx' --page 1 --limit 30

Among the possible values of message.action:

moduleMsgaction
bankcosmos-sdk/MsgSendtransfer
cosmos-sdk/MsgMultiSendtransfer
distributioncosmos-sdk/MsgModifyWithdrawAddressset_withdraw_address
cosmos-sdk/MsgWithdrawValidatorCommissionwithdraw_commission
cosmos-sdk/MsgWithdrawDelegatorRewardwithdraw_rewards
govcosmos-sdk/MsgSubmitProposalsubmit_proposal
cosmos-sdk/MsgDepositproposal_deposit
cosmos-sdk/MsgVoteproposal_vote
stakecosmos-sdk/MsgCreateValidatorcreate_validator
cosmos-sdk/MsgEditValidatoredit_validator
cosmos-sdk/MsgDelegatedelegate
cosmos-sdk/MsgBeginRedelegateredelegate
cosmos-sdk/MsgUndelegateunbond
slashingcosmos-sdk/MsgUnjailunjail
coinswapirismod/MsgSwapOrderswap
irismod/MsgAddLiquidityadd_liquidity
irismod/MsgRemoveLiquidityremove_liquidity
htlcirismod/MsgCreateHTLCcreate_htlc
irismod/MsgClaimHTLCclaim_htlc
irismod/MsgRefundHTLCrefund_htlc
nftirismod/MsgIssueDenomissue_denom
irismod/MsgMintNFTmint_nft
irismod/MsgBurnNFTburn_nft
irismod/MsgTransferNFTtransfer_nft
irismod/MsgEditNFTedit_nft
recordirismod/MsgCreateRecordcreate_record
tokenirismod/MsgIssueTokenissue_token
irismod/MsgEditTokenedit_token
irismod/MsgTransferTokenOwnertransfer_token_owner
irismod/MsgMintTokenmint_token