Contract Interaction
Clarinet provides powerful tools for interacting with your contracts during development. The console gives you an interactive REPL where you can call functions, inspect state, and debug issues in real time.
Starting the console
Use clarinet console to launch an interactive session with your contracts deployed to a local simulated blockchain:
clarinet consoleSample startup output:
clarity-repl v3.3.0
Enter "::help" for usage hints.
Connected to a transient in-memory database.The console supports several useful flags for different development scenarios:
--enable-remote-data
Connect to mainnet or testnet to query real contracts
--deployment-plan-path <path>
Use a specific deployment plan
--manifest-path <path>
Use an alternate Clarinet.toml location
--remote-data-api-url <url>
Specify a custom Stacks API endpoint
--remote-data-initial-height <height>
Set the starting block height for remote data
Working with remote data
One of the most powerful features is the ability to interact with real mainnet or testnet contracts from your local console. This lets you test against actual deployed contracts:
clarinet console --enable-remote-dataExample contract calls:
These capabilities help you:
Test integrations with existing protocols
Verify contract behavior against live chain state
Develop contracts that depend on mainnet deployments
Warning: Remote data requirements
Before using remote data, add the target contract to
Clarinet.tomlwithclarinet requirements add SM3VDXK3WZZSA84XXFKAFAF15NNZX32CTSG82JFQ4.sbtc-token.
Using the Hiro API key
Avoid rate limits by setting the HIRO_API_KEY environment variable before launching the console. Clarinet forwards this key in the x-api-key header for all requests:
You can request a free API key from the Hiro Platform.
Working with contracts
List all available contracts in the session:
Working with different principals
Switch between the provided test wallets to validate multi-user flows:
Working with block heights
Advance the chain to test time-dependent logic:
Tip: Console reference
For a complete list of console commands, see the CLI reference.
Common issues
Last updated
Was this helpful?
