Skip to main content

Executing Contracts

The xyz program execute command calls contract methods that modify state (like a transaction).

Usage

Arguments

Basic Execution

Output:

Message Formats

Inline JSON

With Parameters

From File

Options

Examples

Transfer Tokens (CW20)

Send with Funds

Some contracts require funds with execution:

Batch Operations

Dry Run

Simulate without broadcasting:
Output:

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 when unauthorized:

Error Handling

The CLI provides user-friendly errors:

Complex JSON

For complex messages, use a file:

Scripting

Check Result

Retry on Failure

Troubleshooting

Validate your JSON:
Verify contract exists:
Check method requirements:
  • Are you the owner?
  • Do you have the required role?
Increase gas buffer: