Adding a puzzle
We're going to make a new puzzle, which means we need to provide the smart contract with a set of clues and info about the answers.
Of course, we'll not be sending the answers to the smart contract, otherwise everyone could see. We will, however, send details about each clue, including:
- The clue number
- Whether it's a down or across clue
- The coordinates (x and y position)
- The length of the clue. (How many letters)
Essentially, we're going to tell the smart contract enough information for an empty puzzle like this:

(Note that we aren't showing the human-readable clues in the above screenshot, but we will provide that as well.)
#
Building and deployingLet's use the same steps we learned from the first chapter:

Navigate to the contract
directory, then run the build script for your system:
If following from the previous chapter, you'll likely have a subaccount already created. For the purpose of demonstration, we're calling the subaccount (where we deploy the contract) crossword.friend.testnet
and the parent account is thus friend.testnet
.
Let's delete the subaccount and recreate it, to start from a blank slate.

Here's how to delete and recreate the subaccount using NEAR CLI:
Now we're ready to construct our new crossword puzzle and add it via the new_puzzle
method. Let's start with the clues for this new puzzle.
#
The cluesWe're going to use these clues below for our improved puzzle. The Answer column will not get sent to the smart contract when we call new_puzzle
.
Number | Answer | Clue | (x, y) coords | length |
---|---|---|---|---|
1 | paras | NFT market on NEAR that specializes in cards and comics. | (1, 1) | 5 |
2 | rainbowbridge | You can move assets between NEAR and different chains, including Ethereum, by visiting __.app | (0, 2) | 13 |
3 | mintbase | NFT market on NEAR with art, physical items, tickets, and more. | (9, 1) | 8 |
4 | yoctonear | The smallest denomination of the native token on NEAR. | (3, 8) | 9 |
5 | cli | You typically deploy a smart contract with the NEAR ___ tool. | (5, 8) | 3 |
The x and y coordinates have their origin in the upper-left side of the puzzle grid, and each row and column start at 0.
#
Solution hashLet's derive the sha256 hash using an easy online tool (there are many other offline methods as well) to discover the solution hash:
#
Add the puzzleAdd a new puzzle using NEAR CLI with this long command, replacing crossword.friend.testnet
with your subaccount:
Note that our contract name and the account we're calling this from are both crossword.friend.testnet
. That's because we added a check at the top of new_puzzle
to make sure the predecessor is the owner_id
.
Now our smart contract has information about this second crossword puzzle.
Let's explore how to make our frontend have a login button and truly turn this into a decentralized app (dApp)!