BLOG
BLOG
  • Design
  • Data
  • Discernment

We believe in AI and every day we innovate to make it better than yesterday. We believe in helping others to benefit from the wonders of AI and also in extending a hand to guide them to step their journey to adapt with future.

Know more

Our solutions in action for customers

DOWNLOAD

Featured Post

MENU

  • Visit Accubits Website.
  • Artificial Intelligence
  • Blockchain
  • Cloud Computing
  • Entertainment
  • Fintech

How to set up Ropsten testnet for your smart contract

  • mm
    by Crissi Robert on Fri Aug 17

Back in 1994, when Nick Szabo — a computer scientist and cryptographer from the United States developed the concept of smart contracts, probably no one had expected the disruption it is making to many industries today. A smart contract is simply a computer code running on top of a blockchain containing a set of rules under which the parties to that smart contract agree to interact with each other. If and when the pre-defined rules are met, the agreement is automatically enforced. The smart contract code facilitates, verifies, and enforces the negotiation or performance of an agreement or transaction. It is the simplest form of decentralized automation, which is the essence of every dApps we have today.

Businesses which offers dApps need to deploy their application on top of a blockchain network. However, when a smart contract is deployed to the network, it is not possible to make any modifications to the program. This makes it impossible to fix any bugs or vulnerabilities found in the contract code after it is deployed. Moreover, the successful execution of the contract for any transaction requires a gas fee. This, in turn, makes the testing a costly practice. This is where the need of a test net is at its peak.

Test net allows one to deploy the smart contract code so as to test the program to identify the bugs and vulnerabilities. In Testnets, the developers can upload and interact their contracts without paying any cost of gas.

Testnets hold numerous benefits for the user, the major one being the freedom of testing. Testnets doesn’t charge its user any gas fee for the testing of their smart contacts. Usually, on an Ethereum network, the developers have to pay a rent to run contract. However, Testnets provide an unlimited gas facility which helps the developer try without paying for it.  And most importantly Testnets provide a viable means of verification of contract credentials and thereby it eliminates any post-production issues of smart contracts.

Thinking how to improve your business operations?

Reach out to us today, discuss with our experts!

Contact us

Testnet helps you kick the tires before real assets are involved, this optimizes the exchange process. The quick processing feature of Testnets helps the user save time. Usually, an Ethereum network takes about 20 seconds to process a transaction, whereas the Testnets does it nearly in the fraction of a second.  Ropsten Testnet is an essential Ethereum network with free ETH. Ropsten Testnet is a proof-of-work blockchain that most closely resembles Ethereum.

Ropsten Testnet is the most popular testnet which is used during the later stage of contract development. They are basically a testing network, used for testing purposes before deploying to the main network(Mainnet). Geth is one of the Ethereum client useful for connecting to testnets. In this article, we’ll see how to sync your client with Testnet more quickly.

Given below are the step-by-step process to setup Ropsten Testnet with Geth version 1.6.5

Step 1:
Download the genesis file for ROPSTEN-Revival.
Here’s a snippet of Geth’s Ropsten genesis file :-

{
"config": {
"chainId": 3,
"homesteadBlock":0,
"eip150Block":0,
"eip155Block":10,
"eip158Block":10,
"eip160Block":10
},
"nonce": "0x0000000000000042",
"alloc": {
"0x0000000000000000000000000000000000000011": {
"balance": "0"
}
}
"timestamp": "0x00",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"extraData": "0x3535353535353535353535353535353535353535353535353535353535353535",
"gasLimit": "0x1000000",
"difficulty": "0x100000",
"mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x0000000000000000000000000000000000000000"
}

Initialize a new block and definition for the ROPSTEN network using the following command:
geth –datadir /path/to/testnet/data init genesis.json

Step 2:

The next step includes the downloading of blocks.Normally the blockchains can be synced using two modes. They are:

  1. Normal Syncing
  2. Fast Syncing (using –fast flag)

According to Homestad guide: The fast flag enables fast synching through state downloads rather than downloading the full block data. This will also reduce the size of your blockchain dramatically.
NOTE: — fast can only be run if you are syncing your blockchain from scratch and only the first time you download the blockchain for security reasons.
Along with the –fast flag, there is this another flag called –cache which helps to sync your client more quickly. The cache flag is used to change the default alloted memory for a fast sync.

From Homestad guide: Megabytes of memory allocated to internal caching (min 16MB / database forced). The default is 16MB, so increasing this to 256, 512, 1024 (1GB), or 2048 (2GB) depending on how much RAM your computer has should make a difference.

Thinking how to improve your business operations?

Reach out to us today, discuss with our experts!

Contact us

Command for syncing:-

geth --datadir /path/to/testnet/data --networkid=3 –-syncmode=fast –-cache=1024 console

Points to be noted:-
The command eth.blockNumber is used to verify the number of blocks downloaded. But the ‘Loaded most recent local full block’ will always show ‘0’, which means that your blocks are not being downloaded. It will only show the correct number of blocks once all the blocks are downloaded.

INFO
[06-15|15:54:56] Loaded most recent local header
number=1121759 hash=bdf4d6…ebcdec td=747686182747507
INFO
[06-15|15:54:56] Loaded most recent local full block number=0
hash=419410…ca4a2d td=1048576
INFO [06-15|15:54:56] Loaded most
recent local fast block number=1121676 hash=80f4d5…3ed841
td=747645006524095
After the completion of block synchronization you can find the difference.
INFO [06–16|11:00:58] Loaded most recent local header number=1126948 hash=4ae28e…360ad2 td=750432339366550
INFO [06–16|11:00:58] Loaded most recent local full block number=1126948 hash=4ae28e…360ad2 td=750432339366550
INFO [06–16|11:00:58] Loaded most recent local fast block number=1126948 hash=4ae28e…360ad2 td=750432339366550
WARN [06–16|11:00:58] Blockchain not empty, fast sync disabled

Here, you’ll find the ‘Loaded most recent local full block’ from ‘0’ to the latest block number.At the end, one more message is shown that is fast sync being disabled

Related Posts

Drive into stories worth discussing

  • mm
    Will Hashgraph Replace Blockchains?
    Rahul A R
  • mm
    What is a Predictable Gas Fee, and how it works?
    Rahul A R
  • mm
    How Blockchain Can Perfect Green Bonds?
    Rahul A R
  • mm
    How can Blockchain aid the Circular Economy Model?
    Rahul A R

ASK AUTHOR

mm
Crissi Robert

Crissi Mariam Robert is a mean stack developer who specializes in Blockchain technology. Having her expertise in Ethereum, Hyperledger ... Read more

Ask A Question
Error
Cancel
Send

Categories

View articles by categories

  • Blockchain
  • General

Subscribe now to get our latest posts

  • facebook
  • linkedin
  • twitter
  • youtube
All Rights Reserved. Accubits Technologies Inc