我们检测到有非人物种参与了INSCT的打新

前方高能!

为了确保社区权益不被脚本攻击,INSCTraders团队开放脚本自动化打新代码,帮助社区发展:

import Web3 from "@platonnetwork/web3";       // 导入web3

const provider = "https://openapi2.platon.network/rpc";  // 定义provider,即PlatON节点的RPC端口
const w3 = new Web3(provider); // 创建web3的实例,这里命名为w3
const chainID = 210425;        // 定义PlatON ChainID

var AddressList = [
    {
        "name": "",
        "from": "",
        "fromPk": ""
    },
]

// 定义toHex函数,将10进制转成16进制
const toHex = (number) => {
    return w3.utils.numberToHex(parseInt(number));
};

// 定义转账函数:txDemo
export async function txDemo(fnParams) {
    let { from, to, fromPk, value, data } = fnParams;

    // nonceHex: 转出地址的nonce值
    let nonceHex = toHex(await w3.platon.getTransactionCount(from));

    let tx = {
        from: from,
        to: to,
        value: value,
        chainId: chainID,
        gasPrice: toHex(await w3.platon.getGasPrice()),  // 获取当前链上的gasprice
        gas: toHex(22296),          // 转账固定gas消耗:22296
        nonce: nonceHex,
        data: data
    };

    // 地址签名
    let signTx = await w3.platon.accounts.signTransaction(tx, fromPk);

    // 发出签名交易
    let reply = await w3.platon.sendSignedTransaction(signTx.rawTransaction);
    return reply;
}

var batch = 1;

while (batch < 100) {
    var i = 0;
    console.log("The", batch, "epoch");
    while (i < AddressList.length) {
        console.log("the", i + 1, "address");
        // fnParams 函数示例
        const fnParams = {
            "from": AddressList[i].from, // 转出地址
            "to": AddressList[i].from, // 转入地址
            "fromPk": AddressList[i].fromPk, // 转出地址私钥
            "value": w3.utils.toVon('0', 'lat'),
            "data": '' //交易数据,查询scan获取
        }
        await txDemo(fnParams).then(i = i + 1);
    }
    batch = batch + 1;
}