current position:Home>How to write a contract? You can transfer some Rec20 tokens to it or take it out

How to write a contract? You can transfer some Rec20 tokens to it or take it out

2022-02-03 23:28:04 Q & A of Denglian community

pragma solidity ^0.5.8;import "./ITRC20.sol";contract Tokentest2{           ITRC20 public tokenaddress;           address  public tokenOwner;     constructor(address tokenadd,address _tokenOwner)public{           tokenaddress = ITRC20(tokenadd);           tokenOwner = _tokenOwner;     }          function withdraw(uint256 withdraw_amount)public {        tokenaddress.transferFrom(tokenOwner,msg.sender,withdraw_amount);    }    function givetoken(uint256 give_amount)public{        address buyer = address(msg.sender);        tokenaddress.approve()        tokenaddress.transferFrom(buyer,tokenOwner,give_amount);     }}





Other answers 1:

copyright notice
author[Q & A of Denglian community],Please bring the original link to reprint, thank you.
https://en.netfreeman.com/2022/02/202202032328029945.html

Random recommended