Skip to content
On this page

S1C10: Give 1 Get 1

1. Problem

You need to hold both S1C1 and S1C9 NFTs, then transfer one NFT to the challenge contract in exchange for the flag.

2. Cause

The challenge uses ERC-721 safeTransferFrom to implement a "barter" mechanism — you need to transfer a specific NFT to the contract, the contract verifies it, then mints the S1C10 flag.

3. Solution

  1. Confirm you hold the NFT tokenIds for S1C1 and S1C9
  2. Call the challenge contract's swap function to transfer the designated NFT into the contract
  3. The contract verifies and automatically mints the S1C10 flag

4. Pitfalls Encountered

NFT Ownership Confirmation: You need to find your own tokenId (S1 NFTFlags does not implement ERC721Enumerable).

5. Why the Pitfall Occurred

Season1NFTFlags only inherits ERC721 and does not include tokenOfOwnerByIndex, so you cannot query by enumeration. You need to scan the tokenId range to find the owner.

6. How to Resolve

Scan the tokenId range via ownerOf(tokenId) to find the token belonging to your address:

bash
for tid in $(seq 1 100); do
  owner=$(cast call $NFT_FLAGS "ownerOf(uint256)(address)" $tid)
  if [ "$owner" = "$MY_ADDRESS" ]; then echo "My token: $tid"; fi
done

7. Technical Takeaways

PointExplanation
ERC-721 transfersafeTransferFrom triggers the onERC721Received callback
ERC721 vs ERC721EnumerableThe non-Enumerable version does not maintain a token list and cannot be queried by index
Token Ownership ScanningBrute-force scan tokenId range to find owned tokens

Built with AiAda