Perform Action of NFT Gen2
Perform Action
create file action.ts
vim action.ts
import {SixDataChainConnector} from "@sixnetwork/six-data-chain-sdk";
const main = async () => {
const sixConnector = new SixDataChainConnector()
// specify the RPC URL of the chain
sixConnector.rpcUrl = "https://rpc1.fivenet.sixprotocol.net:443";
// Retrieve acctount signer from private key or mnemonic
const accountSigner = await sixConnector.accounts.privateKeyToAccount(<string_private_key_or_mnemonic_seed>)
// Get index of account
const address = (await accountSigner.getAccounts())[0].address
const rpcClient = await sixConnector.connectRPCClient(accountSigner)
const msg = await rpcClient.nftmngrModule.msgPerformActionByAdmin({
creator: address,
nft_schema_code: "six.rocket_ticket",
tokenId: "1",
action: "burn",
ref_id: "tk1_burn_20points_1",
parameters: [{
name: "points",
value: "20"
}]
})
const txResponse = await rpcClient.nftmngrModule.signAndBroadcast([msg], {
fee: { amount: [{ denom: "usix", amount: "10000000" }], gas: "1500000" },
memo: "tk1_burn_20points",
});
console.log(txResponse)
}
main()
Execute action.ts
npx ts-node ./action.ts
When it is successful it will response similar to:
{
code: 0,
height: 623,
rawLog: '[{"events":[{"type":"message","attributes":[{"key":"action","value":"perform_action_by_admin"},{"key":"action","value":"run_action"},{"key":"run_action_result","value":"success"},{"key":"run_action_changelist","value":"[{\\"key\\":\\"points\\",\\"previous_value\\":\\"400\\",\\"new_value\\":\\"380\\"}]"}]}]}]',
transactionHash: '2063C9F859FA5C033E758B30C1AC16F1E501B00629F2ED2A6A09707C558BF9C8',
gasUsed: 97246,
gasWanted: 200000
}
Last updated