myetherwallet allows you to send tokens without asking anything
Most tokens are implemented using ERC20 standard, and it clearly defines the function format for transferring tokens. So only the other parts of transaction are required.
Should I use the private key of my ethereum address to sign this transaction? or its another private key like the contract one
Contract does not have any private key. If your account holds any tokens, then those tokens can be transferred by that account if that account submits a signed txn to transfer tokens.
how come I can't do the same programatically? What am I missing?
You can do it programatically. Token transfer function resides inside the contract. You can call that function from senders account. And sender's tokens would be transferred. You may find code to achieve this at How to send ERC20 token using Web3 API?
var count = web3.eth.getTransactionCount("0x26...");
var abiArray = JSON.parse(fs.readFileSync('mycoin.json', 'utf-8'));
var contractAddress = "0x8...";
var contract = web3.eth.contract(abiArray).at(contractAddress);
var rawTransaction = {
"from": "0x26...",
"nonce": web3.toHex(count),
"gasPrice": "0x04e3b29200",
"gasLimit": "0x7458",
"to": contractAddress,
"value": "0x0",
"data": contract.transfer.getData("0xCb...", 10, {from: "0x26..."}),
"chainId": 0x03
};
var privKey = new Buffer('fc3...', 'hex');
var tx = new Tx(rawTransaction);
tx.sign(privKey);
var serializedTx = tx.serialize();
web3.eth.sendRawTransaction('0x' + serializedTx.toString('hex'), function(err, hash) {
if (!err)
console.log(hash);
else
console.log(err);
});
It seems I need the ABI, but I would like to avoid using it.
You can use ABI of any ERC20 token, since all ERC20 tokens have that one function that you want to call.
It doesn't make any sense to send the same transaction with lower gasPrice
: If both transactions are in mempool, the miners pick the transaction with the higher gasPrice
(your first transaction), so there's no need to add the second one.
If, for whatever reasons, you really want to have the same transaction with lower gasPrice, you could do the following:
- cancel the pending transaction - this costs gas, because it actually sends a 0 ETH transaction to itself, with a higher gasPrice than the original tx
- re-submit the original tx (with its
nonce
increased ), with a lower gasPrice
I can't imagine any scenario where this would be of any help, but it's definitely possible.
Best Answer
As you said, zero gas price transactions are totally valid but might take a looong time (eternity?) to mine. It seems at least Mist allows zero gas price transactions: Can I set the gas price to whatever I want?
In theory any client could allow it, but probably it's not supported in some clients due to not making much sense.
Upon googling I also stumbled upon a partially relevant, but interesting rant about zero gas price txs: https://www.reddit.com/r/ethereum/comments/7lx1do/a_christmas_mystery_sweepers_and_zero_gas_price/
P.S. The tx you linked has other txs with the same nonce and at least some of them have gas price above zero. But difficult to say of course what the user has tried to accomplish.