How to use a specific coin(non eth) as the currency for contract?

Hi everyone! Been learning solidity and building some things with tutorials/reading but they all used ethereum as the coin to send in transactions. Trying to make a roulette game and maybe it just hasn’t clicked in my head but how do you specify that you want to use a specific token on the txs when for example placing a bet and withdrawing your winnings.(address will hold ftm for gas, chainlink for vrf and an existing coin as gamble currency).

Seeing as i’m playing around with this project on Fantom would be cool to be able to accept the gamble currency as well as ftm. If players payed with ftm it would swap for gamble
token (more buy pressure) and add to the house funds before the roulette spin. But that’s something else i’m figuring out :slight_smile:

From what i’ve been trying to understand one of the steps seems to be importing erc20/interface to your contract but all i can find is about creating a token, adding supply, deploying it etc as opposed to adding an existing token to a contract and just using that as the currency for some if not all payables.

Thanks and sorry for the noob question

You can import the token using IERC20 and then when you need to use the contract balance of that token use like this:

IERC20 token = address of the token;

token.balanceOf(address(this));

2 Likes

Thanks a lot for the reply!

1 Like