It depends on many factors.
-
You have included the
initState
(that is the code and data of the wallet or smart contract) alongside your transaction. In this case the smart contract is deployed first, and then it handles the incoming message. This is similar to sending the transaction to an initialized account. -
No
initState
, andbounce
flag is set. In this case, the message cannot be delivered to a smart contract and the message will be bounced back to the sender. After subtracting the consumed gas, the rest of the amount is returned back. -
No
initState
, andbounce
flag is unset. In this case, the message cannot be delivered, but it will not bounce back to the sender, and the sent amount will be accounted for the reciving address, essentially increasing its balance.
In fact, one way to deploy a wallet, is to send some TON to its address (which is not initialized yet) with the bounce
flag unset. After this step, the owner can deploy and initialize the wallet using the funds at the current unintialized address. This step usually happens on the first withdraw operation.
Wallets usually check the state of the target address and if it's not initialized, they unset the bounce
flag, so that it's not returned.
Deployment of the wallet is the act of uploading its bytecode to the blockchain. But all that is necessary for the success of the transaction is the correct TON address (for example, when using a wallet application), even if it has not been deployed.
When you send TONcoin funds to an uninitialized correct address happen something of the following events:
- The transaction will be executed and funds will store on-chain until the corresponding wallet's address will deploy. After deployment, the owner of the wallet will get funds on balance.
- The transaction will be executed and then a bounce happens - the funds(minus all message transfer and gas fees) return to the sender.
This behavior depends on the message mode of message layout.
You can learn more about deployment of TON smart contracts here.