A Caeser Cipher Quiz Gefrom a Smart Contract

Smart contracts are so cool, and where we can create code which is trustworthy, and run in a verifiable way. Our future work could create…

A Caesar Cipher Quiz Generator from a Smart Contract

Smart contracts are so cool, and where we can create code which is trustworthy, and run in a verifiable way. Our future work could create a whole governance infrastructure which could run from these magical contracts.

So, at the moment, I am moving my cipher challenge infrastructure onto smart contracts and will use smart contacts to generate questions and answers from the Ethereum blockchain.

The code I have initially designed will be a simple Caesar cipher, and where we will take a range of words, and then move these words by a given number of places:

In this case, we have two public methods: generate(), and caeser(). With generate() we will generate a new cipher challenge, and with the random shift value, and to show the shifted version and the solution. With caeser() we pass in a string, and then the shift value, and will return the cipher.

We can first use Remix to enter the code and compile:

If successful we can startup Ganache, and run our local blockchain:

Next, we can deploy our compiled smart contract:

We should find that the first account will have spent some gas to create the contract:

and that a contract has been created:

Next, we can test:

The result when we select generate() is:

Can you find the UK town/city for the Caeser cipher of cjsnjohibn  The answer is birmingham

Now we can test the other function:

The result for two shifts for “Edinburgh” is:

gfkpdwtij

Now, we can move to a test network. We now select “Injected Web3” and the Ropsten network, and link our Metamask wallet:

We then deploy the contract to the test network:

And which should then be mined and deployed:

We can then go to the contract on the test network:

and view it [here]:

Next we must verify and publish the contract:

And define things like our compiler version (0.8.0):

And then paste in the code we used:

and then a successful build:

And showing the code [here]:

We can now test on the test network:

And it all works!