Skip to content

Instantly share code, notes, and snippets.

@tkowalczyk
Created February 12, 2022 12:46
Show Gist options
  • Save tkowalczyk/f201163e990bab393667b3a80fbb1966 to your computer and use it in GitHub Desktop.
Save tkowalczyk/f201163e990bab393667b3a80fbb1966 to your computer and use it in GitHub Desktop.
import {
LCDClient,
MsgExecuteContract,
MnemonicKey,
isTxError
} from '@terra-money/terra.js';
import dotenv from 'dotenv';
dotenv.config();
const terra = new LCDClient({
URL: process.env.NETWORK_URL,
chainID: process.env.NETWORK_CHAIN_ID,
gasAdjustment: 1.7,
gasPrices: { uluna: 0.015 },
});
const mk = new MnemonicKey({
mnemonic: process.env.MNEMO
})
const wallet = terra.wallet(mk);
console.log(wallet.key.accAddress);
const burn = new MsgExecuteContract(
wallet.key.accAddress,
process.env.TOKEN_ADDRESS,
{
"burn":
{
"amount": process.env.AMOUNT_TO_BURN,
}
}
)
const burningTx = await wallet.createAndSignTx({
msgs: [burn],
memo: process.env.TXNS_MNEMO
});
const burnRes = await terra.tx.broadcast(burningTx);
console.log(burnRes);
if (isTxError(burnRes)) {
throw new Error(
`instantiate failed. code: ${burnRes.code},
codespace: ${burnRes.codespace},
raw_log: ${burnRes.raw_log}`
);
}
console.log("burning completed");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment