QuickNode
Published in

QuickNode

Run your own Ethereum Node

Helping developers to build high-performance DApps quickly

QuikNode

What is Quiknode?

With the evolution of Web3, developers are rapidly building decentralized applications on Ethereum. Building Dapps on Ethereum is cool, though it comes with some infrastructure setup drawbacks. You need to set up a node to interact with the blockchain — and this setup needs time, infra and skills. QuikNode solves this problem by providing Ethereum node as Service. As QuikNode website quotes:

“The fastest and easiest way to run your own Ethereum node.”

Why you should use QuikNode?

Running your own private Ethereum node is cumbersome. There are three problems with that:

  • Infra — Blockchains are distributed Ledgers and a full node means the entire copy of the ledger, that maybe not possible on the home computer anymore as ethereum blockchain size is around 670 GB now, even fast sync is now around 120 GB.
  • Time — First time syncing takes time and syncing ethereum main net can take days, depending on the internet speed, cpu, and disk speed.
  • Skills — The most concerning part is the security of the node. You need to have some cybersecurity skills to secure your node.

What QuikNode provides?

QuikNode solves this problem by providing you a full node on a click of a button. Instead of using shared public nodes, QuikNode provides you a dedicated node. QuikNode is optimized for performance, speed, and flexibility. Let's see how QuikNode achieves this.

Dedicated Node- With the use of dedicated nodes helps you increase performance for your blockchain queries as it’s only taking queries for your DApp.

Multiple Zones- QuikNode supports 8 different Zones. That helps in optimizing networks call time which boosts speed and performance for your DApp.

Multiple Testnet support — QuikNode support almost all famous ethereum testnets. That gives immense flexibility to a developer by testing application on their preferred testnet.

Archive Nodes — QuikNode provide Parity archive nodes too. An archive node keeps full copy of blockchain ledger in comparison to full nodes who may do pruning for obvious infra reasons. This is very important feature for businesses benefit from blockchain analysis and research. You can learn more about QuikNode archive nodes here.

Also, QuikNode support Parity and Geth both client. Isn’t it cool? 😃

Signing up with QuikNode

Let’s sign up for the QuikNode. Once you have done with the registration, you can configure your node. You can choose Network, Zone, Client, and Synchronization mode. You will see a link for your Node something like this. Bookmark it and don’t share it with anyone.

https://quiknode.io/node/86d9e35e-8cdb-47ad-80a4-84f9e9537afa/A-cU-9vjaepXeR6qPC8eOg==

Once you Logged in you can see a dashboard, something like this.

Connecting with QuikNode?

I have created a Kovan Testnet and my zone is Bangalore (India). Remember, your node has to be in READY, otherwise, it will not work. You can rebuild your node or contact QuikNode team if you face any problem.

Connection URI

Quiknode supports both HTTPProvider and Websockets(we will see them later). You can find these links by clicking on your node from the dashboard.

Now Let’s deep dive in some code.

Sending Ethereum transaction using web3js and QuikNode

Let's test QuikNode and see how it works. To start, let’s broadcast a raw transaction with QuikNode using web3js.

Let’s create a node js project and install Web3js. Create a project directory and run below commands.

mkdir quiknode
cd quiknode
npm init
npm install web3

Setup Web3 using QuikNode

Let’s create an Index.js file and setup web3. As you can see we add using QuikNode HttpProvider link. We will connect to our node using this link. Now all the commands we will run will be going through this node and will use Kovan Network.

const Web3 = require('web3')const httpProvider = "https://mistakenly-smart-jay.quiknode.io/86d9e35e-8cdb-47ad-80a4-84f9e9537afa/C0_tKUunhUc0rM_i1HMxHA==/"var web3 = new Web3(new Web3.providers.HttpProvider(httpProvider));

To test the network add these line and check the network id, Kovan network Id is 42.

web3.eth.net.getId(function(err, data){
console.log(data);
})

Creating an account

Let’s create a new ethereum account on Kovan network.

var addressData =web3.eth.accounts.create(web3.utils.randomHex(32));console.log(addressData);

This will give us a private key and address, using which we will create a raw transaction.

You can check the balance using below

web3.eth.getBalance('0x75E18d32f2DbEEfaF4055aD709BDe98eCB57C379', (err, wei) => {balance = web3.utils.fromWei(wei, 'ether')console.log(balance);});

Signing an Ethereum transaction

Let’s get some Test ethers using Kovan network faucet and sign a transaction. Ethier, you can generate a new address as a recipient or just use any address from Kovan block explorer.

web3.eth.accounts.signTransaction({
from: address, // our address
to: address2, // any other kovan network address you want to send
value: '2000000000000000',
gas: '8000000'
}, privateKey, function(err, data) {
console.log(data);
});

Sending transaction

Now let’s broadcast this signed transaction using QuikNode.

web3.eth.accounts.signTransaction({
from: address,
to: address2,
value: '2000000000000000',
gas: '8000000'
}, privateKey, function(err, data) {
web3.eth.sendSignedTransaction(data.rawTransaction, function(err, receipt) {
console.log("receipt", receipt);
web3.eth.getTransaction(receipt, function(err, data) {
console.log("transaction", data);
})
});
});

We have successfully sent a transaction using QuikNode on Kovan network, you can check this transaction on Kovan block explorer.

Using WebSockets with QuikNode

QuikNode supports WebSockets too. You can find a web socket connection link under Dev Tools. Either you can use it with HTTPs Auth or Token Auth. Token auth link will look like something below.

- Token auth: wss://mistakenly-smart-jay.quiknode.io/86d9e35e-8cdb-47ad-80a4-84f9e9537afa/C0_tKUunhUc0rM_i1HMxHA==/

WebSockets allow both the server and the client to push messages at any time without any relation to a previous request as opposed to HTTP where the client creates a connection with the server every time. In WebSocket connection get created once, server and client push messages using the connection. Websockets are best for an event-based system. Websockets are supported by almost every browser.

Image source

Subscribing pending Transaction events

Let’s subscribe pending transaction of Ethereum blockchain. You can see we are passing QuikNode WebSocket URI while initializing web3.

const Web3 = require('web3')
const webSocket = "wss://mistakenly-smart-jay.quiknode.io/86d9e35e-8cdb-47ad-80a4-84f9e9537afa/C0_tKUunhUc0rM_i1HMxHA==/"
var web3 = new Web3(webSocket);
var subscription = web3.eth.subscribe('pendingTransactions', function(error, result) {
if (!error)
console.log(result);
})
.on("data", function(transaction) {
console.log(transaction);
});

QuikNode with Truffle

Let’s see how we’ll use QuikNode with Truffle and deploy smart contracts. So for that lets download Truffle Petshop. We will simply unbox it and deploy it using QuikNode.

truffle unbox pet-shop 

We will use truffle-HD-wallet to deploy our pet-shop smart contracts. So you need to install it too.

npm install truffle-hdwallet-provider

Now let’s see the configuration of our Truffle’s config. We will simply add HttpProvider URI to use QuikNode as mentioned below.

var HDWalletProvider = require("truffle-hdwallet-provider");var mnemonic = "YOUR_MEMONICS"; // use a funded walletmodule.exports = {
networks: {
development: {
host: "127.0.0.1",
port: 7545,
network_id: "*" // Match any network id
},
kovan: {
provider: function() {
return new HDWalletProvider(mnemonic, "https://mistakenly-smart-jay.quiknode.io/86d9e35e-8cdb-47ad-80a4-84f9e9537afa/C0_tKUunhUc0rM_i1HMxHA==/")
},
network_id: 42
}
}
};

QuikNode Features

So now let's check out QuikNode’s features:

Analytics

See what your node is doing with detailed call/request metrics:

Security

Lock down (or open up) your endpoint. Use a custom domain if you want!

Ethereum WebHooks

Monitor smart-contracts for events and get notified in real-time with zero code — just 5 minutes for setup!

Conclusion

QuikNode is an awesome and useful addition to the Ethereum ecosystem. It’s fast and completely private. Many high performances DApps will end up running their own node for better performance. Now they don’t need to set up, nor manage, nor scale their node infrastructure.

Need help with your project or have questions? Contact us (hi@quiknode.io), on Twitter @QuikNode or ping us on DISCORD!

Note: Mentioned QuikNode links will not work, my QuikNode subscription is expired.

--

--

--

A platform to access ETH, BTC, BSC, MATIC, OPTIMISM, ARBITRUM, FTM, CELO, SOL, TERRA & xDAI blockchains via API. Infra & tools to build + scale your #Web3 dApp!

Recommended from Medium

Some Potentially Huge News for Flow Developers!

ZYX DeFi

Credenciales bibliotecarias desarrollado con Blockchain, primer piloto del mundo, IFLA 2019, Grecia

New Careers Emerging In The Blockchain Industry And The Cryptosphere

Do copyrights on NFT exist?

The advantages of a blockchain-based on a Proof-of-Stake algorithm

Collaboration with Pictosis

Aurigami’s Papermill — Opening Soon

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Gaurav Agrawal

Gaurav Agrawal

Telegram @gaurav_zen , Editor — Coinmonks publication (medium.com/coinmonks) and working on (https://coincodecap.com)

More from Medium

A Truly Beginner’s Guide — Ethereum (Part 2)

How to Submit Your Smart Contracts to Etherscan

What Are Flash Loans?

How to connect Infura to Web3j