I know how to use web3 to send USDC tokens from one address to another, by using "web3.eth.Contract (ContractABI, ContractAddress) to create a Contract object, and then creating a data object like so:

var objData = objContract.methods.transfer( DestinationAddress, AmountToTransfer ).encodeABI()

I now need to send the USDC tokens to a contract function, instead of an address. The contract function requires three input parameters.

I assume that I need to create a second Contract object (for the destination contract), but I don't know how to insert the call to the 2nd contract (with the three input parameters), within the var objData = objContract.methods.transfer code shown above.

I am not able to modify the 2nd contract. I have its ABI, so I know how to call its functions.

1 Answer 1


Solidity has the concept of payable functions. Payable functions allow users to forward ether to the contract when calling the function. Unfortunately, this feature only applies to ether. The alternative would be to have your function transfer the ERC-20 token when being called. Keep in mind that you would have to approve the contract to control your ERC-20 tokens.

Your Answer

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

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