Deploying a Scrambled Alphabet Generator To Ethereum (With Ganache and Ropsten)

There is a great deal of excitement about the new Proof of Stake (PoS) methods to be used in Ethereum. If it works, it will create a…

Deploying a Scrambled Alphabet Generator To Ethereum (With Ganache and Ropsten)

There is a great deal of excitement about the new Proof of Stake (PoS) methods to be used in Ethereum. If it works, it will create a revolution in the creation of truly distributed and trusted applications. We “should” see performance improve and gas prices drop. This will open up a whole new world of trusted code. So, don’t just talk about blockchain … do it, and just follow me!

Building and deploying for local testing

I love using Ethereum. It pushes me to think simply about the code used, and to be efficient. It almost takes me back to the days of assembly language coding. So, let’s create a scrambled alphabet application and test it locally, and then deploy it to a test network (Ropsten).

First we start with Remix (https://remix.ethereum.org) and enter our code:

The code I have used is here:

This basically randomly selects from five phrases and then scrambles the alphabet with 26 random moves of the characters in the alphabet.

We now need to get our local blockchain. One of the best is ganache [here]. Once installed, we then start it to test locally:

We then deploy our smart contract:

And which will cost us some gas (0.02 ETH):

We can now test our smart contract:

The output is:

Find the message from: 
ihm vninzm wv ihm poimzomi, maumxpqssr po mfuqogpob ihm zqobm wv quuspxqipwoa, podwsdma q tnxh gmmumz gmbzmm wv uzpdqxr, qog qnihmoipxqipwo.
The mapping is: 
abcdefghijklmnopqrstuvwxyz 
qkxgmvbhplestowujzaindyfrc

We see that ‘i’ maps to ‘t’, an ‘h’ maps to ‘h’, and an ‘m’ to an ‘e’. Thus “ihm” maps to “the”, and the full message is

The future of the Internet, especially in expanding the range of applications, involves a much deeper degree of privacy, and authentication.

Building and deploying for Ropsten

And so we have successfully locally. Now let’s deploy it to the Ropsten test network. For this, you will need to install the Metamask wallet [here], and get some free Ether for it [here]. Note, that this is not real ether, so it will not cost you anything.

Once the wallet is installed, we now select the environment to be “Injected Web3” and which will link to our Metamask wallet: (just check the address for the account is matched to your Metamask ID):

We then deploy:

And wait for it to be mined:

And then it will get deployed:

Our contract is then verified:

And is deployed [here]:

Next we need to verify the contract: [here]

We then click on ‘Verify and Publish’ and then add the details about the smart contract (such as the compiler we have used):

We then add the code:

And we get a successful deployment [here]:

Now we can test it again on the Ropsten network:

In this case we get:

Find the  message from: 
ngp lrnrvp ca ngra nmeyvua uyny phdvfbncmh egcdg ca ngp adcphdp ml dvfbnmovybgcda, yhu bvmxcupa y zpdgyhcaz lmv nem phncncpa nm dmzzrhcdynp apdrvpwf ecng yhf mngpv phncnf kpcho ykwp nm vpyu ngpcv zpaayopa.
The mapping is: 
abcdefghijklmnopqrstuvwxyz
ykduplogcjtwzhmbsvanrxeqfi

And where ’n’ is ‘t’, ‘g’ is ‘h’, and ‘p’ is ‘e’. We can reset, and try again:

This time we get:

And so our smart contact is working. If we now want to deploy the mainnet, we just select one of the “JavaScript VM” options, and deploy:

The smart contract is here, if you want to play with it:

https://ropsten.etherscan.io/address/0x2b7447bb366d5b710cb9b61d92226b42855c3421#readContract

Conclusions

The testing of the roll-out of PoS on Ethereum started yesterday, and all was looking good. If successful, we will see the seven-year-old network transform itself into one of the greatest computation engines ever created, and be ready to take on the challenges of transforming the flawed Internet that we have created. Finally, we will start to see the old Internet decay — with its centralised approach and old protocols — and a new one arise.

So, as I said, go and try it yourself, and build up your own opinion. Nothing better than creating your own smart contract for seeing how it works.