0

I had 100 USDC transferred to a local Ethereum wallet I control. It shows up as a valid token when I view it in Etherscan. I normally use geth CLI for all Ethereum transactions, but I'm not sure how to go about sending tokens to a different Ethereum address in this case.

The only suggestion I've found so far suggests the below as the method for sending USDC:

geth console

Then create contract wrapper class like this:

var erc20 = web3.eth.contract ([{"constant": false, "inputs": [{"name": "_to", "type": "address"}, {"name": "_value", "type": "uint256"}], "name": "transfer", "outputs": [{"name": "", "type": "bool"}], "payable": false, "stateMutability": "nonpayable", "type": "function"}]);

And instantiate it at token smart contract address (The contract address for the received USDC as shown in etherscan.io): The contract address for the received USDC as shown in etherscan.io

var myToken = erc20.at ("0x<token smart contract address here>");

now unlock your "from" account (the Ethereum wallet that holds the USDC/tokens):

personal.unlockAccount ("0x<from address>");

and finally send your tokens:

myToken.transfer ("0x<to address>", "<amount in basic units>", {from: "0x<from address>"});

The to address is the Ethereum wallet that will be receiving the tokens, the amount in basic units would be 100 (to send all USDC) and the from address would be the same as the unlocked account.

Is the above correct and do I need to have an Eth balance to pay for gas for the contract etc?

1 Answer 1

1

You need ether to pay the transaction's fee. The USDC contract uses 6 decimals so to transfer 100 USDC the amount parameter should be 100 * 1000000.

2
  • Hi, thanks for that. So are the parameters above correct? Would the transfer command still be: myToken.transfer ("0x<to address>", "1000000", {from: "0x<from address>"}); ? Or do I need to add something for the transaction fee?
    – NULLZ
    Oct 12, 2021 at 0:58
  • 1
    @NULLZ That should work, but geth console isn't very nice to send a transaction. Probably it would be easier to import the account in a wallet like MyetherWallet, Metamask or MyCrypto.
    – Ismael
    Oct 12, 2021 at 5:53

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.