<p>You could hardcode public key hash of a receiver address and then validate if outgoing transaction is going towards address with same public key hash.</p>
<p>Here is an example how that would look like in plutus code:</p>
<pre><code>...
data ContractInfo = ContractInfo
{ 
   recvPkh :: !PubKeyHash
} deriving Show

contractInfo = ContractInfo
{ 
   recvPkh = &quot;3f7846896a48c59359746ff096d63606ceb82e65900d20a9fd2b8a93&quot;
}

{-# INLINABLE mkValidator #-}
mkValidator :: ContractInfo -&gt; () -&gt; () -&gt; ScriptContext -&gt; Bool
mkValidator contractInfo@ContractInfo{..} _ _ ctx =
  any outputToCorrectAddr txOuts
 where
     info :: TxInfo
     info = scriptContextTxInfo ctx

     txOuts :: [TxOut]
     txOuts = txInfoOutputs info

     outputToCorrectAddr :: TxOut -&gt; Bool
     outputToCorrectAddr txo = case toPubKeyHash $ txOutAddress txo of
       Just pkh -&gt; recvPkh == pkh
       Nothing  -&gt; False
...

</code></pre>

CC BY-SA 4.0
2022-01-07T12:18:04.087Z
2022-01-07T12:27:11.053Z
2022-01-07T12:27:11.053Z
KugisMugis
<p>Can you manually list a wallet address in a smart contract transaction? For example lets say I create a smart contract that allows any user to send Ada to a specific address by sending it to the scripts UTXO address is this possible?</p>

<plutus><smart-contract><transaction>
Can you manually list an address in a Smart Contract
# Can you manually list an address in a Smart Contract

(Asked by: username_0 on 2022-01-05)

Can you manually list a wallet address in a smart contract transaction? For example lets say I create a smart contract that allows any user to send Ada to a specific address by sending it to the scripts UTXO address is this possible?

**Tags:** plutus, smart-contract, transaction

---

## 1 answers

### Answer by username_1 on 2022-01-07. Score: 1 | Accepted answer

You could hardcode public key hash of a receiver address and then validate if outgoing transaction is going towards address with same public key hash.
Here is an example how that would look like in plutus code:
...
data ContractInfo = ContractInfo
{ 
   recvPkh :: !PubKeyHash
} deriving Show

contractInfo = ContractInfo
{ 
   recvPkh = "3f7846896a48c59359746ff096d63606ceb82e65900d20a9fd2b8a93"
}

{-# INLINABLE mkValidator #-}
mkValidator :: ContractInfo -> () -> () -> ScriptContext -> Bool
mkValidator contractInfo@ContractInfo{..} _ _ ctx =
  any outputToCorrectAddr txOuts
 where
     info :: TxInfo
     info = scriptContextTxInfo ctx

     txOuts :: [TxOut]
     txOuts = txInfoOutputs info

     outputToCorrectAddr :: TxOut -> Bool
     outputToCorrectAddr txo = case toPubKeyHash $ txOutAddress txo of
       Just pkh -> recvPkh == pkh
       Nothing  -> False
...


---

