0

I am writing a smart contract, but there is an issue, the scenario is: my smart contract should send the specified amount of a token(which is already deposited into the current smart contract) when it's 'transfer' function is called. I already wrote a smart contract, but it only sends zero transaction, without the token. is there any sample in solidity to do it?

[edited]: here is my contract:

pragma solidity 0.5.16;

interface IBEP20 {
        function transfer(address _to, uint256 _amount) external returns (bool);
    }

contract Token_lock {
    
    address public owner;
    
    mapping (address => uint256) private _balances;
    mapping (address => uint256) private _balanceOf;
    bool public transferable = false;
    
    event Transfer(address indexed from, address indexed to, uint256 value);
    
    constructor() public {
        owner = msg.sender;
     }
    
    modifier checkBlock() {
        if(owner != msg.sender)
        {
         require(block.number > 18000000 , 'Your Tokens are locked!');
         _;
        }
    } 
    
    function balanceOf(address account) internal view returns (uint256) {
        return _balances[account];
    }
      
    function transfer(address _to, uint _value) public checkBlock() returns(bool success) {
        
        IBEP20 tokenContract = IBEP20(0x059...);
        return tokenContract.transfer(_to, _value);
    }
    
}

I already have a main smart contract(token) on address "0x059...", I'm writing a second smart contract as u can see to lock tokens for all new token receivers. acutally i should be able to send tokens to anyone but i don't wanna them to be able to transfer it to the others until a specified time(block number).

3
  • Did I understand correctly: your contract has a transfer function, and when someone calls it, the function sends token A to address B, correct? Sep 14 at 15:08
  • Provide the code to see where of it is wrong or what did you forget Sep 14 at 22:49
  • my post is already edited, codes added.
    – NrN
    Sep 15 at 6:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.