Executing Contracts
Thexyz program execute command calls contract methods that modify state (like a transaction).
Usage
Arguments
| Argument | Description |
|---|---|
contract | Contract address |
message | JSON message or @file.json |
Basic Execution
Message Formats
Inline JSON
With Parameters
From File
Options
| Flag | Description | Default |
|---|---|---|
--from | Signing key | Required |
--funds | Send funds with execution | None |
--dry-run | Simulate only | false |
--gas-buffer | Gas multiplier | 1.3 |
Examples
Transfer Tokens (CW20)
Send with Funds
Some contracts require funds with execution:Batch Operations
Dry Run
Simulate without broadcasting:Message Examples
Simple Action
With Parameters
Nested Structure
Multiple Actions (if supported)
Authorization
Execute methods may have authorization requirements:Public Methods
Anyone can call:Owner-Only Methods
Error Handling
The CLI provides user-friendly errors:| Chain Error | CLI Message |
|---|---|
unauthorized | Permission denied: only the contract owner can… |
insufficient funds | Insufficient balance to complete… |
out of gas | Transaction requires more gas. Try increasing —gas |
Complex JSON
For complex messages, use a file:Scripting
Check Result
Retry on Failure
Troubleshooting
Invalid JSON
Invalid JSON
Validate your JSON:
Contract not found
Contract not found
Verify contract exists:
Unauthorized
Unauthorized
Out of gas
Out of gas
Increase gas buffer: