1

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;
    }
}
  • Welcome to Stack Overflow! Please visit the [help center](https://stackoverflow.com/help), take the [tour](https://stackoverflow.com/tour) to see what and [How to Ask](https://stackoverflow.com/questions/how-to-ask). Do some research. If you get stuck, post a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) of your attempt, noting input and expected output using the [snippet editor](https://meta.stackoverflow.com/questions/358992/ive-been-told-to-create-a-runnable-example-with-stack-snippets-how-do-i-do). – Markus Safar Jul 04 '23 at 07:34
  • Please also check [this question checklist](https://codeblog.jonskeet.uk/2012/11/24/stack-overflow-question-checklist/). – Markus Safar Jul 04 '23 at 07:34

0 Answers0