The Transfer.sol contract is a secure, minimal proxy contract that facilitates token transfers on behalf of users. It is designed to enable meta-transactions, batch payments, and delegated transfers within dApps and backend-controlled flows like those used in Assetux Layer 2.
- Primary Role: Transfers ERC-20 tokens from the proxy to a recipient.
- Deployer Control: Only the contract deployer can initiate transfers.
- Security: Implements
Ownablefrom OpenZeppelin to restrict access. - Use Case: Acts as an execution layer for microservices or bots to perform verified token transfers without exposing user keys.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
contract Transfer is Ownable {
function transfer(address _token, address _to, uint _amount) external onlyOwner {
IERC20(_token).transfer(_to, _amount);
}
}Only the contract owner (typically a backend signer or deployer wallet) can call the transfer function. Unauthorized addresses will be reverted via the onlyOwner modifier.
Transfers _amount of an ERC-20 token from this contract to _to.
_token: The ERC-20 token address_to: Recipient wallet address_amount: Number of tokens (in base units)
⚠️ Ensure the contract holds enough tokens to complete the transfer.
- Solidity ^0.8.20
- OpenZeppelin Contracts
npm install @openzeppelin/contractsconst Transfer = await ethers.getContractFactory("Transfer");
const transferProxy = await Transfer.deploy();
await transferProxy.deployed();
console.log("Transfer Proxy deployed at:", transferProxy.address);To allow the proxy to send tokens, you must first send tokens to the proxy address:
await erc20Token.transfer(proxyAddress, amount);Then trigger the proxy transfer:
await transferProxy.transfer(tokenAddress, recipientAddress, amount);- ✅ Use with microservices for payouts
- ✅ Enable Telegram bots to control funds without private keys
- ✅ Batch payments through orchestration
- ✅ Simplified relayer model for controlled wallets
- All transfers are strictly permissioned to the contract owner.
- Make sure the owner wallet is securely stored (e.g., in a backend service or cold wallet).
- Use multi-sig if needed for increased safety.
MIT License — Free to use and modify for both personal and commercial purposes.