I have a contract that allows users to buy a token and pay with a TRC10 token deployed on Tron. Is it possible to replace the token ID with a TRC20 address instead? And if so, how do I implement it? Thanks.

 function buy(address _referredBy) public payable returns (uint256) {
    require(msg.tokenid==1234567);//this is the tokenid I want to replace.
    purchaseTokens(msg.tokenvalue, _referredBy);

TRC20 uses the exact same spec as Ethereum's ERC20. Transfers are certainly possible, but it works differently than TRC10. The user calls approve on the token contract and then your contract is allowed to transfer funds on their behalf. So instead of sending tokens when buy is called, the contract goes and gets them.

Hope that makes a little sense. I recommend taking a look at Ethereum's token page, they go into a lot of detail: https://ethereum.org/token

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.