How can i create a smart contract on TRON network to use USDT Token instead of TRX

176 Views Asked by At

I want to deploy a smart contract on TRON Network but I want it to use USDT instead of TRX

I have already created a smart contract which uses TRX no i need something that uses USDT

i just need a simple contract in which the user can invest a particular amount in USDT to our contract and withdraw from the contract directly.

// SPDX-License-Identifier: GPL-3.0

pragma solidity >=0.4.17;

contract INVSTUSDT {
    using SafeMath for uint256;

    address private owner;
    address private developer;
    string[] strings;

    uint8 private MinPay = 50; // 50 TRX
    uint8 private DevFee = 10; // 10 Percent
    uint24 private vTRX = 1000000; // Value of 1 TRX

    struct Users {
        uint32 balance;
    }
    mapping(address => Users) public users;

    constructor() {
        owner = msg.sender;
    }

    modifier onlyOwner() {
        require(msg.sender == owner);
        _;
    }

    function transferOwnership(address _newOwner) public onlyOwner {
        owner = _newOwner;
    }

    function addDeveloper(address payable _newDev) public onlyOwner {
        developer = _newDev;
    }

    function Invest() public payable returns (uint32) {
        address _uid = msg.sender;
        uint32 _amount = msg.value / vTRX;
        if (!users[_uid].valid){
            Users storage user = users[_uid];
        }else{
            user = users[_uid];
        }
        user.balance = user.balance.add(_amount);
        return _amount;
    }

    function Withdraw(uint32 _amt) public returns (uint32) {
        address _uid = msg.sender;
        if (_amt > MinPay && users[_uid].balance >= _amount) {
            uint256 _devFee = (_amount * DevFee) / 100;
            developer.transfer(_devFee);
            payable(msg.sender).transfer(_amount - _devFee);
            users[_uid].balance = users[_uid].balance.sub(_amount);
            return 1;
        } else {
            return 0;
        }
    }

    function CheckBalance(address _address) public returns (uint32) {
        return users[_address].balance;
    }
}

library SafeMath {
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        if (a == 0) {
            return 0;
        }
        uint256 c = a * b;
        assert(c / a == b);
        return c;
    }

    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a / b;
        return c;
    }

    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        assert(b <= a);
        return a - b;
    }

    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        assert(c >= a);
        return c;
    }
}
0

There are 0 best solutions below