Created
August 3, 2023 05:23
-
-
Save wakasann/6ddb2e6a8a3d84096ee46ea82aecc83d to your computer and use it in GitHub Desktop.
token transfer smart contract
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: GPL-3.0 | |
pragma solidity ^0.8.14; | |
import {IERC20} from "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/IERC20.sol"; | |
contract MyUsdtTransfer{ | |
mapping(string => uint) public orders; //orderNo => orderType | |
function getAllowance(address _token) public view returns(uint256) { | |
IERC20 token = IERC20(_token); | |
return token.allowance(msg.sender, address(this)); | |
} | |
// to = Account B's address | |
function stake(address _token, address receiver, uint amount,string memory _no,uint _type) public { | |
IERC20 token = IERC20(_token); | |
//require(orders[_no] == 0,"the order id is used"); | |
orders[_no] = _type; | |
token.transferFrom(msg.sender, receiver, amount); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment