Last updated 2 months ago
Was this helpful?
Migrate a contract's code while keeping the same address. Invokes the migrate() function on the new code.
migrate()
Input:
See for further docs on contract migration.
Learn how to do contract migration with SecretJS.
import { SecretNetworkClient, Wallet } from "secretjs"; const wallet = new Wallet("Your mnemonic words go here"); const secretjs = new SecretNetworkClient({ chainId: "pulsar-3", url: "https://pulsar.lcd.secretnodes.com", wallet: wallet, walletAddress: wallet.address, });
const tx = await secretjs.tx.compute.migrateContract( { sender: myAddress, contract_address: contractAddress, code_id: newCodeId, code_hash: codeHash, // optional but way faster msg: { migrate_state_to_new_format: {}, }, sent_funds: [], // optional }, { gasLimit: 100_000, }, );
secretjs.tx.compute.migrateContract()