I transferred some ether form an exchange site to an invalid address (invalid in that the correct address was trailed by 6 numbers I accidentally pasted in). Looking for that address on Ethereum chain explorers I am told that is invalid. Will the blockchain refuse the transaction and return the funds?
Invalid Ethereum Address Transfer – Are Funds Returned from Exchanges?
addressesexchanges
Related Solutions
You're trying to apply a model that is appropriate for Bitcoin mainly due to its limitations. It will be an awkward strategy for Ethereum that overlooks it's strengths.
Bitcoin: Not especially programmable, but easy to sweep funds from multiple accounts. Ethereum: Especially programmable, but not so easy to sweep funds from multiple accounts.
Ethereum also has unique security considerations and it's important to confirm that your client has all the capabilities your contract assumes they have, such as the ability to form a transaction and sign a withdrawal request. That is NOT the case if they are sending from another exchange, so you need to prevent it. You probably need registration/KYC in any case, so confirm they have full control of the accounts they will use, and then inform the contract they are "approved" to send money.
- You can use a single deposit account - all money together, so no need to sweep.
- You can know who sent it and emit events, record it etc. - all accounting requirements.
- It is programmable - whatever happens next.
You should confirm that your users can sign a transaction. This will ensure they can work with any contract interface you show them in the future.
- Have them sign a message and send it to you, off-chain (free). Confirm their address with ecrecover.
- Now you know who is who. Not from where the money arrived. By where it came from. No reason a user can't confirm multiple accounts (step 1) but it is unwise to accept funds from unknown senders.
For brevity, I will skip over withdrawal functionality because you will probably transfer the funds to operating accounts as soon as they are received and you might have a completely different contract where you send funds to be withdrawn - or send to the user based on a web site interaction.
This is not presented as a battle-ready production contract, but more like an simple example to show the approach.
pragma solidity 0.5.16;
contract Deposit {
address payable public wallet;
mapping(address => bool) public approved;
event LogApproved(address approver, address approved);
event LogDeposit(address sender, uint amount);
function authorize(address allowed) public {
require(msg.sender == wallet, "Only the owner can do this, e.g. from their admin server.");
emit LogApproved(msg.sender, allowed);
approved[allowed] = true;
}
function deposit() public payable {
require(approved[msg.sender], "Unauthorized sender. Please register.");
emit LogDeposit(msg.sender, msg.value); // <=== there's your accounting
wallet.transfer(msg.value);
}
}
The accounting concern is immortalized on the blockchain and is inspectable by an external client, e.g. nodejs. The money goes to your wallet
account and you can carry on from there.
Hope it helps.
Best Answer
Depends on "how" invalid it is.
If you send ether to a public address that does not exist (i.e. nobody has the private key for), assuming that the format of the address is correct (hex, correct length, etc), the funds are cryptographically unretrievable. The Blockchain sees it as a valid transaction but there is no private key so nobody can sign a transaction with that account as the sender. If you replaced the last 6 characters of the address with 6 random characters this would be the case.
If you paste an extra 6 characters at the end of a valid address, it no longer matches the expected format (length) of an Ethereum address, therefore it will (hopefully) be rejected by the wallet. The transaction will not be processed and all ether will stay in the sender account. If you did this, it is possible that the transaction did not go through but the exchange is showing that it did. Depends on how well the exchange tracks transaction confirmations. The best way to test what happened would be to type your address into a blockchain explorer such as etherchain.org and see what the actual balance is on that address.