user4912: I wondering if is there any script o smart contract example which when i send X ada to a wallet after i receive a native token

user4043: You can do this with multisignatures (no smart contract required). Because of how flexible the (e)UTXO model is, it's possible to construct a transaction that spends from two different addresses, as long as both of the parties involved sign the transaction with their signing key. Imagine party A has 10 ADA, and party B has 1 native asset lets call it XDA, the aim is for party A to buy one XDA from party B in exchange for 10 ADA.
Party A: build Tx with their own utxos as input, and as output they set 10 ADA to party B, and then they add another input using the UTXO of party B, and as output they set 1 XDA to party A address. So you get a transaction like so:
INPUTS
  partyAUtxo [containing ADA]
  partyBUtxo [containing XDA]

OUTPUTS
  10 ADA -> partyBAddress
  1  XDA -> partyAAddress

party A now signs this transaction and sends the serialized signed transaction to party B. Now party B verifies that the trade seems fair (simply checking the price is fair or whatever), signs it with their keys and submits the transaction to the blockchain.
This constructs an atomic swap in a SINGLE TX, which would require two transactions if using a smart contract (lock, and unlock).
I would include the code here, but it'd require quite a bit of code to give you a working demo so I can just guide you to checkout cardano-serialization-lib, and Nami wallet - these two libraries/APIs provide all of the above functionality in terms of getting UTXOs, constructing transactions from UTXOs with custom outputs, building/serializing the transaction, signing it with a wallet, and submitting a transaction to Blockfrost. If I get a simple demonstration of this in action soon I will update here.

4912: <p>I wondering if is there any script o smart contract example which when i send X ada to a wallet after i receive a native token</p>
 4043: <p>You can do this with multisignatures (no smart contract required). Because of how flexible the (e)UTXO model is, it's possible to construct a transaction that spends from two different addresses, as long as both of the parties involved sign the transaction with their signing key. Imagine party A has 10 ADA, and party B has 1 native asset lets call it XDA, the aim is for party A to buy one XDA from party B in exchange for 10 ADA.</p>
<p>Party A: build Tx with their own utxos as input, and as output they set 10 ADA to party B, and then they add another input using the UTXO of party B, and as output they set 1 XDA to party A address. So you get a transaction like so:</p>
<pre><code>INPUTS
  partyAUtxo [containing ADA]
  partyBUtxo [containing XDA]

OUTPUTS
  10 ADA -&gt; partyBAddress
  1  XDA -&gt; partyAAddress
</code></pre>
<p>party A now signs this transaction and sends the serialized signed transaction to party B. Now party B verifies that the trade seems fair (simply checking the price is fair or whatever), signs it with their keys and submits the transaction to the blockchain.</p>
<p>This constructs an atomic swap in a SINGLE TX, which would require two transactions if using a smart contract (lock, and unlock).</p>
<p>I would include the code here, but it'd require quite a bit of code to give you a working demo so I can just guide you to checkout <a href="https://github.com/Emurgo/cardano-serialization-lib" rel="nofollow noreferrer">cardano-serialization-lib</a>, and <a href="https://github.com/Berry-Pool/nami-wallet" rel="nofollow noreferrer">Nami wallet</a> - these two libraries/APIs provide all of the above functionality in terms of getting UTXOs, constructing transactions from UTXOs with custom outputs, building/serializing the transaction, signing it with a wallet, and submitting a transaction to Blockfrost. If I get a simple demonstration of this in action soon I will update here.</p>
