-1

I want to implement USDC into my contract which is currently using ETH. I know I need to implement ERC20 interface in order to let my contract know which functions it should expect. But how should I continue? I suppose I need to take USDC contract address and do something with it. I couldn't find what exactly should I do.

The goal is to be able to accept USDC and display its balance. Any useful links, please? (I am new to smart contract development)

1 Answer 1

0

you tell your contract that the contract that lives at the USDC token address is an ERC20 token like this IERC20 token = IERC20(USDCContractAddress) and then you use its function like this token.transferFrom(user, address (this), amount); // This is an example that takes 'amount' of USDC from 'user' and send it to the contract address, assuming the users allowance is > to 'amount'

General syntax for using interfaces like that is

// Declaring 
YourInterface contract = YourInterface(contractAddress);
// Using 
contract.yourFunction(input1, input2); // 'yourFunction' must be in 'YourInterface' and 'input1' and 'input2 must be of correct types or your contract wont compile
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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