Last active
May 31, 2023 17:44
-
-
Save afsardo/7d95dd65c0797cb959b733a61b824cd4 to your computer and use it in GitHub Desktop.
Simulate multisig txs on any chain with Terra.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { LCDClient, MsgExecuteContract } from "@terra-money/terra.js"; | |
const LCD_URL = "[LCD-ENDPOINT-HERE]"; | |
const CHAIN_ID = "neutron-1"; | |
const DEFAULT_GAS_PRICE = "0.02uatom"; | |
const DEFAULT_GAS_MULTIPLIER = 1.3; | |
(async function () { | |
const multisig = "[MS-ADDRESS-HERE]"; | |
console.log("Neutron: Simulating tx with address", multisig); | |
const lcd = new LCDClient({ | |
URL: LCD_URL, | |
chainID: CHAIN_ID, | |
gasPrices: DEFAULT_GAS_PRICE, | |
gasAdjustment: DEFAULT_GAS_MULTIPLIER, | |
}); | |
const account = await lcd.auth.accountInfo(multisig); | |
try { | |
const simulate = await lcd.tx.estimateFee( | |
[ | |
{ | |
sequenceNumber: account.getSequenceNumber(), | |
publicKey: account.getPublicKey(), | |
}, | |
], | |
{ | |
msgs: [ | |
new MsgExecuteContract( | |
multisig, | |
"neutron1ffus553eet978k024lmssw0czsxwr97mggyv85lpcsdkft8v9ufsz3sa07", | |
{ | |
update_config: { | |
astro_denom: | |
"ibc/5751B8BCDA688FD0A8EC0B292EEF1CDEAB4B766B63EC632778B196D317C40C3A", | |
gov_channel: "channel-6", | |
transfer_channel: "channel-5", | |
}, | |
} | |
), | |
], | |
} | |
); | |
console.log("Success: ", simulate); | |
} catch (error) { | |
console.log("Error: ", error); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment