ATEN Token
The ATEN token contract follows the standard ERC-20 specification, including the use of 18 decimal places. The contract also includes an additional transferAndCall feature, which allows direct smart contract interactions without relying on the typical approve/transferFrom mechanism.
TransferAndCall
Besides the standard ERC20 token features (transfer(), balanceOf(), allowance(), etc), the following transferAndCall feature is also available:
function transferAndCall(
address to,
uint256 amount,
bytes calldata data
) public returns (bool)Send tokens to a contract address along with call data
Parameters:
to
address
destination address for the transfer
amount
uint256
amount to be sent
data
bytes
supplementary data to be provided to the receiving contract
The receiving contract must implement the ITokenCallReceiver interface in order to receive the tokens and execute the desired call.
interface ITokenCallReceiver {
function onTokenTransfer(
address from,
uint256 amount,
bytes calldata data
) external returns (bool);
}Example
The following example demonstrates how to use the transferAndCall function to send tokens to a contract and execute a specific function:
On the receiving contract side, the onTokenTransfer function should be implemented to handle the incoming tokens and execute the desired logic:
Last updated
Was this helpful?