Skip to main content

tx

Usage: chr tx [<options>] <opname> [<args>]...

Make a transaction towards a node.

Supports both specifying the target node using url and brid/id or from a
deployment which is specified in the chromia.yml This will post the
transaction asynchronously unless --await is specified, in which it will wait
until transaction has been included in a block.

FT4 compatibility: To make a transaction towards a dapp that uses
ft-authentication, use the --ft-auth flag. This only works if the signer
keypair is connected to a ft-account with the correct authentication rules.
Use --ft-account-id to explicitly state which account to use if keypair is
connected to more than one account. Node: This does not work with
evm-authentication

ICCF: To verify a transaction using ICCF, specify the tx-rid to verify using
--iccf-tx and which chain id the transaction was processed. The command will
both construct and insert a iccf_proof operation prior to the user operation
but will also add the the transaction as a gtx_transaction as first argument
to the user operation.

Examples:
╭───────────────────────────────────────────────────────────────────────╮
│# operation primitive_args(arg1: integer, arg2: name, arg3: text, arg4:│
│byte_array, arg5: my_enum) │
│chr tx primitive_args 123 Alice "My Neighbor" 'x"AB12"' 0 │
│# operation dict_arg(arg: map<text, integer>) │
│chr tx dict_arg '["key": 12]' │
│# operation map_arg(arg: map<my_enum, text>) │
│chr tx map_arg '[[0, "first"],[1, "second"]]' │
│# operation struct_arg(arg: my_struct) │
│chr tx struct_arg '[12, "structs are arrays", x"AB"]' │
╰───────────────────────────────────────────────────────────────────────╯

Configuration Properties:
-cfg, --config=<config> Alternate path for client configuration file
-s, --settings=<settings> Alternate path for project settings file

Key pair source:
--secret=<path> Path to secret file (pubkey/privkey)
--key-id=<key_id> Key ID of the keypair to use

dApp target options:
-brid, --blockchain-rid=<text> Target Blockchain RID
--cid=<int> Target Blockchain IID
--api-url=<text> Target api url
--mainnet, --testnet Select network, use instead of --api-url

Deployment:

Use a configured deployment network target in chromia.yml

-d, --network=<text> Specify which deployment target to use
-bc, --blockchain=<text> Name of blockchain in deployment configuration

FT compatible dapps options:
--ft-auth Adds ft4.ft_auth operation for FT-compatible dapps
--ft-account-id=<text> Explicitly specify which account to use
--evm-auth=<address> Adds ft4.evm_auth operation for FT-compatible dapps
--ft-register-account Adds ft4.register_account operation. To be used in
combination with an account creation strategy.

ICCF options:
--iccf-tx=<text> Constructs a ICCF-proof for this tx-rid and
inserts iccf_proof operation to the transaction.
This will also add the tx as a gtx_transaction as
argument to the operation
--iccf-source=<value> Blockchain RID for the chain which the tx to be
proven has taken place
--source-api-url=<text> Source api url (default target api url)
--iccf-force-intra-network Force usage of intra-network ICCF proof
--iccf-arg-pos=<int> Which argument position to insert the
gtx_transaction in the operation

Options:
-a, --await / --no-await Wait for transaction to be included in a block
-nop Adds a nop to the transaction
--timeb-at=<value> Add timeb operation to make transaction fail if
applied after the given time (UTC). Supported
formats: yyyy-MM-dd HH:mm, yyyy-MM-dd'T'HH:mm and
milliseconds since 1970 (unix/epoch time)
--timeb-after=<value> Add timeb operation to make transaction fail if
applied after the given number of seconds from now.
-h, --help Show this message and exit

Arguments:
<opname> Name of the operation to execute.
<args> Types and their format as arguments to pass to the operation.
(integer: 123) (big_integer: 1234L) (decimal: "1.2") (text: foo,
"bar") (byte_array: 'x"<myByteArray>"') (list: '["foo",123]')
(map<text, ...>: '["text_key":value1,"text_key2":value2]')
(map<non_text_key_type, ...>: '[[non_text_key, value1],
[non_text_key, value2]]') (struct: '["foo"]')

You can use the tx (transaction) command (chr tx) in the same way as the query command, but you need to sign it with your key pair. It can interact with either a local (Node) or deployed chain without the use of a client.

You can set a path for the project settings file (chromia.yml) or specify a different file using --settings.

For deployed chains, you can use the same transaction commands as in a local environment, but you need to target the chain explicitly.

You can do this by either:

  • Using a configured deployment target in your chromia.yml together with --network and --blockchain options, or
  • Specifying --api-url or --mainnet/--testnet together with the BRID of the dApp you want to interact with.

Local Node

You can see the Blockchain RID of the local node in the sout. An example would look like the following: Blockchain RID: FC17B67D66F6F35A5D8B75ED3F83AE222FB8C8FCA241624F06285150F10C6BAC If you are running the node on a different URL than the default http://localhost:7740, you can use the --api-url option to specify it.

  • Perform a transaction with the operation set_name which takes one argument of type text
chr tx set_name "my_name"
  • If you want to pass a dictionary as an argument, you have to single quote it to avoid incorrect shell parsing.
chr tx operation_with_dict_argument '["key1":value1,"key2":value2]'

Deployed

Towards a deployed chain, you can do the same commands but need to to target the chain explicitly. You can do this by either:

  • Using a configured deployment target in your chromia.yml together with deployment options
chr tx --network deployment_configuration --blockchain my_rell_dapp set_name "my_name"
  • Specifying --api-url or --mainnet/--testnet together with the BRID of the dApp you want to interact with.
chr tx --mainnet --blockchain-rid 2D17B27D4F69E0A91B0CA39AF53EFA9B82CDAF698EF906A67C71C266983EEB7A set_name "my_name"