Skip to content
- Tutorials
- Python Tutorial
- Taking Input in Python
- Python Operators
- Python Data Types
- Python Loops and Control Flow
- Python Functions
- Python OOPS Concept
- Python Data Structures
- Python Exception Handling
- Python File Handling
- Python Exercises
- Java
- Java Programming Language
- Java Collections
- Java 8 Tutorial
- Java Programs
- Java Interview Questions
- Java Exercises
- Java Quiz
- Java Projects
- Advance Java
- Programming Languages
- System Design
- Interview Corner
- Computer Science Subjects
- DevOps
- Linux
- Software Testing
- Databases
- Android
- Excel
- Mathematics
- Python Tutorial
- DSA
- Data Structures
- Algorithms
- Analysis of Algorithms
- Searching Algorithms
- Sorting Algorithms
- Greedy Algorithms
- Dynamic Programming
- Graph Algorithms
- Pattern Searching
- Recursion
- Backtracking
- Divide and Conquer
- Mathematical Algorithms
- Geometric Algorithms
- Bitwise Algorithms
- Randomized Algorithms
- Branch and Bound
- Algorithms Tutorial
- DSA Tutorial
- Practice
- All DSA Problems
- Problem of the Day
- Company Wise Coding Practice
- GfG SDE Sheet
- Practice Problems Difficulty Wise
- Language Wise Coding Practice
- Curated DSA Lists
- Competitive Programming
- Company Wise SDE Sheets
- DSA Cheat Sheets
- Top Interview Questions
- Puzzles
- Data Science
- Web Tech
- Courses
-
Last Updated : 21 Jul, 2024
Summarize
Comments
Improve
Blockchain technology in simple words is a digital database where information or data is stored in blocks that are linked together to form a chain. This Blockchain Tutorial covers all basic to advanced topics of blockchain like cryptography, Blockchain Algorithms, Blockchain Architecture, Blockchain Security, Smart Contracts, etc.
Table of Content
- What is Blockchain?
- Why Do We Use Blockchain?
- Introduction to Blockchain Technology
- Cryptography
- Consensus Algorithms
- Blockchain Architecture
- Blockchain and Cryptocurrency
- Smart Contracts and Decentralized Applications (DApps)
- Blockchain Security
- Blockchain Applications
- Blockchain Implementation
- Miscellaneous
- Interview Questions
What is Blockchain?
A Blockchain is a digital ledger of transactions that is secure, immutable, and decentralized. It consists of a chain of blocks and each block contains a secure group of transactions of money, bitcoins, contracts, property, etc. without any need for third-party middle-man such as central authorities, banks, government, etc. Transactions are verified by a network of computers. Once a block of information is created in the chain, it can’t be changed or deleted. This makes the blockchain very secure and trustworthy. It is a software protocol, it never runs without the internet.
A Blockchain is a chain of blocks that contains information about transactions. On completion of a transaction, it will go to the blockchain’s permanent database. It is mainly used for secure transactions without any third-party involvement in between. To visualize blocks, transactions, and blockchain network metrics,you can use blockchain explorer.
Why Do We Use Blockchain?
Blockchain is a distributed digital ledger of transactions. It changes the whole concept of the transaction now we don’t have any need for centralized authorities to verify our transactions, blockchain makes it decentralized and secure. The security is maintained by cryptographic processes performed by p2p users, through the process called Data mining Here are some important features given below:
- Secure
- Transparent
- Tamper-proof
- Peer-to-peer transaction
Recent Articles on Blockchain
Introduction to Blockchain Technology
- Introduction to Blockchain Technology
- History of Blockchain
- Features of Blockchain
- Important Blockchain Terminologies
- Different Versions of Blockchain
- Types of Blockchain
- Public Blockchain
- Private Blockchain
- Hybrid Blockchain
- Consortium Blockchain
- Applications of Blockchain
- Advantages and Disadvantages of Blockchain
- Benefits of Blockchain Technology
- How Does the Blockchain Work?
- Need of Blockchain
- Peer-to-Peer Network
- What is Decentralization?
- What is Ledger?
- What is Blockchain Distributed Ledger?
- Difference between Centralized and Distributed Ledgers
- Difference between Public and Private Ledgers
Cryptography
- Cryptography and its Types
- Cryptography in Blockchain
- Blockchain Hash Function
- Blockchain – Block hashing
- How Block Hashes Work in Blockchain
- What is Digital Signature?
- Blockchain – Public Key Cryptography
- Blockchain – Private Key Cryptography
- Blockchain Merkle Trees
- What is Cryptographic Primitive in Blockchain?
- Blockchain – Elliptic Curve Cryptography
- How to Create a Public/Private Key Pair?
- Blockchain – Encrypt & Decrypt Files With Password Using OpenSSL
- Blockchain – Elliptic Curve Digital Signature Algorithm (ECDSA)
- Blockchain Resolving Conflicts
- Applications of hom*omorphic Encryption in Blockchain
Consensus Algorithms
- Consensus Algorithms in Blockchain
- Blockchain Proof Of Work
- Proof of Work Consensus algorithm
- Proof of Burn Consensus Algorithm in Blockchain
- Proof of Stake (PoS) in Blockchain
- Byzantine Generals Problem in Blockchain
- Cryptographic Consensus Mechanisms in Blockchain
- Delegated Proof Of Stake (DPoS)
- practical Byzantine Fault Tolerance(pBFT)
Blockchain Architecture
- Blockchain Structure
- Genesis Block in Blockchain
- Candidate Block in Blockchain
- Actors Involved in Blockchain Solution
- Blockchain Transaction Life-cycle
- Blockchain Forks
- Blockchain and Block Header
- Components of Blockchain Network
- Blockchain Incentives to Miners
- Core Component of Blockchain
- Blockchain Protocols and Their Working
- Blockchain – Resolving Conflicts
- What is Blockchain Authentication?
Blockchain and Cryptocurrency
- What is Blockchain Cryptocurrency?
- Cryptocurrencies Benefits
- How are Cryptocurrencies created
- What is a Cryptographic Token
- Non-Fungible Tokens (NFTs)
- What is Cryptoeconomics?
- What is an ICO?
- Generalized Proof-of-Stake Mining in Cryptocurrencies
- Blockchain – Electronic Cash
- What is Blockchain Wallet and How does it work
Smart Contracts and Decentralized Applications (DApps)
- What is Ethereum
- Components of the Ethereum Network
- Difference between Ethereum and Bitcoin
- What is Ether
- Ethereum Accounts
- Nodes and Clients in Ethereum
- What is Ethereum Virtual Machine
- Ethereum – Gas and Fees
- What is a Smart Contract
- How to Test a Smart Contract for Ethereum?
- How to Simply Deploy a Smart Contract on Ethereum
- Hello World – Smart Contract in Remix-IDE
- Decentralized Apps (dApps) in Blockchain
- What is an Ethereum API
- Pros and Cons of Dapps
- What is a Dao?
Blockchain Security
- Blockchain and Data Privacy
- Blockchain and KYC
- Role of Blockchain in Cybersecurity
- Blockchain to Secure IoT Data
Blockchain Applications
- Applications of Blockchain in Data Management
- Top Applications of Blockchain in the Real World
- Benefits and Applications of Blockchain in Cloud Computing
- Integration of Artificial Intelligence and BlockChain
- How Blockchain Can Change the Future of Banking?
- Blockchain – Into the Future
- Blockchain in Genomics
- Integration of Blockchain and AI
- Use Cases of BlockChain in different fields
- Role of Blockchain in Sustainable Development
- Applications and Uses of Blockchain
- Benefits of Blockchain in Healthcare
- Decentralized Voting System Using Blockchain
Blockchain Implementation
- Create a simple Blockchain using Python
- Implementation of Blockchain in Java
- Build a To-do List Web Application Powered by Blockchain
- Flutter and Blockchain – Hello World Dapp
- Blockchain Gaming: Part 1 (Introduction)
- How to Use GANACHE Truffle Suite to Deploy a Smart Contract in Solidity (Blockchain)?
- How to Use MetaMask to Deploy a Smart Contract in Solidity (Blockchain)?
- Build an Authentication Using the Blockchain
Miscellaneous
- Public Blockchain vs Private Blockchain
- Blockchain vs Database
- Proof of Work (PoW) vs Proof of Stake (PoS)
- DAG vs Blockchain
- Hot Wallets vs Cold Wallets in Blockchain
- Bitcoin vs Cryptocurrency
- Full Payment Verification vs Simple Payment Verification in Blockchain
- Bitcoin vs Blockchain
- Hyperledger vs Ethereum
- Blockchain vs Hashgraph
- Quorum Blockchain
- What is EOS Blockchain?
- DAO(Decentralized Autonomous Organization) in Blockchain
- What’s the connection between Java and Blockchain?
- Top 10 Programming Languages for Blockchain Development
- How does Blockchain support Crowdfunding?
- Blockchain Interoperability
- Why Blockchain is Impenetrable?
- Different job roles in Blockchain Technology
- Demur-rage currencies in Blockchain
- Blockchain of Things (BoT)
- What is Blockchain Ecosystem?
- How to Share Files in IPFS Blockchain?
- What is the CAP Theorem in blockchain
Interview Questions
- Top 50 Blockchain Interview Questions and Answers
- 15 Commonly Asked Blockchain Interview Questions & Answers
FAQs on Blockchain Technology
What programming languages are used for Blockchain?
We can use several programming languages to make our Blockchain-based projects :
Solidity is the majority-used programming language for blockchain-based projects.
See AlsoHow Cassandra and Kafka Fit in the Blockchain Ecosystem - AnantWhat Does Blockchain Look Like? A Comprehensive Guide to BlockchainDemystifying Blockchain Data Architecture: How It Empowers the Future of TrustTop 10 Fastest Blockchains by Maximum Daily Average TPS | Blockchain Solana | CryptoRank.ioHow Blockchain works step by step?
In general, many nodes within the same blockchain implementation are required to perform algorithms to evaluate, validate, and process the history of the blockchain block whenever a new blockchain transaction is added to the blockchain. The fresh block of blockchain transaction is accepted into the ledger and the new block containing data is added to the blockchain if the majority of nodes confirm the authenticity of the block’s history and signature.
What is a Blockchain Platform?
A blockchain platform allows developers and users to create transactions in the existing blockchain database. For example, Ethereum has a native cryptocurrency called Ether (ETH). But the Ethereum blockchain allows users to create smart contracts and programmable tokens used in initial coin offerings (ICOs), and non-fungible tokens (NFTs). These are built upon the Ethereum infrastructure and secure by Ethereum network algorithms and system
What Is Cryptocurrency?
Cryptocurrencies are often traded on decentralized exchanges and can also be used to purchase goods and services. It is a digital or virtual currency that uses cryptography to encrypt its transactions and regulate the creation of new nodes or blocks.
What is a Blockchain Wallet?
Blockchain wallets are like bank accounts in that they allow users to easily transfer money between their various accounts. But where banks rely on centralized systems or government rules and protocols to hold customers’ money, blockchain wallets use decentralized technology to manage transactions. It is a digital wallet that allows us to store, send, and receive cryptocurrencies like Bitcoin, Ethereum, Dogecoin, and Tether.
Please Login to comment...
Similar Reads
Flutter and Blockchain - Hello World Dapp
This tutorial will take you through the process of building your first mobile dapp - Hello World Dapp! This tutorial is meant for those with a basic knowledge of Ethereum and smart contracts, who have some knowledge of the Flutter framework but are new to mobile dapps. In this tutorial we will be covering: Setting up the development environmentCrea
9 min read
Integration of Artificial Intelligence and BlockChain
Artificial Intelligence and Blockchain are proving to be quite a powerful combination, improving virtually every industry in which they're implemented. These technologies can be combined to upgrade everything from food supply chain logistics and healthcare record sharing to media royalties and financial security. The integration of AI and Blockchai
8 min read
How to use GANACHE Truffle Suite to Deploy a Smart Contract in Solidity (Blockchain)?
There are various processes involved in deploying a smart contract using Ganache and Truffle Suite: 1. Install Ganache first. Ganache is a personal blockchain for Ethereum development. You must first download and install it. It is available for download from https://www.trufflesuite.com/ganache, the official website. 2. Install Truffle Suite: The n
4 min read
Introduction to Blockchain technology | Set 2
Blockchain technology has been garnering great hype recently. It gained popularity after the introduction of Bitcoin in 2009 by the person or group of people by the pseudonym Satoshi Nakamoto. Many people confuse and believe blockchain to be bitcoin. But, bitcoin is one application of the blockchain technology. There are many other applications and
5 min read
What is Blockchain Wallet?
A blockchain wallet is a software that enables sending and receiving cryptocurrencies such as Bitcoin, Ethereum, etc. It stores the record of transactions and also public and private keys which are used to perform transactions. A public key is similar to an account number. If A wants to send some money to B using Bitcoin when A sends the public key
10 min read
What is Consortium Blockchain?
A consortium blockchain is a group of multiple financial institutions where each financial institution has its private blockchain. In this blockchain, a pre-selected set of nodes are allowed to control the consensus process. What is Consortium Blockchain?Consortium blockchains are managed and run by a number of organizations or entities. As a permi
9 min read
Blockchain - Proof of Work (PoW)
Proof of Work consensus is the mechanism of choice for the majority of cryptocurrencies currently in circulation. The algorithm is used to verify the transaction and create a new block in the blockchain. The idea for Proof of Work(PoW) was first published in 1993 by Cynthia Dwork and Moni Naor and was later applied by Satoshi Nakamoto in the Bitcoi
6 min read
Benefits of Blockchain Technology
Blockchain is the backbone Technology of Digital CryptoCurrency BitCoin. Blockchain technology is a digital or ledger technology that evaluates the records and makes track of it in a peer-to-peer network. Each transaction is verified by the majority of participants of the system. It contains every single record of each transaction. Benefits of Bloc
5 min read
Blockchain and Data Privacy
Blockchain has been defined as a digital, decentralized ledger that keeps a record of all transactions that take place across a peer-to-peer network. It enables the secure transfer of assets without an intermediary. It also provides a record of transactions that is fully transparent and displayed in real-time for benefit of participants. Blockchain
11 min read
7 Project Ideas on Blockchain For Professionals
We have passed the time when blockchain was used only in the form of cryptocurrency. Today, it is being used in a broader domain and it's going to dominate in the coming future. As per the latest reports, it is expected that corporations will spend around $20 Billion on blockchain technical services by 2024. Industries like Healthcare, Insurance, I
8 min read
Consensus Algorithms in Blockchain
Prerequisites: Introduction to Blockchain technology | Set 1, Set 2 We know that Blockchain is a distributed decentralized network that provides immutability, privacy, security, and transparency. There is no central authority present to validate and verify the transactions, yet every transaction in the Blockchain is considered to be completely secu
5 min read
Blockchain to Secure IoT Data
INTRODUCTION: Internet of things and Blockchain are two technologies which are gaining popularity since the time of their creation. In the near future, IoT is going to influence almost every day-to-day items we use. As the usage of this technology increases, the threat to misuse it also increases. Existing technologies are not enough to deal with t
7 min read
Difference between Blockchain and a Database
Database: Generally a database is a data structure which is used for storing information. It is a organised collection or storage of data which is able to store a new data or access a existing data. The data stored in a database can be organized using a database management system. The database administrator can modify the data stored in the databas
2 min read
What Are Cryptoasssets in Blockchain
So as you are aware of Blockchain technology and have of the basic idea of it, in this article we will be talking about the cryptocurrency part of the blockchain, more specifically about the crypto-assets. As we know, an asset is something that holds value, similarly, a crypto-asset is an asset that is based on cryptography. Mostly it is a virtual
3 min read
Basics of the Blockchain and its various applications
The BlockChain, to begin with is undeniably one of the most ingenious inventions of mankind. Considering it to be the brainchild the pseudonym, Satoshi Nakamoto, the technology has evolved into something unimaginably great. However, the most commonly asked always arises every single time - What is this Blockchain? A BlockChain is defined as a peer
5 min read
Proof of Stake (PoS) in Blockchain
Proof of Stake (PoS) is a type of algorithm which aims to achieve distributed consensus in a Blockchain. This way to achieve consensus was first suggested by Quantum Mechanic here and later Sunny King and his peer wrote a paper on it. This led to Proof-of-Stake (PoS) based Peercoin. A stake is value/money we bet on a certain outcome. The process is
5 min read
How Block Hashes Work in Blockchain?
Blockchain is the backbone technology of the digital cryptocurrency Bitcoin. The blockchain is a distributed database of records of all transactions or digital events that have been executed and shared among participating parties. Each transaction is verified by the majority of participants of the system. It contains every single record of each tra
7 min read
Features of Blockchain
Here In this article, we will discuss the features of blockchain technology and how they make it a revolutionary and highly desirable platform for various applications. A blockchain is a chain of blocks that contains information. Most people think that Blockchain is Bitcoin and vice-versa. But it’s not the case. In fact, Bitcoin is a digital curren
7 min read
How does BlockChain support Crowdfunding ?
The Crowdfunding platform in block-chain makes different possibilities for the startups by raising the funds to create their own digital currency and it is peer-to-peer fund raising model some of the famous crowdfunding cryptocurrencies are coinspace, swarm, judobaby etc. Crowdfunding has offers for creators and other consumers. Anyone can particip
2 min read
Demur-rage currencies in Blockchain
Currency is one such core concept in blockchain technology that can extended and re-understood. Currency which is usually referred as digital token it facilitates quantified transfer mechanism. This idea is known as Demur-rage currency. Demur-rage means "cost of carrying"- that is the cost to carry an asset. The Demur-rage originated from freight a
2 min read
Blockchain Gaming : Part 1 (Introduction)
Blockchain Gaming. It’s a world of it’s own. It’s ‘Ready Player One’ incorporated into gaming. Before reading this article, it is recommended to read: Introduction to Blockchain to get well versed with the concept of blockchain. Part-1: Transparency, Proven Rarity and True Ownership Transparency: When games use third party distribution platforms li
4 min read
Blockchain Hash Function
A hash function is a mathematical function that takes an input string of any length and converts it to a fixed-length output string. The fixed-length output is known as the hash value. To be cryptographically secure and useful, a hash function should have the following properties: Collision resistant: Give two messages m1 and m2, it is difficult to
5 min read
Guidelines for learning Blockchain
As a beginner, while starting learning something new everyone is having a question in mind, "How to get started?". When I started learning Blockchain I was in the same situation. So I want to share my journey of BLOCKCHAIN with you, by this, every technical worm who is interested in learning new technologies will get an idea about this trending tec
6 min read
Blockchain and Block Header
Blockchain is a database, or broadly distributed database, used mainly for concurrent transactions and one of the most popular implementations of blockchain is Bitcoin. Blockchain has several blocks, also called nodes, and all the blocks are managed with the help of the block header. Constituents of Block Header are : TimestampVersionMerkle RootDif
3 min read
Top 10 Programming Languages for Blockchain Development
Do you ever wonder about the sudden emergence and popularity of Blockchain? What is it? Well, Blockchain is literally a chain of blocks as the name suggests! It’s just that the “blocks” in this context are digital information that is connected using cryptography. Each of these blocks contains a cryptographic hash function linking to the previous bl
7 min read
How Blockchain Technology Can Accelerate the Potential of IoT?
Yes, the blockchain has enormous potential to accelerate the Iot functioning efficiently. Since, security is a major concern with IoT that has hindered its large-scale deployment. IoT devices often suffer with security vulnerabilities that make them an easy target for Distributed Denial of Service (DDoS) attacks.So these are some concern of blockch
3 min read
Decentralized Voting System using Blockchain
Blockchain is a technology that is rapidly gaining momentum in era of industry 4.0. With high security and transparency provisions, it is being widely used in supply chain management systems, healthcare, payments, business, IoT, voting systems, etc. Why do we need it? Current voting systems like ballot box voting or electronic voting suffer from va
4 min read
Blockchain Incentives to Miners
A Blockchain is basically a database containing all the important information about the transactions of cryptocurrency, which is very difficult to manipulate. It can be called a Digital Ledger that contains all the information which is decentralized and distributed all across the nodes in the blockchain. Bitcoin is a digital cryptocurrency that use
4 min read
What is Cryptographic Primitive in Blockchain?
Blockchain is a distributed, decentralized ledger. It comprises blocks connected to one another. Each block comprises information such as transactions and a unique hash. The medium of exchange in Blockchain is cryptocurrency or crypto. What are Cryptographic Primitives?In Blockchains, there are no third parties or Governments involved. It is fully
5 min read
Benefits of Blockchain in Healthcare
A blockchain is a chain of blocks linked together using hashing technique. Each block consists of some timestamped records of information such as financial, healthcare, confidential data, etc. The Blockchain network is managed by a group of users on a decentralized network. All the information is available on a distributed ledger to all the users f
6 min read
Article Tags :
Trending in News
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
'); $('.spinner-loading-overlay').show(); jQuery.ajax({ url: writeApiUrl + 'create-improvement-post/?v=1', type: "POST", contentType: 'application/json; charset=utf-8', dataType: 'json', xhrFields: { withCredentials: true }, data: JSON.stringify({ gfg_id: post_id, check: true }), success:function(result) { jQuery.ajax({ url: writeApiUrl + 'suggestions/auth/' + `${post_id}/`, type: "GET", dataType: 'json', xhrFields: { withCredentials: true }, success: function (result) { $('.spinner-loading-overlay:eq(0)').remove(); var commentArray = result; if(commentArray === null || commentArray.length === 0) { // when no reason is availaible then user will redirected directly make the improvment. // call to api create-improvement-post $('body').append('
'); $('.spinner-loading-overlay').show(); jQuery.ajax({ url: writeApiUrl + 'create-improvement-post/?v=1', type: "POST", contentType: 'application/json; charset=utf-8', dataType: 'json', xhrFields: { withCredentials: true }, data: JSON.stringify({ gfg_id: post_id, }), success:function(result) { $('.spinner-loading-overlay:eq(0)').remove(); $('.improve-modal--overlay').hide(); $('.unlocked-status--improve-modal-content').css("display","none"); $('.create-improvement-redirection-to-write').attr('href',writeUrl + 'improve-post/' + `${result.id}` + '/', '_blank'); $('.create-improvement-redirection-to-write')[0].click(); }, error:function(e) { $('.spinner-loading-overlay:eq(0)').remove(); var result = e.responseJSON; if(result.detail.non_field_errors.length){ $('.improve-modal--improve-content .improve-modal--improve-content-modified').text(`${result.detail.non_field_errors}.`); jQuery('.improve-modal--overlay').show(); jQuery('.improve-modal--improvement').show(); $('.locked-status--impove-modal').css("display","block"); $('.unlocked-status--improve-modal-content').css("display","none"); $('.improve-modal--improvement').attr("status","locked"); $('.improvement-reason-modal').hide(); } }, }); return; } var improvement_reason_html = ""; for(var comment of commentArray) { // loop creating improvement reason list markup var comment_id = comment['id']; var comment_text = comment['suggestion']; improvement_reason_html += `
${comment_text}
`; } $('.improvement-reasons_wrapper').html(improvement_reason_html); $('.improvement-bottom-btn').html("Create Improvement"); $('.improve-modal--improvement').hide(); $('.improvement-reason-modal').show(); }, error: function(e){ $('.spinner-loading-overlay:eq(0)').remove(); // stop loader when ajax failed; }, }); }, error:function(e) { $('.spinner-loading-overlay:eq(0)').remove(); var result = e.responseJSON; if(result.detail.non_field_errors.length){ $('.improve-modal--improve-content .improve-modal--improve-content-modified').text(`${result.detail.non_field_errors}.`); jQuery('.improve-modal--overlay').show(); jQuery('.improve-modal--improvement').show(); $('.locked-status--impove-modal').css("display","block"); $('.unlocked-status--improve-modal-content').css("display","none"); $('.improve-modal--improvement').attr("status","locked"); $('.improvement-reason-modal').hide(); } }, }); } else { if(loginData && !loginData.isLoggedIn) { $('.improve-modal--overlay').hide(); if ($('.header-main__wrapper').find('.header-main__signup.login-modal-btn').length) { $('.header-main__wrapper').find('.header-main__signup.login-modal-btn').click(); } return; } } }); $('.left-arrow-icon_wrapper').on('click',function(){ if($('.improve-modal--suggestion').is(":visible")) $('.improve-modal--suggestion').hide(); else{ $('.improvement-reason-modal').hide(); } $('.improve-modal--improvement').show(); }); function loadScript(src, callback) { var script = document.createElement('script'); script.src = src; script.onload = callback; document.head.appendChild(script); } function suggestionCall() { var suggest_val = $.trim($("#suggestion-section-textarea").val()); var array_String= suggest_val.split(" ") var gCaptchaToken = $("#g-recaptcha-response-suggestion-form").val(); var error_msg = false; if(suggest_val != "" && array_String.length >=4){ if(suggest_val.length <= 2000){ var payload = { "gfg_post_id" : `${post_id}`, "suggestion" : `
${suggest_val}
`, } if(!loginData || !loginData.isLoggedIn) // User is not logged in payload["g-recaptcha-token"] = gCaptchaToken jQuery.ajax({ type:'post', url: "https://apiwrite.geeksforgeeks.org/suggestions/auth/create/", xhrFields: { withCredentials: true }, crossDomain: true, contentType:'application/json', data: JSON.stringify(payload), success:function(data) { jQuery('.spinner-loading-overlay:eq(0)').remove(); jQuery('#suggestion-section-textarea').val(""); jQuery('.suggest-bottom-btn').css("display","none"); // Update the modal content const modalSection = document.querySelector('.suggestion-modal-section'); modalSection.innerHTML = `
Thank You!
Your suggestions are valuable to us.
You can now also contribute to the GeeksforGeeks community by creating improvement and help your fellow geeks.
`; }, error:function(data) { jQuery('.spinner-loading-overlay:eq(0)').remove(); jQuery('#suggestion-modal-alert').html("Something went wrong."); jQuery('#suggestion-modal-alert').show(); error_msg = true; } }); } else{ jQuery('.spinner-loading-overlay:eq(0)').remove(); jQuery('#suggestion-modal-alert').html("Minimum 5 Words and Maximum Character limit is 2000."); jQuery('#suggestion-modal-alert').show(); jQuery('#suggestion-section-textarea').focus(); error_msg = true; } } else{ jQuery('.spinner-loading-overlay:eq(0)').remove(); jQuery('#suggestion-modal-alert').html("Enter atleast four words !"); jQuery('#suggestion-modal-alert').show(); jQuery('#suggestion-section-textarea').focus(); error_msg = true; } if(error_msg){ setTimeout(() => { jQuery('#suggestion-section-textarea').focus(); jQuery('#suggestion-modal-alert').hide(); }, 3000); } } document.querySelector('.suggest-bottom-btn').addEventListener('click', function(){ jQuery('body').append('
'); jQuery('.spinner-loading-overlay').show(); if(loginData && loginData.isLoggedIn) { suggestionCall(); return; } // load the captcha script and set the token loadScript('https://www.google.com/recaptcha/api.js?render=6LdMFNUZAAAAAIuRtzg0piOT-qXCbDF-iQiUi9KY',[], function() { setGoogleRecaptcha(); }); }); $('.improvement-bottom-btn.create-improvement-btn').click(function() { //create improvement button is clicked $('body').append('
'); $('.spinner-loading-overlay').show(); // send this option via create-improvement-post api jQuery.ajax({ url: writeApiUrl + 'create-improvement-post/?v=1', type: "POST", contentType: 'application/json; charset=utf-8', dataType: 'json', xhrFields: { withCredentials: true }, data: JSON.stringify({ gfg_id: post_id }), success:function(result) { $('.spinner-loading-overlay:eq(0)').remove(); $('.improve-modal--overlay').hide(); $('.improvement-reason-modal').hide(); $('.create-improvement-redirection-to-write').attr('href',writeUrl + 'improve-post/' + `${result.id}` + '/', '_blank'); $('.create-improvement-redirection-to-write')[0].click(); }, error:function(e) { $('.spinner-loading-overlay:eq(0)').remove(); var result = e.responseJSON; if(result.detail.non_field_errors.length){ $('.improve-modal--improve-content .improve-modal--improve-content-modified').text(`${result.detail.non_field_errors}.`); jQuery('.improve-modal--overlay').show(); jQuery('.improve-modal--improvement').show(); $('.locked-status--impove-modal').css("display","block"); $('.unlocked-status--improve-modal-content').css("display","none"); $('.improve-modal--improvement').attr("status","locked"); $('.improvement-reason-modal').hide(); } }, }); });