I have a problem with raw Transaction. Using this code to send tokens to another contract, something does not work. The transaction is signed correctly, everything is sent to the network but it does not work.
let gasCost = await tokenContract.transfer['address,uint256,bytes'].estimateGas(tradecenterAddress,web3.toWei(
this.uint256,"ether"),
web3.fromAscii(this.bytes),
{from:this.creator});
console.log(gasCost);
let count = web3.eth.getTransactionCount(this.creator);
var rawTransaction = {
"from":this.creator,
"nonce":"0x"+count.toString(16),
"gasPrice":web3.eth.gasPrice.c[0],
"gasLimit":gasCost,
"to":SafeCoinAddress,
"value":"0x0",
"data:":tokenContract.transfer['address,uint256,bytes'].getData(tradecenterAddress,this.uint256,web3.fromAscii(this.bytes),{from:this.creator}),
"chainId":1994
};
let tx = new window.ethereumjs.Tx(rawTransaction);
let privateKey = window.keythereum.recover(this.password,fileOb);
privateKey = privateKey.toString('hex');
let buf = Buffer.Buffer.from(privateKey,'hex');
console.log(privateKey);
console.log(buf);
tx.sign(buf);
let serializedTx = tx.serialize();
let recipt = await web3.eth.sendRawTransaction('0x'+serializedTx.toString('hex'));
console.log(recipt);
Doing the same in this way everything works.
let gasCost = tokenContract.transfer['address,uint256,bytes'].estimateGas(tradecenterAddress,web3.toWei(44,"ether"),web3.fromAscii("fd"));
console.log(gasCost);
let hashT = tokenContract.transfer['address,uint256,bytes'].sendTransaction(tradecenterAddress,web3.toWei(44,"ether"),web3.fromAsci
i("fd"),{from:account0,gas:gasCost});
gasPrice
and chainId are correct.