Vie
September 25, 2020, 1:05pm
1
hi, I want to send USDT with custom data, how can I do that?
I deploy en erc20 token ‘HelloWorldToken’ and I send a token to mysql with custom data ‘HelloWorld’,
the url is https://rinkeby.etherscan.io/tx/0xc1b54de98d2b8df5baf343d721ef8e245ff3ef6cfffa50bc848f28392a40347c
the data of this tx is as follow:
0xa9059cbb000000000000000000000000ad61cc6653b62b7c05bd2f593bc49d22fb901a9c000000000000000000000000000000000000000000000000000000000000040048656c6c6f576f726c64
just as we all know, a9059cbb
is the function id of transfer(address,uint256)
and 000000000000000000000000ad61cc6653b62b7c05bd2f593bc49d22fb901a9c
is the address, the 0000000000000000000000000000000000000000000000000000000000000400
is the amount,
and I add my custom data of 48656c6c6f576f726c64
(HelloWorld) to the end.
and the tx is ok, the token transfer from A to B.
Is there a EIP abount this on how to add custom data to the end of a token?
1 Like
Hi @vie ,
I assume that you should be able to do the same with transfer
on the USDT contract.
It has a check for data size but this is to prevent short addresses…
The Contract Address 0xdac17f958d2ee523a2206206994597c13d831ec7 page allows users to view the source code, transactions, balances, and analytics for the contract address. Users can also interact and make transactions to the contract directly on...
/**
* @dev Fix for the ERC20 short address attack.
*/
modifier onlyPayloadSize(uint size) {
require(!(msg.data.length < size + 4));
_;
}
/**
* @dev transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint _value) public onlyPayloadSize(2 * 32) {
uint fee = (_value.mul(basisPointsRate)).div(10000);
if (fee > maximumFee) {
fee = maximumFee;
}
uint sendAmount = _value.sub(fee);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(sendAmount);
if (fee > 0) {
balances[owner] = balances[owner].add(fee);
Transfer(msg.sender, owner, fee);
}
Transfer(msg.sender, _to, sendAmount);
}
Hi @Vie ,
Were you able to send custom data?
Vie
October 5, 2020, 12:37pm
4
1 Like