Rarity Manifested打包操作合约

in hive-180932 •  3 years ago 

最近AC的Rarity Manifested火了,大家都开始领取英雄养号

我领了200多个英雄,一个个探索,升级,领取金币将会占据太多时间,所以写了脚本自动帮我养英雄

脚本有个问题是,操作需要一个个提交,因为我的英雄比较多,所以全部提交完需要一段时间

为了解决太多操作问题,写了一个合约用于打包探索,升级和领取金币的操作

只需调用这个合约,就可以打包操作,省去一个个提交的时间

合约里面有3个函数

  • adventureTime(): 探索
  • levelAllUp(): 升级
  • claimGold(): 领取金币

要让合约替你操作,需要授权给钱包。

上面的3个函数中,用了2个不同的合约,所以要分别在2个合约里面授权给打包合约

这是打包合约的代码:

pragma solidity 0.8.7;

interface IRarity {
    function adventure(uint _summoner) external;
    function level_up(uint _summoner) external;
}

interface IGold {
    function claim(uint _summoner) external;
}

/**
 * @title AdventureTime
 * @dev sends multiple summoners on an adventure or to claim gold
 */
contract RarityTime {
    IRarity rarity = IRarity(0xce761D788DF608BD21bdd59d6f4B54b2e27F25Bb);
    IGold gold = IGold(0x2069B76Afe6b734Fb65D1d099E7ec64ee9CC76B2);
    function adventureTime(uint256[] calldata _ids) external {
        uint len = _ids.length;
        for (uint i = 0; i < len; i++) {
            rarity.adventure(_ids[i]);
        }
    }
    
    function levelAllUp(uint256[] calldata _ids) external{
        uint len = _ids.length;
         for (uint i = 0; i < len; i++) {
            rarity.level_up(_ids[i]);
        }
    }
    
    function claimGold(uint256[] calldata _ids) external{
        uint len = _ids.length;
         for (uint i = 0; i < len; i++) {
            gold.claim(_ids[i]);
        }
    }
}

合约地址:https://ftmscan.com/address/0x9df5075615bc1a41b718de9ae8ab65f79da362cc#writeContract

这是打包的操作:

image.png

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!