How do I send a transaction in emulator instead of testnet?

  • Updated

The Flow Emulator is a lightweight tool that emulates the behaviour of the real Flow network. The emulator allows you to simulate the execution of transactions as if they were performed on Mainnet or Testnet.

To send a transaction in the emulator instead of Testnet or Mainnet, you need to specify the network you want the command to use for execution. The flag for this is --network or -n for short. The valid inputs for this flag are the names of networks defined in the configuration (flow.json). By default, it is set to emulator.

Here is an example of how to run a transaction on the emulator using the Flow CLI:

flow transactions send ./transaction.cdc "Hello, me" --signer emulator-tester --network emulator

In this command, ./ is the path to your Cadence transaction file, "Hello, me" is the argument passed to the transaction, emulator-tester is the name of the account signing the transaction, and emulator is the network on which the transaction will be executed.

Remember to have your emulator running when you execute this command. If you haven't started it yet, you can do so by running flow emulator start.
For more information, you can refer to the Flow CLI documentation and the Flow Getting Started guide.