How can i easy swap flow scripts and transactions contract address from testnet to mainnet or mainnet-testnet

Hi all.
I have a simple question.

I am using one more scripts and transactions files. I deployed my app to production i want to use mainnet contract address, or trying to debug i want to use testnet address.

I am changing everytime my contract address. How can i do that with correct way?

Screen Shot 2022-09-21 at 21.48.15


Does the SDK support this?

Hey there! I think what you’re looking for is using the flow.json aliases + env variables to fill in the correct address/contexts for scripts and transactions on mainnet/testnet. Check out this recent scaffold for an example:

p.s. pro tip for local dev: we recently launched Flow CLI super commands which allows address-less imports and auto-deployment of contracts: Using Super Commands with the Flow CLI | Flow Blockchain

1 Like

Yep Andrea.
We used your method.
We changed our token address like this : 0xFungibleToken.
And then we want to change address on replace the our contract address.

Pseudo code:

  .config() // returns the config instance
  .put("0xFungibleToken", "0x5644asd54a5s4d5") // configures "0xFungibleToken" to be "0x5644asd54a5s4d5"
  .put("0xNonFungibleToken", "0xd54a5sd5445488"); // configures "0xNonFungibleToken" to be "0xd54a5sd5445488"
1 Like