Отправка токенов erc20 с помощью Web3js - PullRequest
0 голосов
/ 09 июня 2018

Я пытался отправить erc20 (Бела) с одного адреса на другой, в результате получил идентификатор tx, но эта транзакция не отображается ни в одной службе проверки tx, и средства с моего адреса не отправляются.Код на данный момент выглядит так:

web3 = new Web3(new Web3.providers.HttpProvider('https://mainnet.infura.io/PKEY'));


var myAddress = "0x4d0...";
var toAddress = "0xce6...";
var amount = web3.utils.toHex(5);

var count = web3.eth.getTransactionCount(myAddress).then(function(v){console.log(v); count = v});

var privateKey = new Buffer('pkey', 'hex');

//got from https://etherscan.io/address/0x2e98a6804e4b6c832ed0ca876a943abd3400b224#code
var abiArray = '';

var contractAddress = '0x2e98a6804e4b6c832ed0ca876a943abd3400b224';
var contract = new web3.eth.Contract(abiArray, contractAddress, {from: myAddress});

var rawTransaction = {
    "from":myAddress,
    "gasPrice":"0x098bca5a00",
    "gasLimit":"0xcb05",
    "to":contractAddress,
    "value":"0x0",
    "data":contract.methods.transfer(toAddress, amount).encodeABI(),
    "nonce":web3.utils.toHex(count)
};
var transaction = new Tx(rawTransaction);
transaction.sign(privateKey);

web3.eth.sendSignedTransaction('0x' + transaction.serialize().toString('hex'), function (err, hash) {
    console.log(err, hash);
});
...