How To Transfer All Your Steem Monsters Cards

in #steemmonsters5 years ago

carbon.png

Steem Monsters a few weeks ago introduced Dark Energy Crystals (DEC). You can burn your cards and received DECs. You can also get DECs when you win a battle.

Like many of you, I have Steem Monsters alt accounts. But I do not have much time to play those. Also, they do not have strong cards. So, I thought why not transfer them back to my main account, combine and play.

But sending so many cards manually is a pain. You can only do all of the same cards together from the interfaces. Me, not the only one facing this, so I wrote a Node JS script make my life a bit easier. 😁

const fetch = require('node-fetch');
const { Client, PrivateKey } = require('dsteem');

const client = new Client('https://anyx.io');

const settings = {
  account: 'reazul-dev', // Sender account
  receiver: 'reazuliqbal', // Receiving account
  wif: '', // Private posting key of the sender
  commons: true, // Set to false, if you do not want to send them
  rares: true, // Set to false, if you do not want to send them
  epics: true, // Set to false, if you do not want to send them
  legendaries: true, // Set to false, if you do not want to send them
};

(async () => {
  // Making lists of commons, rares, epic, and legendaries
  // We will use this to filter cards later
  const commons = [];
  const rares = [];
  const epics = [];
  const legendaries = [];

  await fetch('https://steemmonsters.com/cards/get_details').then(r => r.json())
    .then((cards) => {
      cards.forEach((c) => {
        if (c.rarity === 1) commons.push(c.id);
        if (c.rarity === 2) rares.push(c.id);
        if (c.rarity === 3) epics.push(c.id);
        if (c.rarity === 4) legendaries.push(c.id);
      });
    });


  // Fetching all cards except cards listed for sell
  // Filtering based on selected settings
  // And making an array of all the eligible card IDs
  const cards = await fetch(`https://steemmonsters.com/cards/collection/${settings.account}`)
    .then(r => r.json())
    .then(c => c.cards.filter(r => r.market_id === null)
      .filter((card) => {
        if ((settings.commons && commons.includes(card.card_detail_id))
          || (settings.rares && rares.includes(card.card_detail_id))
          || (settings.epics && epics.includes(card.card_detail_id))
          || (settings.legendaries && legendaries.includes(card.card_detail_id))) {
          return true;
        }

        return false;
      }).map(a => a.uid));

  // Broadcasting custom json to transfer all cards
  if (cards.length > 0) {
    client.broadcast.json({
      required_auths: [],
      required_posting_auths: [settings.account],
      id: 'sm_gift_cards',
      json: JSON.stringify({ to: settings.receiver, cards, app: 'sm-market/0.1' }),
    }, PrivateKey.from(settings.wif))
      .then(r => console.log(r))
      .catch(e => console.error(e));
  }
})();

Copy this code and save it as script.js and change settings if you need. Then run it from Terminal:

node script.js

Here is an example transaction.

You only need to change settings. But if you are technical enough feel free to change the code as you need.

In this example, I am sending all my cards from @reazul-dev to @reazuliqbal account.

const settings = {
  account: 'reazul-dev', // Sender account
  receiver: 'reazuliqbal', // Receiving account
  wif: '', // Private posting key of the sender
  commons: true, // Set to false, if you do not want to send them
  rares: true, // Set to false, if you do not want to send them
  epics: true, // Set to false, if you do not want to send them
  legendaries: true, // Set to false, if you do not want to send them
};

Settings are kind of self-explanatory. Set account to the sender, put the private posting key of the sender to wif, set receiving an account in receiver. If you don't want to send commons set it to false. This is the same for rares, epics, and legendaries.

The script is provided as is and without any guarantee. If this causes you any harm, I cannot be held responsible. Code screenshot was generated using Carbon.

Sort:  

Thanks for sharing and caring, your post was very clear and on to the point. Everything was explained in details and was easy to understand.

Thank you for commenting.

You got a 4.59% upvote from @bdvoter courtesy of @anikaa!

Delegate your SP to us at @bdvoter and earn daily 100% profit share for your delegation & rewards will be distributed automatically daily.

500 SP, 1000 SP, 2500 SP, 5000 SP, 10000 SP.

If you are from Bangladesh and looking for community support, Join BDCommunity Discord Server & If you want to support our service, please set your witness proxy to BDCommunity.

Hi @reazuliqbal, your post has been upvoted by @bdcommunity! It is a manual curation project from Bangladesh.

If you want to support us, please consider setting us as your witness proxy, or delegating STEEM POWER to us.

20 SP50 SP100 SP200 SP300 SP500 SP1000 SP

JOIN US ON

Coin Marketplace

STEEM 0.35
TRX 0.12
JST 0.040
BTC 70733.96
ETH 3563.16
USDT 1.00
SBD 4.76