Punk Ownership

Remember the section on Mappings? In it we learned what it means to own a punk. Let's recap real quick:

As an example, we looked at this table:

Punk uintOwner address
00xe08c32737c021c7d05d116b00a68a02f2d144ac0
10xb88f61e6fbda83fbfffabe364112137480398018
20x897aea3d51dcba918c41ae23f5d9a7411671dee0

Every punk token id is mapped to an owner. In Solidity code, this mapping looks like this:

// Keeps track of which punk (uint) belongs to which account (address)mapping (uint => address) public punkIndexToAddress;

If we were to access the punk owner we'd write:

// Get the address of the owner of punk #0address punkOwner = punkIndexToAddress[0];

And in order to set the owner of a punk, we could do the following:

address newOwner = 0xb88f61e6fbda83fbfffabe364112137480398018;uint punkId = 0;// Set owner of punk #0 to 0xb88f6...398018punkIndexToAddress[punkId] = newOwner;

To summarize, we have a Mapping of a uint (unsigned integer) which is the punk identifier, to an address, which is the identifier of an owner. We can access and write to this data store.

We can actually query live punk ownership data from the blockchain from this very mapping! Go to the CryptoPunksMarket contract page on Etherscan, click "Read Contract", and then type a punk id into the 7. punkIndexToAddress field. It will show the address of current owner of the given punk.

Query punk ownership on Etherscan.

To double check, head over to other interfaces like OpenSea or the official CryptoPunks Website to verify that all are showing the same result...