<p>Each change in state in the auction contract passes a new datum (arbitrary data). The auction datum is made up of the 'Auction' and 'Bid' records. The bid record has a 'bBidder' field which is the public key of the bidder. You can't see this in the playground because the actual datum value isn't stored on-chain, the hash is which allows others to validate. When a validator (or the simulator) calculates the highest bidder, it does it from the start based off the series of eUXTOs'.</p>
<p>As to how does the auction example know who started the bid? When a new eUXTO is added to the series of bids, the validator calculates the previous bids up to the current one, in order to discover the datum. This datum is then used in the contract script again to place the next bid.</p>
<p>The reason this can be done is because the result is entirely deterministic. Based off the same inputs (transactions in/endpoints), you'll get the same output.</p>

CC BY-SA 4.0
2022-01-14T05:15:37.340Z
Welcome to Cardano SE! As a new user be sure to take the [Tour].
gRebel
CC BY-SA 4.0
2022-01-14T14:21:19.747Z
OK, the datum is not shown in the explorer/playground - that was not clear to me. (I thought it would show the datum, since it does show the some other values, such as how much Ada and T it has in it's state).
btw, if the actual datum value isn't stored onchain, it's stored offchain, right? Where exactly is it stored? (Is it on 1 place, which doesn't seem like a good idea to me, or is it also somehow redundant?)
Kurt Sys
CC BY-SA 4.0
2022-01-14T14:24:17.240Z
The datum isn't stored anywhere. The hash of the datum is stored on-chain. Because Plutus is deterministic, whenever a node is trying to run your request, it can re-calculate the datum.
micahkendall
CC BY-SA 4.0
2022-04-01T06:53:18.743Z
Since I previously mentioned that datums are never stored on-chain, I thought it relevant to note that Post-CIP32 (coming June/Oct), this will no longer be true, and it will be possible to store datums on-chain.
micahkendall
CC BY-SA 4.0
2022-01-13T14:23:43.637Z
2022-01-14T14:29:06.250Z
2022-01-14T14:29:06.250Z
micahkendall
<p>In the second transaction of the auction example, these are the output EUTxO's. In the final transaction, only wallet 1 and the script are inputs. How does the script know that wallet 3 has done the highest bid? I would expect that the script also stores 'wallet 3' as data, so it's known who had done the bid.
Or, in the closing Tx, how does the script know that wallet 3 did the bid (from the playground, this doesn't seem to be stored.)</p>
<p><a href="https://i.sstatic.net/XIHpF.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/XIHpF.png" alt="output of 2nd transaction in the auction example" /></a></p>

CC BY-SA 4.0
2022-01-14T04:38:29.323Z
Welcome to Cardano SE! As a new user be sure to take the [Tour].
gRebel
<eutxo><datum><redeemer>
How does the final transaction in the auction example know who did the bid?
# How does the final transaction in the auction example know who did the bid?

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

In the second transaction of the auction example, these are the output EUTxO's. In the final transaction, only wallet 1 and the script are inputs. How does the script know that wallet 3 has done the highest bid? I would expect that the script also stores 'wallet 3' as data, so it's known who had done the bid.
Or, in the closing Tx, how does the script know that wallet 3 did the bid (from the playground, this doesn't seem to be stored.)

[![output of 2nd transaction in the auction example](https://i.sstatic.net/XIHpF.png)](https://i.sstatic.net/XIHpF.png)

**Tags:** eutxo, datum, redeemer
> **Comments:**
> **username_1**: Welcome to Cardano SE! As a new user be sure to take the [Tour].  

---

## 1 answers

### Answer by username_2 on 2022-01-13. Score: 1

Each change in state in the auction contract passes a new datum (arbitrary data). The auction datum is made up of the 'Auction' and 'Bid' records. The bid record has a 'bBidder' field which is the public key of the bidder. You can't see this in the playground because the actual datum value isn't stored on-chain, the hash is which allows others to validate. When a validator (or the simulator) calculates the highest bidder, it does it from the start based off the series of eUXTOs'.

As to how does the auction example know who started the bid? When a new eUXTO is added to the series of bids, the validator calculates the previous bids up to the current one, in order to discover the datum. This datum is then used in the contract script again to place the next bid.

The reason this can be done is because the result is entirely deterministic. Based off the same inputs (transactions in/endpoints), you'll get the same output.

> **Comments:**
> **username_1**: Welcome to Cardano SE! As a new user be sure to take the [Tour].  
> **username_0**: OK, the datum is not shown in the explorer/playground - that was not clear to me. (I thought it would show the datum, since it does show the some other values, such as how much Ada and T it has in it's state). btw, if the actual datum value isn't stored onchain, it's stored offchain, right? Where exactly is it stored? (Is it on 1 place, which doesn't seem like a good idea to me, or is it also somehow redundant?)  
> **username_2**: The datum isn't stored anywhere. The hash of the datum is stored on-chain. Because Plutus is deterministic, whenever a node is trying to run your request, it can re-calculate the datum.  
> **username_2**: Since I previously mentioned that datums are never stored on-chain, I thought it relevant to note that Post-CIP32 (coming June/Oct), this will no longer be true, and it will be possible to store datums on-chain.  

---

